05.08.2014 Views

here - Stefan-Marr.de

here - Stefan-Marr.de

here - Stefan-Marr.de

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.2. SOM: Simple Object Machine<br />

SOM’s focus on clarity and a minimal set of concepts makes it a good candidate<br />

to express the execution semantics of the OMOP. Essential semantics<br />

can be expressed while the acci<strong>de</strong>ntal complexity that comes with the extensive<br />

feature set of common mainstream languages is avoi<strong>de</strong>d. Compared to<br />

basing the semantics on a calculus such as the impς-calculus of Abadi and<br />

Car<strong>de</strong>lli [1996], SOM provi<strong>de</strong>s a platform that is closer to common language<br />

implementations. It inclu<strong>de</strong>s common language concepts and their essential<br />

complexity. For instance, this directly allows a discussion of the special case<br />

of VM primitives, which would not be the case with an application of the<br />

impς-calculus, without adding specific extensions to it.<br />

AweSOM 2 is chosen over the other available SOM implementations, because<br />

its Smalltalk implementation is the most concise in the SOM family and<br />

enables the formulation of an executable semantics that is concise enough to<br />

serve for illustration as part of this dissertation.<br />

4.2.1. Language Overview and Smalltalk Specifics<br />

This section gives a brief overview of SOM’s Smalltalk syntax and Smalltalk<br />

concepts used in the source co<strong>de</strong> examples of this dissertation.<br />

SOM’s standard implementation relies on a textual syntax for class <strong>de</strong>finitions.<br />

Lst. 4.1 gives a minimal <strong>de</strong>finition of the class Object. Note that Object<br />

inherits from nil and thus, it is the root class of the class hierarchy. If neither a<br />

superclass nor nil are given, a class will implicitly have Object as superclass.<br />

1 Object = nil ( " <strong>de</strong>fines the class Object , superclass is ‘nil ’"<br />

2 | class | " object fields : each object has a field ‘class ’"<br />

3<br />

4 class = ( ^ class ) " method to return field ‘class ’"<br />

5 = other = ( ^ self == other )<br />

6 == other = primitive " equality test implemented in the VM"<br />

7 asString = ( ^’instance of ’ + ( self class ) )<br />

8 value = ( ^ self )<br />

9 yourself = ( ^ self )<br />

10 ifNil : nilBlock ifNotNil : goBlock = (^ goBlock value )<br />

11<br />

12 " Error recovering "<br />

13 doesNotUn<strong>de</strong>rstand : selector arguments : arguments = (<br />

14 self error : ’ Method not found : ’<br />

15 + class name + ’ >>#’ + selector ) )<br />

Listing 4.1: SOM Language Example: Object class extending nil<br />

2 https://github.com/smarr/SOM/#readme<br />

91

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!