r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Geomol
11-Jul-2011
[1697]
Tonight's Moment of REBOL Zen:

>> switch/default 'a [a 1] 2 
== 2
Andreas
11-Jul-2011
[1698]
What's the insight here?
Geomol
11-Jul-2011
[1699]
>> switch/default 'a [a [1]] 2
== 1
Steeve
11-Jul-2011
[1700]
so what ?
Geomol
11-Jul-2011
[1701]
Isn't it strange, that if the value being searched for (in this case 
a) is found, and the next item in the block isn't a block, then it 
fails to defaul?
Andreas
11-Jul-2011
[1702]
No.
Geomol
11-Jul-2011
[1703x2]
*default*
ok :)
Andreas
11-Jul-2011
[1705x2]
From the docstring for SWITCH: "Selects a choice and evaluates the 
block that follows it."
>> switch 'a [a b [1]]
== 1
>> switch 'b [a b [1]]
== 1
Steeve
11-Jul-2011
[1707]
must be a block, nothing else
Geomol
11-Jul-2011
[1708]
Oh, the docs are different at
http://www.rebol.com/docs/words/wswitch.html
It sais "Selects a choice and evaluates what follows it."

Must be a block
 ... hm why?
Steeve
11-Jul-2011
[1709]
because it says so
Geomol
11-Jul-2011
[1710]
Ok, got it from Andreas' example. Multiple values. :)
Andreas
11-Jul-2011
[1711x2]
C-style fallthrough.
(I think that was the intention behind that particular behaviour.)
Geomol
11-Jul-2011
[1713]
yup, cute! :)
Steeve
11-Jul-2011
[1714x2]
the syntax of switch evolved
it was different back...
Geomol
11-Jul-2011
[1716]
Damn, now I have to change my own switch. ;)
Andreas
11-Jul-2011
[1717x2]
Yes, I think back in 2.5 (or earlier), switch 'a [a 1] actually returned 
1.
Ah, that was still the case in 2.6, even.
Geomol
11-Jul-2011
[1719]
I'm behind schedule, since I haven't noticed this.
Andreas
11-Jul-2011
[1720]
2.7.2 it was:
http://www.rebol.net/upnews/0008.html
Maxim
11-Jul-2011
[1721]
the change to switch was a good thing... wasn't it also mezz code 
a wee back?  IIRC this happened at the same time... and it made A 
LOT of code much faster.
Ladislav
11-Jul-2011
[1722]
>> - 2 + - 2
** Script error: - operator is missing an argument
Maxim
11-Jul-2011
[1723]
is that in R3?
Ladislav
11-Jul-2011
[1724]
in R3, the - operator is not unary
Maxim
11-Jul-2011
[1725]
or should we say, there is no unary version of the - operator?
Ladislav
11-Jul-2011
[1726]
That is false, actually
Maxim
11-Jul-2011
[1727]
what is false?
Ladislav
11-Jul-2011
[1728]
what you wrote
Maxim
11-Jul-2011
[1729]
in R2   -  can be either, no?
Ladislav
11-Jul-2011
[1730]
in R2, the - operator is both unary and binary, and its arity is 
determined during interpretation
Maxim
11-Jul-2011
[1731]
so what is the diferrence in R3?
Ladislav
11-Jul-2011
[1732]
in R3, the - operator is not unary
Maxim
11-Jul-2011
[1733]
well, that means there is only the binary version of the - operator.
Ladislav
11-Jul-2011
[1734]
that is false, as I see it
Maxim
11-Jul-2011
[1735x2]
tell me how :


there is no unary version of the - operator  !=   the - operator 
is not unary
(I'm trying to understand what you mean... really)
Ladislav
11-Jul-2011
[1737]
1) There are not unary version and binary version of the - operator 
in R2, there is just one - operator in R2, which is both binary and 
unary depending on the "situation"

2) The statement "there is no unary version of the - operator" may 
be true only if you state, that NEGATE is not a unary version of 
the - operator
Maxim
11-Jul-2011
[1738]
ok, well, to me the negate function is not an operator, but I understand 
what you mean.
Ladislav
11-Jul-2011
[1739]
I wrote: "...which is both binary and unary...", I could have written 
"...which is neither binary nor unary, since it does not have fixed 
arity, its arity being dependent on the situation..."
Geomol
12-Jul-2011
[1740x2]
Would people miss unary minus in R3?
Ladislav, do you mean "fixed parity"?


And yes, there seem to be just one minus '-' in R2. If you redefine 
- with something like:
	set '- ...
, then you don't have unary minus any longer.
Ladislav
12-Jul-2011
[1742x2]
'Ladislav, do you mean "fixed parity"?' - no, I did mean "arity", 
not "parity"
And, in R2, the - operator is, in fact, variadic, having neither 
arity 1, nor 2
Geomol
12-Jul-2011
[1744]
I learned some new words, thanks! :)
BrianH
12-Jul-2011
[1745x2]
Would people miss unary minus in R3?

 - Initial testers reported its lack as a bug. The bug was dismissed, 
 since this was an intentional change. The benefits of the reduced 
 ambiguity won them over once they got used to it.
variadic
 - nice, I love precise words :)