Squeak forth and Logo

Francisco Garau francisco.garau at gmail.com
Sat Apr 8 10:49:02 UTC 2006


I am having fun with dates, and I can build them with the following 
expression:

    2006 year april dayNumber: 30

I don't like the keyword selector there, because it breaks the beauty of the 
expression and forces parenthesis afterwards. It would be nicer if I could 
write:

    2006 year april 30

It would never had occurred to me that numbers *could* be selectors if I 
hadn't taken a look at Forth. In that amazing little language *anything* can 
be a selector (eg. #?! or ^%* are valid selectors or word names, as they 
call them).

As a comprise, I decided to use the following expression:

    2006 year april day30

But that leaves me with another problem. Basically defining 31 methods like 
this:

    TmActualMonth>>day30
        ^ self dayNumber: 30

Very boring. In the very Logo way, I created a method that creates those 
boring methods:

    TmActualMonth class>>installBoringMethods
        (1 to: 31) collect: [:number |
            self fakeCompile:
                (String streamContents:
                    [:stream |
                    stream
                        nextPutAll: 'day';
                        print: number; cr; tab;
                        nextPutAll: '^ self dayNumber: ';
                        print: number ] ) ]

Now I have to rush to our first UK Smalltalk meeting. Stephen Taylor from 
APL fame will be giving a presentation. It seems that there are lots of 
similarities between the APL and the Smalltalk community. But we are 
bigger!!

-Francisco









More information about the Squeak-dev mailing list