[NEWBIE]using the compiler for active squeak pages

Bert Freudenberg bert at isgnw.CS.Uni-Magdeburg.De
Tue Oct 19 07:58:25 UTC 1999


On Tue, 19 Oct 1999, Vandendriessche, Frederik wrote:

>   blockStreamToExecute _ '[:aReq1 :anObj1 | 'hardcoded.....interfacecode',
> self code, 'hardcoded.....interfacecode]'
>   ^ (Compiler evaluate: blockStream contents)
> and return a string (html or xml or js or...)
> 
> I know I need to send value: with: to the block, but I don't know how or
> where.

You have to send #value:value:, as usual: 

	code _ 'a + b'.
	blockString _ '[:a :b | ', code, ']'.
	block _ Compiler evaluate: blockString.
	^block value: 3 value: 4

answers 7, as expected. The compilers #evaluate: just returns a block that
can be used like every block. Or, for your stream example:

	code _ 'stream print: 42. stream cr.'.
	blockString _ '[:stream | stream nextPutAll: ''begin''; cr.', 
		code, '. stream nextPutAll: ''end''; cr]'.
	block _ Compiler evaluate: blockString.
	^String streamContents: block

HTH

  /bert





More information about the Squeak-dev mailing list