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

World: r3wp

[Core] Discuss core issues

BrianH
15-May-2011
[1509]
There is a similar special case for when you pass a get-word value 
to a lit-word parameter, bot in R2 and R3. R2's APPLY function has 
code to undo these special cases, and R3's APPLY doesn't do the special 
evaluation; APPLY is used to break the evaluation rules, often for 
safety.
GrahamC
15-May-2011
[1510]
Didn't know about Chris' date formatting
BrianH
15-May-2011
[1511]
Great work on that date formatting! I prefer compiled dialects over 
interpreted ones for volume work, but it's definitely the right idea 
:)
Geomol
17-May-2011
[1512]
Tonight's Moment of REBOL Zen:


How should R2 functions be categorized? They're not really functions 
with vars only temporarely on a stack:

>> c: func [a b] [[a + b]]
>> do c 1 2
== 3

but also not really closures with individual contexts:

>> f: func [a] ['a]       
>> word1: f 1
== a
>> word2: f 2
== a
>> get word1
== 2
onetom
24-May-2011
[1513]
aaaw... ask/hide doesn't work if i start rebol with the -w option, 
which i might accept, IF there would be a way to start it without 
a clear screen... it doesn't integrate nicely with unix this way...
Geomol
24-May-2011
[1514x2]
Yes, we had a discussion about this in the Core group recently. See 
posts around 13-May.
Sorry, my last post here was an answer to something in the !REBOL3 
group.
Geomol
26-May-2011
[1516]
FIRST, SECOND and THIRD can be used on functions like:

>> first :repend
== [series value /only]


SECOND and THIRD returns the function body and spec. FIRST returns 
a stripped spec, just the arguments and refinements. I notice, it's 
produced each time contrary to the other two:

>> same? second :repend second :repend
== true
>> same? third :repend third :repend  
== true
>> same? first :repend first :repend
== false


What is FIRST on a function used for? It may be used internally, 
but does anybody use it externally? It seems more logical, if FIRST 
on a function returned the spec, SECOND the body, and nothing else.
Ladislav
26-May-2011
[1517]
This is not a useful subject to discuss, due to the changes in R3
Geomol
26-May-2011
[1518]
I see, they're all produced each time in R3:

>> same? reflect :repend 'spec reflect :repend 'spec
== false

Guess the R3 implementation is better in this case.
Gabriele
26-May-2011
[1519]
Geomol, that's very useful if you want to count the number of arguments 
of a function etc. - think of it as a pre-parsed function spec.
Geomol
26-May-2011
[1520]
Yes, I see the benefit. I was just wondering, if it was actually 
used. I guess, you used it somewhere? :)

If used, would it be more logical to have FIRST return the spec, 
and THIRD return, what FIRST return today? Or am I missing some vital 
point?
onetom
26-May-2011
[1521]
its a remove-each e spec-of fn [find type? e [string! block!]]
Geomol
26-May-2011
[1522]
Looking at SPEC-OF, and another question pop up. Why isn't copy/deep 
the default for COPY? Wouldn't the world be much easier, if it was?
Micha
26-May-2011
[1523x3]
I need some help
My server has multiple ip.
it is possible to select the ip address ?
I want to download the page, and to do it from different ip
p: open tcp://

i: get-modes p  'interfaces
 probe i

 probe i
[make object! [
        name: "if16"
        addr: 91.121.*.*
        netmask: 255.255.255.0
        broadcast: 91.121.*.*
        dest-addr: none
        flags: [broadcast multicast]
    ] make object! [
        name: "lo0"
        addr: 127.0.0.1
        netmask: 255.0.0.0
        broadcast: none
        dest-addr: none
        flags: [multicast loopback]
    ] make object! [
        name: "if16"
        addr: 188.165.*.*
        netmask: 255.255.255.255
        broadcast: 188.165.*.*
        dest-addr: none
        flags: [broadcast multicast]
    ]]
onetom
26-May-2011
[1526]
wow, i didn't know u can do that! where is it documented? i just 
remeber get-modes in relation to setting binary mode for the console 
or parity and speed setting for the serial port...
Micha
26-May-2011
[1527]
you can not just choose adress  ip .   I ask if there was any way 
.
Dockimbel
26-May-2011
[1528]
AFAIK, there is no way to do that using REBOL ports.
Micha
26-May-2011
[1529]
thanks
Maxim
26-May-2011
[1530x2]
Geomol, using copy/deep by default would be extremely bad for speed 
and memory.   in most of the processing, you don't need to copy the 
deep content of a block, but the wrapper block itself, so you change 
the order or filter it.  


IIRC using copy/deep also causes cyclical references to break-up 
so using it by default would be disastrous.  


just look at how often we really need to use copy/deep compared to 
not and you'll see that the current behaviour is much more useful.
I wish compose/deep didn't copy/deep the whole block when it did 
its composing.  


