Replies: 4 comments 1 reply
-
|
why avoid the RETURN? If you don't like the anonymous return you can use a named block instead of the implicit one. (CL:BLOCK DATA-RETURN (for DIR DATA in ... do (RETURN-FROM DATA-RETURN (OPERATE-ON DATA)))) |
Beta Was this translation helpful? Give feedback.
-
|
$$VAL is a documented way of getting at that -- e.g., in the IRM for the LARGEST/SMALLEST i.s.operator --
"Returns the value of the i.v. that provides the smallest value of FORM. $$EXTREME is always bound to the current greatest/smallest value, $$VAL to the value of the i.v. from which it came."
and in 9.8.5 Miscellaneous Hints on I.S.Oprs --
… While the exact form of the translation of an iterative statement depends on which operators are present, a PROG will always be used whenever the i.s. specifies dummy variables, i.e., if a BIND operator appears, or there is more than one variable specified by a FOR operator, or a GO, RETURN, or a reference to the variable $$VAL appears in any of the operands.
-- Nick
|
Beta Was this translation helpful? Give feedback.
-
|
9.8.5 also notes that
And it also uses an example with |
Beta Was this translation helpful? Give feedback.
-
|
I'm OK with my original formulation and will keep it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
@rmkaplan and co.
I've got a few situations in which I'm looping over the elements of a list and want to call a predicate on each element. If true, I want to exit the loop with a value obtained by calling another function on the i.s.var.
Here's what I came up with. I'd like to avoid the explicit call to RETURN:
thereisis almost what I want, but it makes the expression return the value of the i.s.var (DIR). I'd rather not access CLISP internal vars like$$VALand friends in my code.Is there a more concise or idiomatic way to do this?
Beta Was this translation helpful? Give feedback.
All reactions