1. Re: we need official libs : Swap
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Jul 19, 1999
- 438 views
> Unfortunately this requires that this function changes the contents of the variables, which > does not fit properly into the language. Perhaps an operator is needed. We don't need swap. What we need is the ability is sequence 'unbinding' .. Many times, people have asked for things such as: { status, value } = get (0) Why does this seem logical ? Because we, humans most of us, can 'unbind' things and make the only logical conclusion about the values being assigned to the variables. I think the above should work, as well as: { a, b } = { b, a } (swapping) As well as: a + 1 = 3 -- sets a to 2 Surely, situations like this can be confusing: (the only problematic situations I can come up with are the use of '=') ( a = b ) = ( b = c ) How would this be currently handled ? Not. It would crash, can not assign to an expression, or whatever type of error. If implemented as I suggested, it would, eventhough a little confusing, would assign to a whatever value is needed to make the above true. The parenthes (sp ?) force the second '=' to be the assignment operator, which forces the truth by setting the variable on the left. The left is an evalution expression, and the first variable is set. Well, if this is the most complex situation possible, a situation already complex anyway, it seems like a very feasable, readable and powerfull addition to the Euphoria language. Comments, any one ? Robert, how do you feel about this ? Ralf N. nieuwen at xs4all.nlt http://www.xs4all.nl/~nieuwen