1. RE: Changing Euphoria
- Posted by kbochert at ix.netcom.com Feb 04, 2002
- 410 views
-------Phoenix-Boundary-07081998- Hi Shawn Pringle, you wrote on 1/31/02 9:37:11 AM: >Ofcourse pass by reference is relatively cheap in EUPHORIA, being copy >on write pointers. It would seem to me that code like: >list = append(list,a) should be optimized to something like: >append(!!list,a) keeping with your notation. As, the object passed in >will be reassigned there is no need to copy a new list in append. > >Apparently EUPHORIA already does this, at least for append. The >documentation says "highly optimized." > Built-in functions like append follow their own rules. If the user writes a function that modifies one of it's sequence parameters, the sequence is copied before modification. If the user wants the modification AND a return value, one or the other must be not passed to the function or they must be combined into a sequence (more copying!). A third reason to add PBR (and slicing shorthands) to Euphoria is to reduce redundancy: I have read (and written) too many code lines like: MOD1_base_elements = doit (MOD1_base_elements[2..MOD1_base_elements]) Much better without the redundancy: doit (!!MOD1_base_elements[2..]) >As for object orientation, as you said, something like: > stack.push( 9 ) >would have to be stack = stack.push( 9 ), unless ofcourse we have >stack=.push(9) for pass by reference like the other = ops. > >It may be pass by reference but we still only change things on the left >side of the "=". > Generally, the method dispatch 'stack.push(9)' gets handled as 'push(stack, 9)' i.e. the instance to operate on is passed as a a hidden parameter. Remember 'stack' here is an instance (maybe of class STACK?) NOT a class!'. In Euphoria this is: 1) stack=push(stack,9) -- push() can't return a value or: 2) push(stack,9) -- stack must at file scope, or unchanged We could make the rule that class methods can either return a value OR modify the instance but I would rather make it more general, especially when PBR brings other advantages. -------Phoenix-Boundary-07081998---
2. RE: Changing Euphoria
- Posted by kbochert at ix.netcom.com Jan 30, 2002
- 406 views
-------Phoenix-Boundary-07081998- Hi Shawn Pringle, you wrote on 1/29/02 1:30:25 PM: > >When it comes to changing something that is so simple and clean I >cringe. Euphoria was been around a long time with out many changes had >bugs which must have been many years old. When languages change >programs break and implementations break. The new bugs might show up in >the interpreter or the 'compiler'. Many proposed changes are features >of C that people want in EUPHORIA because they are used to C. >Things that need features in C are not needed in EUPHORIA: > >For Example: >Pass by reference: > >scanf would be something like >procedure sscanf( sequence str, sequence fmt, sequence& inputs ) > >On the other hand, in today's EUPHORIA the same thing can be implemented >with >function sscanf( sequence str, sequence fmt ) -- return user input > > >Regards, >Shawn Pringle > As I see it, there are 2 advantages to pass-by-reference: 1) More efficient. foo = modify(foo) -- involves a couple of copy operations modify (!!foo) -- modifies in place (my pass-by-reference syntax) 2) Object orientation Methods are automatically passed the instance they are to work on ('this') as the first parameter. Methods which modify the instance and also return a value are extremely awkward without 'this' beng passed by reference. It adds complexity and power, but it does indeed compromise the simplicity that makes Euphoria so attractive. Karl Bochert -------Phoenix-Boundary-07081998---
3. RE: Changing Euphoria
- Posted by Shawn Pringle <pringle at techie.com> Jan 31, 2002
- 420 views
Ofcourse pass by reference is relatively cheap in EUPHORIA, being copy on write pointers. It would seem to me that code like: list = append(list,a) should be optimized to something like: append(!!list,a) keeping with your notation. As, the object passed in will be reassigned there is no need to copy a new list in append. Apparently EUPHORIA already does this, at least for append. The documentation says "highly optimized." As for object orientation, as you said, something like: stack.push( 9 ) would have to be stack = stack.push( 9 ), unless ofcourse we have stack=.push(9) for pass by reference like the other = ops. It may be pass by reference but we still only change things on the left side of the "=". It sounds like we are designing a EUPHORIA++ here. Cheers! Shawn kbochert at ix.netcom.com wrote: > -------Phoenix-Boundary-07081998- > Content-type: text/plain; charset=ISO-8859-1 > Content-transfer-encoding: 8bit > > Hi Shawn Pringle, you wrote on 1/29/02 1:30:25 PM: > > > > >When it comes to changing something that is so simple and clean I > >cringe. Euphoria was been around a long time with out many changes had > >bugs which must have been many years old. When languages change > >programs break and implementations break. The new bugs might show up in > >the interpreter or the 'compiler'. Many proposed changes are features > >of C that people want in EUPHORIA because they are used to C. > >Things that need features in C are not needed in EUPHORIA: > > > >For Example: > >Pass by reference: > > > >scanf would be something like > >procedure sscanf( sequence str, sequence fmt, sequence& inputs ) > > > >On the other hand, in today's EUPHORIA the same thing can be implemented > >with > >function sscanf( sequence str, sequence fmt ) -- return user input > > > > > >Regards, > >Shawn Pringle > > > As I see it, there are 2 advantages to pass-by-reference: > > 1) More efficient. > foo = modify(foo) -- involves a couple of copy operations > modify (!!foo) -- modifies in place (my pass-by-reference syntax) > > 2) Object orientation > Methods are automatically passed the instance they are > to work on ('this') as the first parameter. Methods which > modify the instance and also return a value are extremely > awkward without 'this' beng passed by reference. > > It adds complexity and power, but it does indeed compromise the > simplicity that makes Euphoria so attractive. > > Karl Bochert > > > -------Phoenix-Boundary-07081998--- > Regards, Shawn Pringle