1. Re: Discard, was:Re: hypocrite's reply a
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL>
Sep 21, 1998
-
Last edited Sep 22, 1998
>errrrrrrrrrrrrrrrrrr..................
>*feels around to make sure his dunce cap is on*
>i sowwy, ummmmmmm, i just-a don't get it...
>*ponder* urm... nope... still cannae figure
>out how this-a does what ralf was 'fer-in to...
Hmm, I was referring to the often use trash object.
An object receiving values not used in the programs.
The calculation of such a value *could* be skipped.
By using an Discard variable, the interpreter can determine, it is not legal
to use the value stored in the variable and therefor eliminate all
calculations, and skip many assignments.
Actually, the reason I wanted this was, because is certain languages, you
can neglect a function result, however in Euphoria you *must* use it. In
Theory this is a good thing. However, the actual calculation of the result
value *does* take place, even in those cases where the value is *not* going
to be used.
For clarity it is a good thing you can see you are neglecting a value.
However, this should 1) be safe: you shouldnt be allowed to use a value you
said you dont want nothing to do with 2) why perform the actual calculation
? Why not skip it for speed.
Many times do we make calls like this:
trash = my_func () -- called for side-effect
...
The name of the variable says it all, trash. We are not going to use the
returned value. However, Euphoria forces us to save it into *variable* so
you can always see you are neglecting something.
Even we wouldnt use the assignment syntax, we would get (c-like) ..
my_func () -- called for side effect, return value ignored
However, at that point, we can no longer distinguis procedures from
function, in other words, we can no longer see wether we are neglecting a
value or not.
So, I do prefer to assign it to *some* variable.
But it would be cleaner if I werent allowed to use that variable.
And this also speeds things up.
Hmm, I think I just explained the same thing 3 times.. oh well.
PS. Ad, I dont quite understand what you meant, could you explain your
example ?
Ralf