Discussion:
eval stmt
(too old to reply)
s***@engmail.uwaterloo.ca
2004-07-13 16:00:03 UTC
Permalink
In the SL spec, for eval it says:

“Sometimes it is useful to evaluate an expression but do nothing with its
result. In particular, some procedures are executed solely for their side
effects, not for their return value. This can be done with the eval statement,
which consists of the keyword eval followed by an expression. Execution of an
evaluation statement consists of evaluating the expression.”

It seems like we don’t need to generate any action code for this, as it does
not alter the value of any variable, neither is the result used (eg, not even
printed to console).

Could we get some clarification on what eval is to do, and please correct me
if I’m wrong in my thinking of what evalstmt does.

Thanx,

SJ




----------------------------------------
This mail sent through www.mywaterloo.ca
Stephen Tse
2004-07-14 01:57:32 UTC
Permalink
I implented result by actually calculating the result but not doing
anything. So this means doing type checking on any variables that are
being passed and calculating the result of any procedures in the eval
statement.

Theoretically, if the eval statement evalutates correctly, then it does
nothing. But if the user tries to evaluate an illegal expression, I threw
out a Compile Exception.

Stephen Tse
=20
=93Sometimes it is useful to evaluate an expression but do nothing with i=
ts=20
result. In particular, some procedures are executed solely for their side=
=20
effects, not for their return value. This can be done with the eval state=
ment,=20
which consists of the keyword eval followed by an expression. Execution o=
f an=20
evaluation statement consists of evaluating the expression.=94
=20
It seems like we don=92t need to generate any action code for this, as it=
does=20
not alter the value of any variable, neither is the result used (eg, not =
even=20
printed to console).
=20
Could we get some clarification on what eval is to do, and please correct=
me=20
if I=92m wrong in my thinking of what evalstmt does.
=20
Thanx,
=20
SJ
=20
=20
=20
=20
----------------------------------------
This mail sent through www.mywaterloo.ca
=20
=20
Troy Mark Gonsalves
2004-07-20 17:40:17 UTC
Permalink
In general something could happen, namely 'side-effects'.
Side-effects are the effects that procedures have, excluding their return
value. For example, if a procedure changes a global variable, or alters
one of it's arguments. Strictly speaking, neither of these can happen
unless you implement Arrays, which are passed by reference...hence I could
use an eval statement to call a procedure that sets all of the arrays
elements to 0...this would require you to generate code.

To be safe, I'd generate code for eval, even if I didn't implement arrays.

Troy
=93Sometimes it is useful to evaluate an expression but do nothing with i=
ts
result. In particular, some procedures are executed solely for their side
effects, not for their return value. This can be done with the eval state=
ment,
which consists of the keyword eval followed by an expression. Execution o=
f an
evaluation statement consists of evaluating the expression.=94
It seems like we don=92t need to generate any action code for this, as it=
does
not alter the value of any variable, neither is the result used (eg, not =
even
printed to console).
Could we get some clarification on what eval is to do, and please correct=
me
if I=92m wrong in my thinking of what evalstmt does.
Thanx,
SJ
----------------------------------------
This mail sent through www.mywaterloo.ca
Loading...