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

World: r3wp

[Core] Discuss core issues

Gregg
8-Jul-2011
[1680]
My original goal was not binary diffs, but diffing blocks.
Henrik
9-Jul-2011
[1681]
you are right. I looked into it and it looks to be way too slow, 
so I'm trying another approach.
Geomol
11-Jul-2011
[1682x3]
>> negate 2 + - 2
== 0
>> - 2 + - 2
== -4

Bug?
Isn't unary minus introducing a third semantic rule? Functions are 
prefix, operators are infix with precedence over functions. And then 
unary minus is prefix with precedence similar to operators?
w> - (2 + (- 2))
== 0
w> (- 2) + (- 2)
== -4

Question is, how would we read
- 2 + - 2
Endo
11-Jul-2011
[1685]
It does correctly I think, here is the trace log:
>> - 2 + - 2
Trace:  - (word)
Trace:  2 (integer)
Infix:  op (add)
Trace:  - (word)
Trace:  2 (integer)
Geomol
11-Jul-2011
[1686]
I'm asking, if unary minus should work as if being defined like this:

>> set '- :negate
Maxim
11-Jul-2011
[1687]
no,  AFAICT the unary minus is applied exactly like all operator 
precedence (from left to right).


negate and  "-"  do not have the same precedence, as you noted, so 
its normal for:
    >> negate 2 + - 2    
and
    >> - 2 + - 2
to give different results.
Geomol
11-Jul-2011
[1688]
Ok, intensional then. I'm surprised.
Steeve
11-Jul-2011
[1689]
You shouldn't old pal :-)
Geomol
11-Jul-2011
[1690x2]
Is unary minus the only prefix thing, that has same precedence as 
operators?
:) Sometimes I feel, I have no clue about this language. ;)
Steeve
11-Jul-2011
[1692]
actually, unary minus has an higher precedence than other ops
Geomol
11-Jul-2011
[1693x2]
Functions with literal arguments works about the same.

>> f: func ['a] [probe a]
>> f 2 + 2
2
== 4

So f gets the value 2 in this example.
Complicated rules! ;)
Steeve
11-Jul-2011
[1695]
because functions with literals stop the evaluation flow
Geomol
11-Jul-2011
[1696x2]
yeah
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?