[ Prev ] [ Index ] [ Next ]

Block and array types special syntax

Created Friday 28 November 2008

Abstract

The purpose of this specification is to allow the declaration of arrays directly as types, and be able to use different prototype for the array types and block types.

Currently, native array are described in the prototype NATIVE_ARRAY. The prototype is lying to the compiler (the compiler has no idea this is an array at all). Thus this may be a problem in some cases where the compiler needs to know it is an array.

Syntax proposal for blocks

Current syntax for BLOCKs type is:

+ var :{INPUT;OUTPUT};

Where INPUT and OUTPUT are the input and output parameters of the block. The new syntax will also allow to write (in addition to the current syntax):

+ var :BLC{INPUT;OUTPUT};

In such cases, the prototype BLC will be used when messages are sent to var. The messages sent must match a slot in the prototype BLC. If BLC is not present (current syntax) then the prototype BLOCK will be automatically used.

TODO: there should be a way for the prototype the name of the slot value.

Syntax proposal for arrays

For arrays, the following syntax is proposed:

+ var1 :ARR[T];	// (1)
+ var2 :ARR[T, n];	// (2)
+ var3 :[T];		// (3)
+ var4 :[T, n];	// (4)

The syntax (3) is just a shortcut of (1) where the prototype ARR is replaced by NATIVE_ARRAY (just like for blocks). The syntax (4) is just a shortcut for the syntax (2) where ARR is FIXED_ARRAY.

Remark: The prototypes ARR must be generic prototypes. For the syntax (1) it must be accept one generic argument which is the type of the value in the array. For the syntax (2) the second generic argument is an integer representing the number of elements in the array. Those prototypes should correctly define their size slot (in the Section Header, see Expanded Inheritance).

Benefits

The new syntax for arrays will allow the compiler to correctly generate arrays for External slots, and also for Portable Libraries.

The ability to use any prototype for blocks would be useful to implement convenient slots when one cannot modify the standard library.

See also


Backlinks: :Computer:Lisaac:Specs :Computer:Lisaac:Specs:Future Work:Compiler cleanup :Computer:Lisaac:Specs:Future Work:Portable Libraries