Syntaxes & Block Closures

Paul Fernhout pdfernhout at kurtz-fernhout.com
Fri Sep 15 17:17:06 UTC 2000


Henrik-

Great suggestions!

Regarding class overrides vs. comments, one issue is how to handle a
Smalltalk method intended to be translated to multiple languages.  For
example, one could imagine the VM might be written so it could be
translated say to any of C, Delphi, Scheme or various assembler
dialects. Adding more target languages might tighten up the restrictions
on how methods intended for translation (as well as emulation under
Smalltalk) could be coded and what classes and methods they could
reference.

One might generalize the example you give:

  MyClass class>>parser
    ^PythonLevel2 parser
to return a collection of allowable language forms. Thus:

  MyClass class>>desiredTranslations
    ^#(PythonLevel2 Delphi3 AnsiC MzScheme 68000 80386)

Then for any such class, as a method was created or changed, all desired
translators would be asked if they were OK with the overall structure of
that method as well as whether only translateable classes and methods
were referenced.

I think there are a lot of complex issues here, specifically what to do
when only a small part of a method needs to be coded differently for a
specific target language given different idioms the current level of the
respective translator supports. 

Gradually, what we are doing here is adding aspects of a Lisp-like "code
is data, data is code" flavor to translateable methods.

-Paul Fernhout
Kurtz-Fernhout Software 
=========================================================
Developers of custom software and educational simulations
Creators of the Garden with Insight(TM) garden simulator
http://www.kurtz-fernhout.com

Henrik Gedenryd wrote:
> 
> 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