Planet JFX
Register
Advertisement

Syntax differences between compiler and interpreter[]

Class definition and declaration[]

In the interpreter, the class includes only the member declarations, not their definitions; in the compiler, these are defined inside the class, just as in Java. Attribute change triggers have been moved into the class as well, using the "on change { block }" syntax.

Nonprivate class members must have explicit types; this means attributes must have an explicit type, and function signatures must have explicit types for return value and argument types.

Attribute values specified in a class are considered defaults only. If the object literal specifies a value, the defaults are not evaluated.

Interpreter:

 class Foo { 
   attribute foo;
   function moo(x);
 }
 
 attribute Foo.foo = 3;
 
 function Foo.moo(x) = { x + 1 }
 
 trigger on Foo.foo = newValue { code }


Compiler:

 class Foo { 
   attribute foo = 3
     on change { code };
   
   function moo(x) { x + 1 }
 }

Functions vs Operations[]

Currently, operations and functions have been folded together. Bind semantics are still up in the air.


Initialization[]

Any code that must be run after the instance is created via the object literal can be placed in an optional init { } block within the class definition. This can be used to reject invalid arguments, perform additional initialization steps, etc.

Compiler:

 class Foo { 
   attribute foo = 3
     on change { code };
   
   function moo(x) { x + 1 }

   init { 
     initialization code here
   }
 }

Modifiers[]

The compiler currently recognizes public, private, protected, abstract, and readonly as member modifiers.


Block Expressions[]

  • to be filled in*


Use of extends instead of supertype on class definition[]

  • to be filled in*


Import[]

  • to be filled in*


Cardinality[]

The only cardinality specifiers are nothing (instance) and [] (sequence).

Advertisement