From: Dave Burt Date: 2005-04-07T15:34:44+09:00 Subject: Re: [curiousity] why aren't declarations just syntactic sugar? "Florian Gro�" responded: > Dave Burt wrote: > >> "MyClass do ..." looks like a syntax error to me. >> >> How about a Class#| for this (think set union like Array#|)? >> >> MyClass |= Class.new do >> .... >> >> First-class methods would make implementation of something like this >> convenient. > > That would not work though as the block can not bind to the | operator. I know that. I was thinking, "what if you could add all the methods defined in that anonymous class to MyClass?" This would effectively be a way of doing multiple inheritance, and has all the problems associated with that. (e.g. Class.new will make a class that inherits from Object, and those methods would have to be "ORed" into MyClass as well as any explicitly defined.) So it's a bad thing. It makes more sense if the RHS is a Module. And you can do that already, with mix-ins (extend, include) I still think it's an interesting thought. Cheers, Dave