Squeak scripting syntax (was: Re: how to get arg and print on
the output)
Bert Freudenberg
bert at impara.de
Mon Aug 21 17:13:02 UTC 2006
Neat!
If we want to play parser tricks, however, we could get rid of the
extra brackets by making leading whitespace significant inside of #
[]. Admitted, I like Python for that feature ;-)
Object subclass: #Point definition: #[
| x y |
magnitude
^((x * x) + (y * y)) sqrt
+ aPoint
^(x + aPoint x) @ (y + aPoint y)
].
- Bert -
Am 21.08.2006 um 15:56 schrieb Andreas Raab:
> Couple of years back I used something quite similar to Ian's
> version - the main difference was that instead of prototypes it
> used classes so it would look like this:
>
> Object subclass: #Point definition: #[
> | x y |
> magnitude [
> ^((x * x) + (y * y)) sqrt
> ]
> ]
>
> (I still have an ~400k image based on this stuff ;-) The trick in
> the above is that I redefined #[] to mean a "token array" that
> would be processed as part of the #subclass:definition: message so
> it retained the expression nature of class definitions. It's kind
> of cool but also overkill - these days I'd go straight for human
> readable syntax instead of fancy parser tricks ;-)
>
> Cheers,
> - Andreas
>
>
> Bert Freudenberg wrote:
>> florent trolat schrieb:
>>> stéphane ducasse a écrit :
>>>>>
>>>>> Right - so this really only applies to headless command line
>>>>> use. So why not create a special squeak shell for them?
>>>>>
>>>>> You could create a stripped image with OSProcess preloaded,
>>>>> write a small shell script or launcher program (say, "squeash")
>>>>> that runs a headless VM with the image, et voilà, Squeak for
>>>>> scripting.
>>>>
>>>> Exact! And with a syntax for writing method and class without !!
>>>> and !
>>>> I will give a try at that.
>>>
>>> (hi,) an example of syntax?
>> I like Ian's:
>> http://piumarta.com/pepsi/pepsi.html
>> There are others, like
>> http://www.double.co.nz/smallscript/byexample.htm
>> - Bert -
>
More information about the Squeak-dev
mailing list
|