I don't know how it is in R3, but in R2, to simply replace one value 
in tree, you have to copy the whole tree, which isn't very useful.
BrianH
26-May-2011
[1532]
You can do more exact selections of what you want to copy in R3 using 
COPY/types.
Maxim
26-May-2011
[1533]
yep, in R3, the make/copy system was greatly improved.
Geomol
26-May-2011
[1534]
I imagined a can of worms. Guess I have to read and think it all 
through at some time.
Geomol
28-May-2011
[1535]
Today's Moment of REBOL Zen:

>> mod -8 3
== 1
>> modulo -8 3
== 1
>> remainder -8 3
== -2


The correct answer is 1. Check at http://www.wolframalpha.comtyping: 
-8 mod 3

>> mod -8 -3
== -5
>> modulo -8 -3
== 1
>> remainder -8 -3
== -2


The correct answer is -2. Check at http://www.wolframalpha.comtyping: 
-8 mod -3
BrianH
28-May-2011
[1536x2]
The modulus operation from math is not defined for negative numbers 
at all. Most programming languages with a modulus operation have 
extended it to cover negative numbers, but there is no agreed definition 
for it. This is why *all* programming languages and math processors 
that have modulus of negative numbers defined, are using an arbitrary 
platform-dependent definition for it, *even Wolfram Alpha*.
The "correct answer" is NaN or to trigger an error, but since that 
is not useful, to pick a definition that is useful.
Henrik
28-May-2011
[1538x3]
>> lesser? 'a 6
== false
>> lesser? 6 'a
** Script Error: Expected one of: integer! - not: word!
** Near: lesser? 6 'a
how does SORT do it without errors?
(the lesser? is from a sort/compare)
Ladislav
28-May-2011
[1541]
The correct answer is -2.
 - that is false, you need to read the help string
Geomol
28-May-2011
[1542]
From HELP MOD: "Compute a nonnegative remainder of A divided by B."
MOD can produce negative results as seen above.

From HELP MODULO: "Wrapper for MOD that handles errors like REMAINDER."

So REMAINDER must give wrong result in some cases. What does REMAINDER 
say:

From HELP REMAINDER: "Returns the remainder of first value divided 
by second."

That's what I expect a modulo operation to do. A modern definition 
is given by Knuth in "The Art of Computer Programming" using floored 
division, and this seems to be also the definition, Wolfram Alpha 
use. So I would say, REMAINDER give the correct answer in the second 
case, but not in the first.


As I see it, REBOL have 3 modulo functions, and none of them operate 
as expected, if Knuth's definition is used.
onetom
28-May-2011
[1543]
would be nice if such discussion could be looked up when someone 
is curious why something has been implemented in a certain way... 
the rebol3 blog is a kind of raw material for such a "background 
documentation"...
Ladislav
28-May-2011
[1544x2]
none uses Knuths definition
BTW, this was discussed and implemented in ALtMe some time ago
Geomol
29-May-2011
[1546]
none uses Knuths definition
 Ladislav, please!


Check mod in these languages: Clojure, Common Lisp, Filemaker, Fortran 
(modulo), Lua, Mathematica, MATLAB, R, Ruby (remainder), Scheme (modulo), 
Smalltalk (\\), VHDL


and maybe a few more. They all give the same result as from Knuth 
definition.
Ladislav
29-May-2011
[1547x3]
none uses Knuths definition

 - you should try to comprehend. None of the functions you mentioned 
 uses the Knuths definition.
In case you again try to misunderstand, then it is "none of the Rebol 
functions you mention"
And, moreover, you can easily redefine the MOD and MODULO, since 
they are mezzanines
onetom
29-May-2011
[1550x2]
Ladislav: I misunderstood it too as "no fucking body is using knuths 
definition"
s/is using/uses/
Ladislav
29-May-2011
[1552]
come on. If a function does not use a definition, then you cannot 
claim the function has a bug when differing from the definition in 
question.
Geomol
29-May-2011
[1553]
Oh, sorry. None of the REBOL functions use Knuth's definition. Got 
it. :)
Ladislav
29-May-2011
[1554x3]
Due to specifics in REBOL arithmetic it was deemed desirable to remain 
compatible with some of them when defining more arithmetic functions
In essence, the MOD function is a "helper" for ROUND. It uses the 
Boute's definition, but assuming that the divisor is positive. If 
you do want to use a more comfortable variant, you can use the MODULO 
function, which does not make such an assumption.
Still, there are arithmetic specifics, regarding rounding.
PeterWood
30-May-2011
[1557]
A bug?

>> cur: what-dir

== %/Users/peter/

>> cd %Code/Rebol

== %/Users/peter/Code/Rebol/
>> cd cur

** Access Error: Cannot open /Users/peter/Code/Rebol/cur/

** Near: change-dir to-file path

>> change-dir cur

== %/Users/peter/
Though this works:

>> cd :cur
== %/Users/peter/
Geomol
30-May-2011
[1558]
>> ? cd 
USAGE:
    CD 'dir


Notice the non-evaluated Literal Argument. So when you use CD, the 
argument isn't looked up.

>> ? change-dir
USAGE:
    CHANGE-DIR dir


With CHANGE-DIR, it is looked up. It is expected behaviour, but maybe 
confusing, that CD and CHANGE-DIR are different.