Lambda the Ultimate

inactiveTopic F-Script: Smalltalk Scripting for Mac OS X
started 10/17/2002; 6:33:19 AM - last post 10/17/2002; 9:33:38 PM
Ehud Lamm - F-Script: Smalltalk Scripting for Mac OS X  blueArrow
10/17/2002; 6:33:19 AM (reads: 1796, responses: 1)
F-Script: Smalltalk Scripting for Mac OS X
Philippe Mougin. F-Script: Smalltalk Scripting for Mac OS X. ESUG 2002

F-Script is a scripting language that was inspired by both Smalltalk and APL. The language was discussed here previously.

These slides show how F-Script is integrated with Cocoa (the OS X framework).

Compressed PPT file.


Posted to OOP by Ehud Lamm on 10/17/02; 6:33:51 AM

rev - Re: F-Script: Smalltalk Scripting for Mac OS X  blueArrow
10/17/2002; 9:33:38 PM (reads: 661, responses: 0)
F-Script is fun to play with, indeed. One thing that kind of turned me off of it is that you cannot create full apps with it, forgoing Objective-C for everything but perhaps something performance intensive. You cannot create classes in F-Script, just instantiate ObjC classes.

But than again, that isn't a failing so much as a "feature-" F-Script is for scripting Cocoa, not for creating Cocoa apps. For me, I'd like it more if I could write entire apps in it. :)

It has some nifty features with collections, that I'm told are derived from APL. One afternoon, I took a few minutes to implement similar features in Squeak. F-Script has a wee bit of syntactic sugar (well, probably not, probably implemented as regular messages, so they're not technically sugar) to automagically issue #collect: messages on collections. That is-

#(1 2 3) * 2 yields #(2 4 6) in F-Script. In Smalltalk, you'd typically do that with #(1 2 3) collect: [ :n | n * 2 ]. Getting behavior ala F-Script in Smalltalk is a pretty trivial (but fun to implement) matter of overriding #doesNotUnderstand:, basically telling Collection to do a "self perform: #collect: with: aBlock" whenever the message isn't found in Collection. aBlock is a block created that reflects what message and args were passed to the collection- in the example above, if the message sent ws #* and the argument 2, compose a one argument block - [ :n | n * 2].

In the cases that there is already a message name that's a part of Collection, F-Script uses Collection's message. To force the use of the APLish #collect: jobbie, you throw in a @. Like so:

#(1 2 3) @ someMessage: 'foo'.

Again, this is very easily implementable in Squeak- you can create a binary message @. I think there is already a method called that in the Squeak system, but it can be renamed, either the feature borrowed from F-Script, or the existing message in the image. I don't think those changes improve productivity enough that they're worth having in Squeak by default, but they're fun all the same, and for a somewhat newbie looking to learn about the way Squeak handles messages and such, it'd be a great lazy Sunday thing to thinker with.

I'm sure this is all in those slides, but I just feel like rambling as I avoid doing my AI homework. :P