Agora94 User Guide

Koen De Hondt
Last revision: August 7th, 1996

Agora94 User Guide - Symbiosis with Smalltalk

This chapter describes the symbiosis of Agora and Smalltalk.

Smalltalk objects in Agora programs and vice versa

All Smalltalk globals are visible in Agora programs. Since Smalltalk class names are Smalltalk globals, they can be used just as if they were Agora objects.

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:
			# [	(s at:1) print;
				   (s at:2) print; s return ]);
	  d do:
		( value:s # [ s print; s return ] )

Primitive objects

Agora primitive objects, like integers, reals, characters, strings and booleans, are implemented by their Smalltalk alter egos. All messages understood by the Smalltalk primitive objects can thus be sent to the Agora primitive objects.

All Agora primitives also understand the message print, which produces a textual representation of the primitive object on the Smalltalk transcript window.

Predefined mixins, methods and variables

Predefined mixins, methods and variables are attributes declared in the root object. Since an Agora program is an extension of the root object, these attributes are visible in each Agora program.

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.