1. Re: we need official libs : Swap

Hello,

Boehme, Gabriel wrote:

<lots of good stuff and this>

>1) The receiving structure may *not* contain duplicate variables.
>
>    a) Duplicate variable names would be caught *before* execution.
>
>       Example:
>          {a,b} = {1,2} -- legal
>          {a,a} = {1,2} -- error!
>
>    b) Duplicate variable subscripts would be caught at run time.
>       (This would probably be the most difficult condition to verify.)
>
>       Examples:
>          {a[7],    a[9]} = {1,2}           -- legal
>          {a[7],    a[7]} = {1,2}           -- error!
>          {a[7][2], a[7]} = {1,2}           -- NASTY error!
>          {a[x],    a[y]} = {1,2}           -- legal only if x != y
>          {a[x][z], a[y]} = {1,2}           -- legal only if x != y
>          {a[7],    a[9]} = {a[9], a[7]}    -- legal, swaps the variables
>          {a[x],    a[y]} = {a[y], a[x]}    -- legal only if x != y
>                                            -- (if they're equal, then
>                                            -- it's redundant anyway...)
>          {a[x][z], a[y]} = {a[y], a[x][z]} -- legal, swaps the variables
>                                            -- but *only* if x != y
>                                            -- (my, we're *really* opening
>                                            -- a can of worms here...)
>
>2) If the expression returns a sequence value, then its structure must
>    match the specified receiving structure *exactly*.
>
>    Examples:
>       {a,b}     = {1,2}       -- legal
>       {a,b}     = {1,2,3}     -- error!
>       {a,{b,c}} = {1,{2,3}}   -- legal
>       {a,{b,c}} = {1,{2,3,4}} -- error!
>       {a,b}     = {b,a}       -- legal, swaps the variables
>       {a,b}     = {b,b}       -- legal, but a bit redundant
>       {b,b}     = {a,b}       -- error! (see #1 above)
>
>3) If the expression returns an atom value, this value will be applied to
>    *all* receiving variables. (NOTE: I'm not 100% sure about this idea,
>but
>    it *does* fit with the s[i..j] = 0 method of slice assignment...)
>
>    Examples:
>       {a,b}     = 2 -- legal
>       {a,{b,c}} = 2 -- legal, but unnecessarily complicated
>       {a,b,c}   = 2 -- legal, identical to the above
>
>4) Every received value *must* be assigned to its own variable, i.e.
>    no "placeholder" symbols, no repeated "junk" values (see #1 above).
>
>    Example:
>       {_,     keep, _}     = {1,2,3} -- error! "_" is not a variable
>       {junk,  keep, junk}  = {1,2,3} -- error! "junk" is repeated
>       {junk1, keep, junk2} = {1,2,3} -- legal, though not elegant
>

      <SNIP>

>Nevertheless, it does appear to me that this idea *can* be made into a
>reasonably clear and self-consistent part of Euphoria; and, certainly, this
>is the kind of thinking which *must* be done if we want to make this an
>integrated part of the language.

Thank you Gabriel for doing us the favor of extensively
defining the rules that could govern this sort of addition
to Euphoria. I like these rules and hope that this addition
will be made. I want to mention that I still think that the
{a, b} = <EXPRESSION> idea is Euphoric, consistent, and
clear. I'm dying to know if Robert will considder adding
this to a future release.

TIA,
Lewis Townsend


_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu