Is there a language specification for SOM?

21 views
Skip to first unread message

R. K.

unread,
Aug 10, 2020, 10:01:24 AM8/10/20
to SOM, Simple Object Machine: VMs for Research and Teaching

SOM looks like a great scripting language and I would like to have a version runnin on LuaJIT. My current method to implement the parser (see https://github.com/rochus-keller/Som) is trial an error based on the existing SOM files from https://github.com/SOM-st/som and looking into the other implementations which is ok, but I would prefer to have some kind of language report/specification to reduce ambiguity and knowledge acquisition effort. E.g. what should officially happen if a given code base includes classes colliding with the "kernel" classes (e.g. Vector and Pair in https://github.com/smarr/are-we-fast-yet), or there are classes with the same name in a codebase (e.g. Node in SOM Examples Benchmarks)? Should the later parsed files just replace the former ones, or should an error be reported? I didn't find a specification so far; does anyone have such a document?

Stefan Marr

unread,
Aug 10, 2020, 10:15:59 AM8/10/20
to R. K., SOM, Simple Object Machine: VMs for Research and Teaching
Dear R.K.:

> On 10 Aug 2020, at 15:01, R. K. <rochus...@gmail.com> wrote:
>
> SOM looks like a great scripting language and I would like to have a version runnin on LuaJIT. My current method to implement the parser (see https://github.com/rochus-keller/Som) is trial an error based on the existing SOM files from https://github.com/SOM-st/som and looking into the other implementations which is ok, but I would prefer to have some kind of language report/specification to reduce ambiguity and knowledge acquisition effort.

There’s a grammar for SOM here: https://github.com/SOM-st/SOM/blob/master/specification/SOM.g4

We don’t have a specification in the sense of an English text defining the semantics though.

> E.g. what should officially happen if a given code base includes classes colliding with the "kernel" classes (e.g. Vector and Pair in https://github.com/smarr/are-we-fast-yet), or there are classes with the same name in a codebase (e.g. Node in SOM Examples Benchmarks)? Should the later parsed files just replace the former ones, or should an error be reported? I didn't find a specification so far; does anyone have such a document?

There’s no such document. Sorry.

Though, the question has come up repeatedly and various details have been discussed in the issue tracker:

https://github.com/SOM-st/SOM/issues?q=label%3Aspec

For this particular question, relying on the various language implementations, the behavior is somewhat similar to Java.

This means, SOM uses the class path to find a class.
It will load the first one it finds.
Once that class is loaded, it’s a known “global” and no further class loading for that name is performed.

The general idea in SOM is that the grammar permits for identifiers, which are either locals, arguments, fields, or globals. If it’s a global, but not actually initialized/defined, a handler is triggered (Object>>#unknownGlobal:), which then does the class loading, see: https://github.com/SOM-st/SOM/blob/master/Smalltalk/Object.som#L81

Does this answer your question?

In case you aim to have a “compatible” SOM implementation, please see:
- https://github.com/SOM-st/SOM/tree/master/TestSuite
- and for early versions https://github.com/SOM-st/SOM/tree/master/TestSuite/BasicInterpreterTests which doesn’t require as much of SOM to work yet.

Especially questions like “what’s expected to happen here” would be very welcome on the issue tracker.
This helps me to keep track of things, and perhaps one day, to actually have a specification that answer such questions.

Thanks
Stefan

--
Stefan Marr
School of Computing, University of Kent
https://stefan-marr.de/research/


R. K.

unread,
Aug 11, 2020, 8:44:11 AM8/11/20
to SOM, Simple Object Machine: VMs for Research and Teaching
Thanks for this information which was helpful.
Yes, I knew it, but this is only the syntax specification; all my questions concern the semantics.


Ok, I will lookup and post questions to the Github issue list (which is more convenient anyway since gmail apparently classifies mails from this list as spam).

> In case you aim to have a “compatible” SOM implementation, please see:

Thanks, I'm already using the test suite; it is very helpful but there are still open questions as I go; will have a closer look at your C++ implementation then.

Best regards
Rochus

Reply all
Reply to author
Forward
0 new messages