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

World: r3wp

[Core] Discuss core issues

Geomol
22-Aug-2009
[14549]
Anyone got an old REBOL 1 lying around, I could have a look at?
Anton
22-Aug-2009
[14550]
I noticed a get-word parameter prevents a paren argument value being 
evaluated first.
>> f: func [a][print mold a]
>> f (action?)
false
>> f: func [:a][print mold a]
>> f (action?)
(action?)
Geomol
22-Aug-2009
[14551x5]
Yeah, and you would probably like it to be mold :a in the function 
to not do the same mistake, I did. In your first example, you have 
evaluation of a two times, first as (action?) leading to false, and 
then false is evaluated when doing mold a.
Hey, I just read all that again. I can't figure out, why your second 
example returns (action?). That parenthesis should be evaluated, 
when you write mold a, shouldn't it?
It's the same in R3.
On the other hand, with the current behaviour, paren! works as block! 
in such situations. Blocks are not evaluated, when we write mold 
a, and a is a block. So why should a, if a is a paren! ? :-)
>> p: to paren! [a b c]
== (a b c)
>> mold p
== "(a b c)"

That's ok, I think.
Maxim
22-Aug-2009
[14556x2]
yep, we need that in order to handle things like parens in dialects.
>> a: [1 2 (3 4)]
== [1 2 (3 4)]
>> third a
== (3 4)
Ladislav
23-Aug-2009
[14558]
Geomol, I think, that you missed http://en.wikibooks.org/wiki/REBOL_Programming/Advanced/Interpreter
Geomol
23-Aug-2009
[14559]
Ladislav, how did you get the info to write that?
Ladislav
24-Aug-2009
[14560]
tests/experiments
Graham
25-Aug-2009
[14561x2]
Given some Json data like this::

