[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

[S8] Extensions to Smalltalk syntax

As we run on top of low level execution machinery that is not opaque[1], there are times we want to express/access something at the lower levels of the execution engine.
S8 compiler support a small number of extensions to smalltalk syntax to access objects in native layers.

SyntaxEffectHow/where it is used?
{' javascript '} Inline the javascript code in the generated code. It is used to implement basic operations that are provided by javascript language or can be expressed by minimal variations of it. Most times are used to implement basic operations like Primitive ops in smalltalk.Use references tool with searchSource: for {'
object#propertyNameGenerate the code to direct access the property(propertyName) of the object. It is equivalent to dot op in javascript. The result can be undefined. It is reccomended to be written as
object basicAt: propertyName
(or basicAt:ifAbsent:)
See implementors of accessors to NativeObject properties e.g. HTMLElement>>#scrollTop
#{aName}Lookup for object named aName will be realized in javascript. The result can be undefined.
Note: in case the name is lowercase, the S8 compiler do not force the existence of the target, so if the name is not found in the executing context lookup will continue at the javascript upper contexts (e.g. global object).
See implementation of Object>>#halt
# aMessageThe use of # for receiver means the receiver is missing, and the function activated for the message will be look up in global context. For example
# gc
generates javascript code
gc()
See implementation of Object>>#print:
receiver #message: arg1 with: arg: 2 and: arg3Will call function "message" (selector up to first colon, ignoring remaining parts of the selector) with the arguments. In the example it will generate javascript code
receiver.message(arg1,arg2,arg3)
See implementation of Number>>#isNumber

[1] Information hiding is a facility imposed to let us not be distracted by underlying mechanisms WHEN (and only when) we do not want to. Putting the vellum out must be mediated by an immediate gesture.