It is thus possible to create instances of Smalltalk classes and bind them to Agora variables. This feature is heavily used in the bezier.ago
example in the examples
folder.
Not only can Smalltalk objects be transparently used in Agora programs, Agora objects can also be transparently used in Smalltalk programs ! They can be passed freely as arguments of messages sent to Smalltalk objects.
WARNING: Agora message passing and Smalltalk message passing differ in a subtle but important way. Whereas Smalltalk keyword messages can contain duplicate keywords, Agora messages can not. For Agora program text this is checked before evaluation. This is also checked during evaluation when Smalltalk objects send messages to Agora objects. This limits the symbiosis between Agora and Smalltalk to messages that do not contain duplicate keywords.
WARNING: Smalltalk methods always return a result. For Agora this is not the case. Therefor all methods of an Agora object that are invoked from within Smalltalk must be functional methods.
Agora single slot nested objects (SSNO's) are compatible with Smalltalk blocks, as long as their pattern is compatible with the evaluation protocol of Smalltalk blocks. There is a catch however! The standard protocol for blocks contains methods with duplicate keywords. For example the message value:value:
to evaluate a block with two arguments. With the above warning in mind this would mean that Agora SSNO's can not be substituted for Smalltalk blocks. Due to the importance of blocks a solution is given by translating value:value:
... messages to Agora valueWithArguments:
messages. For example
value # ... valueWithArguments: anArray # ...denote SSNOs compatible with Smalltalk blocks.
[ x:x y:y mixin method: [ x functional method:x ; y functional method:y ; hash functional method:(x + y) hash ; = p functional method:(x = p x) & (y = p y) ; print method:[ x print ;y print ] ] ; d variable: Dictionary new ; d at:(self x:10 y:20) put:"Wim" ; d at:(self x:20 y:10) put:"Patrick" ; d at:(self x:17 y:40) put:"Koen" ; d keysAndValuesDo: (valueWithArguments:s # [ (s at:1) print; (s at:2) print; s return ]); d do: ( value:s # [ s print; s return ] ) ]
All Agora primitives also understand the message print, which produces a textual representation of the primitive object on the Smalltalk transcript window.
In this version of Agora the following attributes are visible:
true false
true and false are bound to the corresponding primitive objects.
array: size array: size of: initialValue
The array:
and array:of:
mixins extend the receiver object with slots accesible by means of the at:
and at:put:
messages.