Re: Rob: Q: Euphoria 2.6 + PD source bug

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

Pete Lomax wrote:

> On Wed, 30 Mar 2005 08:25:57 +0200, Juergen Luethje wrote:
>
>> Vincent wrote:
>>
>> <big snip>
>>
>>> Dynamic variable routines
>>> like, variable_id(), read_var(), write_var() would be great too.
>>
>> What can we do with those routines, that we can't do without them?
>>
>> <big snip>
>
> For one thing, you could code
> }}}
<eucode>
> include lib.e
> ...
> object a,b
> 	...
> 	libproc(variable_id(a))
> 	libproc(variable_id(b))
> </eucode>
{{{

>
> instead of
> }}}
<eucode>
> global object a, b
> include liba.e as alib
> include libb.e as blib -- duplicate code slightly modified
> ...
> 	alib:libproc()
> 	blib:libproc()
> </eucode>
{{{

>
> Less code, less globals.
> You can, of course, achieve much the same by using a single global
> array and refer to elements in it using index constants:
>
> }}}
<eucode>
> global sequence a	-- possibly defined in lib.e
> include lib.e
> ...
> constant avar=1, bvar=2
> 	...
> 	libproc(avar)
> 	libproc(bvar)
> </eucode>
{{{

> But it is still an extra global. One thing you could potentially do is
> write a complex (multi-source-file) library component without exposing
> the internal data which currently has to be made global. In my print
> preview I resorted to clear shrouding the file, then editing that file
> by hand to remove the unwanted globals, every time I packaged.

Thanks for the info!
So as far as I understand, the bottom line is that variable_id() would
be useful, because Euphoria currently only allows to pass parameters to
routines by value. To achieve pass by reference, IMHO a special keyword
such as "byref" would be cleaner.
Your first example:
  
include lib.e
   ...
   object a,b
   ...
   libproc(variable_id(a))
   libproc(variable_id(b))
   


then would read:
  
include lib.e
   ...
   object a,b
   ...
   libproc(byref a)
   libproc(byref b)
   


This is IMHO better readable, and is simpler because read_var() and
write_var() are not required.

Regards,
   Juergen

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

Search



Quick Links

User menu

Not signed in.

Misc Menu