help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax
Date: Wed, 14 Mar 2007 08:54:38 +0100
User-agent: Thunderbird 1.5.0.10 (Macintosh/20070221)

> This worries me slightly --- as soon as you start adding special cases to your
> language to add support for certain features, your language syntax starts
> becoming inconsistent, which is a Bad Thing. There ought to be a way to do
> this that avoids such nastiness.

Agree 100% -- consider anything in that message, before the final version, to
be just a rationale for the proposed syntax, or a hint that it is not *so* far 
from
pure Smalltalk.

> How about something along these lines:
> 
> ---snip---
> 
> 'Hello, world!' printNl. "A simple statement."
> 
> Class subclass: 'MyClass' is: [ :class
>     class classMethod: 'new' is: [
>         | i |
>         i := super new.
>         i message: 'Hello, world!'.
>         ^i
>     ].
> 
>     class method: 'go' is: [
>         message printNl
>     ].
> 
>     class variable: 'message'.
>     class method: 'message:' is: [ :m |
>         message := m
>     ].
> ].

> (I'm assuming heavily that it's possible to turn a Block into a method without
> any horrible side effects.

I actually like this more than any other proposal, and it's indeed not hard
to turn a block into a method as long as it does not access external closure
variables.  It's interesting enough that in your example the temporary variable
syntax would map to class variables:

Class subclass: 'MyClass' is: [ :class |
    "Foo, defined in the closure passed to #subclass:is:, is visible
     to both class methods and instance methods..."
    | Foo |
]

But you're assuming much more than that: you're assuming that the
block compilation can be deferred to the point where the block is evaluated!
Otherwise, "message" would not be known as an instance variable when the last
block is compiled.

Even worse for the "go" method that is compiled before the variable is declared.

That's an unavoidable problem with a "pure Smalltalk" syntax, AFAICT.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]