Re: Pass by address
- Posted by Matthew Lewis <MatthewL at KAPCOUSA.COM> Aug 16, 2000
- 480 views
> > On passing vars by address: > > #1 > > I'm glad someone mentioned this. I've been giving this some thought > recently and i see the problem with passing vars in Eu by > address is that > it then requires complete knowledge of the structure of the data being > passed. Although, if, instead of 'by address', we say, 'by reference', there might be a way around this. The interpreter could copy the pointer to the passed variable, but rather than copying it when it's changed, simply make the changes. That way, the 'address' would still be hidden from the user, but would have the important functionality of 'passing by address'. Granted, I don't know how this would affect performance, etc., but since Eu already does copy pointers to variables, and seems to be able to keep track of them, it might actually speed some things up, since you avoid having to copy the stucture/data to somewhere else. It might make some parts of the C translation a bit easier/faster, too. To argue against it, I think this makes the code less readable in some cases(it's not as clear, to ME at least, when you're returning values this way vs. using functions), but would probably simplify things in the other. <snip> > #2 > > Currently Eu's routine_id() seems to be limited to passing within > the same program, so I'd also like to see routine_id() return > an address > instead of an id. This change would be backward compatible > with the current > routine_id() as well as to allow passing of routines to other > programs! Of > course this would make Euphoria plug-ins a reality also. > This part is already done. Use call_back(), which takes a routine_id as it's argument, and returns the address an external process should call--the equivalent of a pointer to a function in C. That's how Eu is able to function in Windows. Matt Lewis