{
page
:"1","total":4,"records":"22",
rows

:[{"id":null,"cell":["Quantum of Solace","Marc Forster","2008","Daniel 
Craig","200"]},

{"id":null,"cell":["Casino Royale","Martin Campbell","2006","Daniel 
Craig","150"]},

{"id":null,"cell":["Die Another Day","Lee Tamahori","2002","Pierce 
Brosnan","142"]},

{"id":null,"cell":["The World is Not Enough","Michael Apted","1999","Pierce 
Brosnan","135"]},

{"id":null,"cell":["Tomorrow Never Dies","Roger Spottiswoode","1997","Pierce 
Brosnan","110"]},

{"id":null,"cell":["GoldenEye","Martin Campbell","1995","Pierce Brosnan","58"]},

{"id":null,"cell":["Licence to Kill","John Glen","1989","Timothy 
Dalton","36"]}]
}


using Rebol-to-json, what sort of Rebol data object do I need to 
create to produce that output?
I've tried various combinations of objects and blocks and usually 
the rebol-to-json function just breaks.
Maxim
27-Aug-2009
[14563]
I am beyond mystified!   what is wrong with this code?

(1.3 * (any  [rgb clr]))


both rgb and clr have tuple values... if I remove the any, it works, 
if I try the any and probe it, it returns the proper value... 

this is within a compose block.

 ** Script Error: Cannot use multiply on decimal! value
** Where: refresh-gfx
** Near: 1.3 * (any [rgb clr])
PeterWood
27-Aug-2009
[14564x2]
Try reversing the operands to the *. It seems to work:

>> clr: 0.0.0             
== 0.0.0
>> rgb: 4.4.4             
== 4.4.4
>> 1.3 * (any [rgb clr])  
** Script Error: Cannot use multiply on decimal! value
** Near: 1.3 * (any [rgb clr])
>> ((any [rgb clr]) * 1.3)
== 5.5.5
Haven't figured out why :-)
Maxim
27-Aug-2009
[14566x2]
I can almost swear I tried it!  but anyhow I did the 'ANY earlier 
in the code.... and just use rgb directly now...
thanks for the help though... this is a really strange bug :-)
Sunanda
27-Aug-2009
[14568]
R2 does not allow [decimal! * tuple!] but it does allow [tuple! * 
decimal!] with a tuple! as the result
    1.3 * 9.9.9
    ** Script Error: Cannot use multiply on decimal! value
    9.9.9 * 1.3
    == 11.11.11

R3 allows both, with a tuple! as a result.

Looks like an R2 bug fixed only in R3.
Graham
27-Aug-2009
[14569x3]
In forming iso-8601 dates , you need to add the sign of the time 
zone.

Would you believe that 

pick [ "+" "-" ] positive? now/zone

is 4x faster than this

either (1 = (sign? now/zone)) ["+"] ["-"]
It relies on the behaviour of pick using false is same as pick 2
Is that going to be the same in R3?
Sunanda
27-Aug-2009
[14572]
R3 looks the same as R2 in that respect, at least right now
    pick [ "a" "b" ] true
    == "a"
    pick [ "a" "b" ] false
    == "b"
Chris
27-Aug-2009
[14573]
pick "+-" positive? now/zone
Sunanda
27-Aug-2009
[14574]
Those three methods timed under R3:
    dt [loop 100000 [pick [ "+" "-" ] positive? now/zone]]
    == 0:00:00.511

    dt [loop 100000 [either (1 = (sign? now/zone)) ["+"] ["-"]]]
    == 0:00:00.504

    dt [loop 100000 [pick "+-" positive? now/zone]]

    == 0:00:00.35    ;; looks like the speediest under current alphas.
WuJian
27-Aug-2009
[14575]
If   time/zone is  0:00, should the answer be "-"?
Graham
27-Aug-2009
[14576x4]
I think it's normally + .. have to read up about it.  though + or 
- 0 is the same :)
In R2 quite different results


>> t1: now/precise loop 100000 [either (1 = (sign? -10:00)) ["+"] 
["-"]  ] difference now/precise t1
== 0:00:00.278

>> t1: now/precise loop 100000 [ pick [ "+" "-" ] positive? -10:00 
] difference now/precise t1
== 0:00:00.062

>> t1: now/precise loop 100000 [ pick "+-" positive? -10:00 ] difference 
now/precise t1
== 0:00:00.07
Interesting that R2 is much faster than F3 here.
R3
Sunanda
27-Aug-2009
[14580]
R3 is still beta -- so may be full of debugging code.

Also, are you comparing my times with yours? We have may have different 
speed machines
Henrik
27-Aug-2009
[14581]
fastest algorithms on R2 and R3 are generally equally fast here.
Graham
27-Aug-2009
[14582]
I should rephrase that .. interesting my PC is much faster than yours!
Sunanda
27-Aug-2009
[14583x2]
....Or not running as many other processes :)
Just tried your code on R2.  You do have a faster machine than me, 
and R3 is currently much slower for this benchmark:
== 0:00:00.39
== 0:00:00.046
== 0:00:00.047
Steeve
27-Aug-2009
[14585x6]
weird guys, but you don't do the same thing in R2 and R3 
(positive? -10:00) is 10 times faster than (positive? now/zone)
Another way (not faster but lol)

>>#"," - 1 == #"+"
>>#"," + 1 == #"-"

so, that should works like

>>#"," - sign? 10:00 

But it doesn't in R3, because

>> #"," - -1
==>> #"," - -1
** Script error: char! overflow/underflow
** Where: -
** Near: - -1
So, you can't add or substract a negative integer! to a char!, but 
you can add or substract a positive integer!
Weird, i said
Btw, with R2 it works

>> #"," + sign? -10:00
==#"-"
Seems a bug in R3
except, the formula was wrong
>> #"," - sign? -10:00
Sunanda
27-Aug-2009
[14591]
In R3, this will work:
    to-char (0 - sign? 10) + #","
    == #"+"
     to-char (0 - sign? -10) + #","
    == #"-"


Not quite as fast as Chris's suggestion, but rejigging to remove 
the (...) may help:
    dt [loop 100000 [to-char (0 - sign? -10) + #","]]
    == 0:00:00.39
Steeve
27-Aug-2009
[14592]
well, it's just a shame to have to reconvert to a char!
Graham
27-Aug-2009
[14593]
doesn't work with 0 for timezone
Steeve
27-Aug-2009
[14594]
ahah, yes
Graham
27-Aug-2009
[14595x3]
BY THE WAY,

pick "+-" negative? now/zone

fixes the 0 issue
-1 => "-" , and 0, +1 => "+"
sorry ... it should be  

pick "-+" negative? now/zone
Sunanda
28-Aug-2009
[14598]
Is my understanding of find/part wrong, or is this a bug?
     series: ["a" "b" "c" "d" "e"]
     find/part series "c" at series 3  

     == none      ;; fails to match using the [at series 3] part of  'series
    print mold at series 3  
    == ["c" "d" "e"]  ;; but [at series3] does contain the match