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: David Given
Subject: Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax
Date: Wed, 14 Mar 2007 11:12:33 +0000
User-agent: Thunderbird 1.5.0.10 (X11/20070221)

Paolo Bonzini wrote:
[...]
> 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.

D'oh! Yes, of course.

I was about to suggest that this particular problem could be easily patched by
requiring you to create your class and add methods in two separate stages, viz.:

---snip---
Class addSubclass: 'MyClass' withVariables: 'message'.
MyClass addMethods: [ :class
    class method: 'go' is: [
        ...
    ]
]
---snip---

...but on further reflection, the compiler (which thinks it's compiling a
simple evaluation block) *still* doesn't know that it's supposed to use the
class namespace. So this doesn't help.

If the compiler can't find a scoped variable, it generates a call to
SystemDictionary>>at:, right? Is there any way we could edit the bytecode when
we convert the block to a method to replace these calls with instance variable
lookups? Or is that just too evil for words?

Alternatively, if we could somehow defer the compilation of a block until
method-add time, we could configure the compiler to know about the class
variables. This is a little complex due to the fact that the code containing
the block must be compiled in the first place so that we can run the method to
add the method... the simplest way round this is to have Class>>method:is:
take a string, but that's deeply unpleasant. Hmm. Special syntax for a
partially compiled Block, that becomes an array of parse tokens, perhaps?

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

...as I'm now beginning to realise.

-- 
┌── dg@cowlark.com ─── http://www.cowlark.com ───────────────────
│ "Wizards get cranky, / Dark days dawn, / Riders smell manky, / The road
│ goes on. / Omens are lowering, / Elves go West; / The Shire needs
│ scouring, / You may as well quest." - John M. Ford

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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