Syntaxes & Block Closures
Henrik Gedenryd
Henrik.Gedenryd at lucs.lu.se
Fri Sep 15 16:25:52 UTC 2000
Mats Nygren wrote:
>> I think there has got to be a better solution for embedding code than
>> comments (given the potential quote problem), but I'm not sure exactly
>> what.
>
> It is important to try to avoid that. This can be done by making
> the involved syntaxes a little more flexible, or inventing new ways of
> interpreting existing syntactic constructs. I have in this way
> eliminated the need to write C-code directly in strings as is done now.
> (The quote problem doesn't exist, see above)
The straight forward solution, which is already used in Slang, is to define
messages that do nothing in Squeak but have a meaning in the other
language., like #inline:, #cCoerce:into:.
E.g.
Python import: 'moduleName'
where Python would be eg. a subclass of OtherLanguage.
also, instead of
MyClass>>myPythonishMethod
"Restrict: Smalltalk->Python (level 2)"
you would probably do this on a class basis in the regular way, say
MyClass class>>parser
^PythonLevel2 parser
otherwise, inherit a class defining
#language: language
^language parser ~~ self class parser
ifTrue: [self error: 'This method requires ', language printString]
Henrik
More information about the Squeak-dev
mailing list
|