Syntax & Sematics [was: Re: [Enough already] Re: Proposal3: Make $_ ..]

Mats Nygren nygren at sics.se
Thu Jun 1 13:34:28 UTC 2000


JArchibald at aol.com wrote:
> => 6/1/00 12:36:59 AM EDT, ok at atlas.otago.ac.nz [personal communication] =>
> << The great ideas in Smalltalk are semantic.  They'll survive the new 
> additional Squeak syntax (whatever it happens to look like).  And they'll 
> survive underscores. >>
> 
> I agree completely. I tend to think of a Smalltalk program as a semantic 
> construct associated with the parse tree for that program. The nature of this 
> semantic construct is unfortunately ungrounded, somewhat waving the the air. 
> [snip]

I to agree completely, and have planned to show some results to this
list during the year.

My main idea is to assign parse trees an important role, the compiler
should take a parse tree, how that was contructed is non of its
business. I have already experimented with this using Squeak-like,
C-like, Python-like, Scheme-like syntaxes. (But outside of Squeak, which
is new to me).
And within each many variations are possible. To make it all work there
need to be bijective mappings between the syntaxes which need some
thought and some work. In this framework I can write things for
C-compilation in any of the syntaxes above (the Squeak-syntax being
of course quite similar to Slang). It is also possible to write
Squeak-code (for fileIn) in Python-syntax.

In short, syntax and semantics shuold be separated. Both will benefit.
Semantics (for example the Squeak execution environment) will be
available in more ways. And syntaxes can be used for more purposes.

I sincerely hope that at least some of the people on this list will take
an interest in this line of development.

It will take some time before I am more acquainted with Squeak internals
and have ported this material into it.

This will be my MSc thesis (never finished that), with your support it
will be an enjoyable work and should lead to a nice and well documented
structure on the syntax handling in Squeak. I also add that IMO the structure of C code generation (Slang) will be improved with this and the language Slang will mature somewhat.

Another important consideration of course is the SqC work in this
direction. We will soon hear about this I hope.

A simple example. Each maps to each other via a parsetree, assuming one of several identifier mappings. Note that comments are preserved. Also note that there are two different Squeak-versions, one could turn into the other in (seemingly) no time.

" example "
x < y ifTrue: [
   fooBar _ 1 
] ifFalse: [
   fooBar _ 2
]

" example "
x < y ifTrue: [
   foo_bar := 1 
] ifFalse: [
   foo_bar := 2
]

// example
if (x < y)
   foo_bar = 1;
else
   foo_bar = 2;

; example
(if (< x y)
    (set! foo-bar 1)
    (set! foo-bar 2))

# example
if x < y:
   fooBar = 1
else:
   fooBar = 2

Many things remains to be said on the matter but I end for now.

Cheers,

/Mats Nygren





More information about the Squeak-dev mailing list