the magic behind "do it"
Brent Vukmer
bvukmer at blackboard.com
Thu Dec 27 16:06:12 UTC 2001
Bert and Bob --
Thanks for being so helpful, even though this is a classic case of RTFM. I gotta say, I love the Squeak list.
-----Original Message-----
From: Bert Freudenberg [mailto:bert at isg.cs.uni-magdeburg.de]
Sent: Thursday, December 27, 2001 10:48 AM
To: Brent Vukmer
Cc: squeak-dev at lists.squeakfoundation.org
Subject: Re: the magic behind "do it"
On Thu, 27 Dec 2001, Brent Vukmer wrote:
> Selecting "2 halt" and inspecting brought me to the method
> Compiler#evalute:in:to:notifying:ifFail. I wrote a script to access
> this method directly ( see below ). I am getting nil instead of 3.
> When I debugged, it looks like the Parser is generating the following
> MethodNode: DoIt
> ^ nil
>
> What do I need to do to get Compiler-love?
>
>
> | exprStream result failBlock |
>
> exprStream _ ReadWriteStream on: ''.
> exprStream nextPutAll: '1 + 2'.
> failBlock _ [ Transcript show: 'ArithmeticExpression#eval FAILED: ', exprStream contents. ].
> result _ Compiler new evaluate: exprStream in: nil to: nil notifying: nil ifFail: failBlock.
> ^ result
You need to reset the stream's position after writing to it:
exprStream nextPutAll: '1 + 2'.
exprStream reset. "<--- insert"
failBlock ...
Btw, on the class side of Compiler there are some handy methods to make
live easier, try:
Compiler evaluate: '3 + 4'
-- Bert
More information about the Squeak-dev
mailing list
|