I miss my Ruby macros (1st day in Squeak and I love it ... dislike the
camelCase tho'). Would this be the correct way to go about it? RUBY: class Class def has_many symbol ...generate getter/setter with Collection.new end end class House has_many :doors # just remove this line to "Undo" ! end SQUEAK: !Class methodsFor: 'macros' stamp: 'xy 7/1/2006 18:34'! has_many: aSymbol ... generate getter/setter with (Collection new) ... record meta-data fact on the class itself ! ! undo_has_many: aSymbol ... check meta-data on the class ... remove getter/setter ! ! Any starting hints for: (a) what would I put in the "...." :-) (b) how to put these onto convenient popup menus? (c) pointers to specific freely available stuff like these? Many thanks. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Hi,
i> (b) how to put these onto convenient popup menus? right click on the desktop, to get the context menu. The entry at the bottom is "personalize" which will bring up a browser on Preferences class side method personalizeUserMenu: This contains examples and explanations. You first will have to solve your other questions but I can't help there. Cheers! Herbert mailto:[hidden email] _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Sophie424
On Sat, 01 Jul 2006 21:33:04 -0700, itsme213 <[hidden email]> wrote:
> I miss my Ruby macros (1st day in Squeak and I love it ... dislike the > camelCase tho'). Would this be the correct way to go about it? Not to hijack, but this is the second time I've run across the term "camelCase" in the past week after never running into it before. I always thought the term for caps in the middle was "infix"--but when I didn't see "infix" used anywhere in what I was searching, I began to wonder--have I made this up? _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Am 02.07.2006 um 11:03 schrieb Blake: > On Sat, 01 Jul 2006 21:33:04 -0700, itsme213 <[hidden email]> > wrote: > >> I miss my Ruby macros (1st day in Squeak and I love it ... dislike >> the camelCase tho'). Would this be the correct way to go about it? > > Not to hijack, but this is the second time I've run across the term > "camelCase" in the past week after never running into it before. I > always thought the term for caps in the middle was "infix"--but > when I didn't see "infix" used anywhere in what I was searching, I > began to wonder--have I made this up? I guess so. I only know "infix" pertaining to "notation", in contrast to "prefix" and "postfix" notation. http://en.wikipedia.org/wiki/Infix_notation I got to know the style as "mixed case", contrasting with "upper case" and "lower case". But "CamelCase" seems to have become ubiquitous, my personaI guess is because it's an insiders-joke, similar to "duck typing": http://en.wikipedia.org/wiki/CamelCase - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Sophie424
Am 02.07.2006 um 06:33 schrieb itsme213:
> I miss my Ruby macros (1st day in Squeak and I love it ... dislike > the camelCase tho'). To add a variable to a class, use someClass addInstVarName: 'myInstVar'. To add an accessor with initialization code, compile one: someClass compile: 'myInstVar ^myInstVar ifNil: [myInstVar := OrderedCollection new]'. Similarly, use #removeInstVarName: and #removeSelector: to remove what you added. To automate the process, you could implement #noteCompilationOf:meta: to add/remove stuff automatically when some "spec" method was changed. HOWEVER, such "magic" behavior is not considered good practice in Smalltalk. We do use code generation for repetitive tasks, but that is usually triggered not automagically, but invoked manually - we put the actual call in a comment that you can just double-click and execute. An example for this is the various "#fields" methods for ExternalStructure subclasses which include a "self defineFields" comment that should be executed when you changed the field definitions. The reason for this non-magic is mostly because you're dealing with an evolving, live system that is not bootstrapped every time you run your app like in Ruby. After you let the system define the methods, you're free to change them in a browser to suit your needs. In Smalltalk, you're actually modifying the class, not a textual blue- print that is executed later. That's a huge difference, it's hard to grasp when you come from a different environment, admittedly, but you need to get your head around it to become a proficient Smalltalker. Once you got enlightened, you'll wonder how you could ever have longed for editing a Smalltalk class in a text file ;-) - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Sophie424
> -----Original Message-----
> From: [hidden email] > [mailto:[hidden email]] On > Behalf Of itsme213 > Sent: Saturday, July 01, 2006 9:33 PM > To: squeak-beginers > Subject: [Newbies] Ruby macros > > I miss my Ruby macros (1st day in Squeak and I love it ... > dislike the camelCase tho'). Would this be the correct way to > go about it? > > RUBY: > > class Class > def has_many symbol > ...generate getter/setter with Collection.new > end > end > > class House > has_many :doors # just remove this line to "Undo" ! > end > Correct me if I'm wrong, but those Ruby macro's don't actually generate getters and setters, rather, don't they just setup method_missing to intercept those calls as if getters and setters actually existed? Don't the relationships in ActiveRecord do this as well? If so, method_missing is the same as Smalltalk's doesNotUnderstand:, so you can accomplish the same thing in Smalltalk by overriding new on the class side and implementing methods like hasOne: and hasMany: to setup a property hash in the object that doesNotUnderstand: can check to handle messages. As a newbie, I doubt you're ready for hacking doesNotUnderstand:, yet, but it's certainly possible to implement declarative relationships, quite easily in fact. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |