Re: Euphoria implementation

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Mon, 18 Mar 2002 03:19:03 +0000, Shawn Pringle <pringle at techie.com>
wrote:

>I think it is a natural extension of this idea to have statements
>like this: "n = foo(n)" pass by reference.  As it makes
>no difference to the functionality of the program. Ofcourse things
>like "x = foo(n)" would be pass by value as it is now.  The benifit
>is that many programs would get faster for nothing.

I would suggest that all functions would then have to cope with both
pass by reference and pass by value under this scheme.
function foo(object o)
-- allocates a new local variable o
...
return k
-- deallocates o and any other local variables

So with this suggested optimisation, either do or don't create the
object o, all the code in the function now has to either reference o
(as in the x=foo(n) case) or n (as in the n=foo(n) case); then when we
get to the return, it either has to deallocate o and return k, or do
nothing.

There's quite alot of extra handling there which will totally outweigh
the minor optimisation you are thinking of.

If you *really* need the speedup, make n global, and duplicate the
code from foo(n) to a procedure foon() which modifies n directly.

Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu