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

World: r3wp

[Core] Discuss core issues

Geomol
1-May-2011
[1369x2]
Thanks!
It's for the parse function, I'm working on, and I want to be sure, 
I don't get a local var, if vars are used in the parse rules.
Maxim
1-May-2011
[1371]
if the parse rule is given as a parameter, vars within the rule will 
not be bound to the function.  the binding is static, i.e. it occurs 
only once, when the function is created.  the word in the parse, 
already is bound (or not).
Geomol
1-May-2011
[1372]
Ah yes, thanks.
Geomol
9-May-2011
[1373]
Tonights moment of REBOL ZEN:

>> f: func [/ref x] [print [ref x]]
>> f/ref/ref 1 2
true 2
onetom
9-May-2011
[1374]
ahhha...
>>  f: func [/ref x y] [print [ref x y]]   f/ref/ref 1 2 3 4
true 3 4
PeterWood
9-May-2011
[1375]
Can somebody confirm if the following crashes 2.7.8 on their machine

>> -1 * -2147483648
Sunanda
10-May-2011
[1376]
Crashes under Windows here,
Nice catch!
PeterWood
10-May-2011
[1377x2]
I was also running under Windows.
Crashes under OS X too:

>>  -1 * -2147483648
Floating point exception
BrianH
10-May-2011
[1379x2]
Geomol, that's something I've never seen anyone do in REBOL before. 
The discarded arguments are even evaluated properly and typechecked.
Works in R3 as well.
Ladislav
10-May-2011
[1381]
An old one, Peter. It is in %core-tests.r
PeterWood
10-May-2011
[1382]
Do  you know if it is RAMBO as I guess Carl doesn't take much interest 
in %core-tests.r ?
Ladislav
10-May-2011
[1383]
#4229
PeterWood
10-May-2011
[1384]
Thanks Ladislav.
Geomol
10-May-2011
[1385x2]
Tonight's Moment of REBOL Zen:

Check this Fibonacci function:

fib: func [
	n [integer!]
	(
		if not local [
			a: 0
			b: 1
		]
		prin [a b ""]
		loop n [
			prin [c: a + b ""]
			a: b
			b: c
		]
		print ""
	)
	/local a [integer!] b [integer!] c
][
	do bind third :fib 'a
]

>> fib 10
0 1 1 2 3 5 8 13 21 34 55 89 
== 89
>> fib/local 10 55 89 none
55 89 144 233 377 610 987 1597 2584 4181 6765 10946 
== 10946


If you only want to execute the paren in the function spec, put this 
in the body instead:

	do bind to block! third second load mold :fib 'a
A more simple example of this weird function construction:


>> hello-world: func [(print "Hello, World!")] [do third :hello-world] 
    
>> hello-world
Hello, World!
onetom
10-May-2011
[1387]
moebius function. its body bends and bites back into its own spec 
:)
Maxim
10-May-2011
[1388]
can anyone confirm that 'CALL on windows 7 is unable to launch apps 
without using the /show refinement.... which is VERY annoying.

it seems that call/shell no longer works.
Dockimbel
11-May-2011
[1389]
I use CALL without /show in Cheyenne to start worker processes. Anyway, 
CALL is quite unreliable in 2.7.8 on Windows as shown by this RAMBO 
ticket: http://www.rebol.net/cgi-bin/rambo.r?id=4416&
Geomol
12-May-2011
[1390]
Tonight's Moment of REBOL Zen:


The /local refinement in functions is just like any other refinement. 
This again mean, any refinement can be used for local variables, 
like in this example:

exp2: func [
	"2 raised to exponent"
	exponent [number!]
	/il-locale number [number!]
][
	if not il-locale [number: 2]
	number ** exponent
]

>> exp2 3
== 8.0
>> exp2/il-locale 3 3
== 27.0


But HELP will search for the /local refinement, when producing its 
output. But as any word, HELP can just be redefined to serve ones 
needs. HELP is even a function, so its source can be looked at, if 
someone wants to produce ones own HELP function.
ChristianE
12-May-2011
[1391x2]
/local is special only in HELP not listing any refinements and args 
from the /local refinement onwards. You can even use that to hide 
refinements (sth. like 'private' refinements):
>> zen: func [arg [integer!] /local /private base] [add any [base 
0] arg]
>> zen 1
== 1
>> help zen
USAGE:
    ZEN arg

DESCRIPTION:
    (undocumented)
     ZEN is a function value.

ARGUMENTS:
     arg -- (Type: integer)
>> zen/private 1 10
== 11
Maxim
12-May-2011
[1393]
just remember that in R3, the /local refinement might be given special 
status in a future release. this was mainly to prevent you from supplying 
default values to locals which can be a pretty big security hole 
right now.
ChristianE
12-May-2011
[1394]
That shouldn't be a problem, Max, I don't think too many people abuse 
implementation specific hacks like this one in code other than zen 
examples ... ;-)
Sunanda
13-May-2011
[1395]
Long discussion of R3/local here:
    http://www.rebol.net/cgi-bin/r3blog.r?view=0341
Geomol
13-May-2011
[1396]
Tonight's Moment of REBOL Zen:

>> skip [a b c] to integer! true
== [b c]
>> skip [a b c] true
== [a b c]
BrianH
13-May-2011
[1397x2]
Yup. The order of logic values as considered by SKIP, PICK and POKE 
is true then false. This was done to make PICK compatible with EITHER.
Carl uses PICK instead of EITHER a lot. He also marvels that this 
trick isn't used more often, especially since he added logic indexing 
specifically for that purpose :)
Geomol
13-May-2011
[1399]
Interesting explanation! Gives us even more Zen to think about:

>> pick [a b] true 
== a
>> pick [a b] to integer! true
== a
>> pick [a b] false           
== b
>> pick [a b] to integer! false
== none
Maxim
13-May-2011
[1400]
well, difference in types is expected, its the point of having dynamic 
typing.  I don't think its a required feature for type casting to 
result in symmetric uses of other functions.    I expect to-from 
one type to another to be as symmetric as possible, but not what 
they mean in another context of usage.
BrianH
13-May-2011
[1401]
Yup, because PICK, POKE, AT, INDEX? and /1 work with indexes, while 
SKIP works with offsets.
Henrik
13-May-2011
[1402]
I would like to use the PICK option more, if also NONE was supported 
as the first item.
BrianH
13-May-2011
[1403x2]
But that would make PICK data none the same as PICK data true, not 
PICK data false.
I would really like it if TRUE? was native. There's too much code 
that needs PICK reversed-data NOT condition, which would be better 
expressed as PICK data TRUE? condition.
Henrik
13-May-2011
[1405]
perhaps there should be a three-state PICK instead.
BrianH
13-May-2011
[1406x2]
0 = none, 1 = true, 2 = false?
Or -1, 0, 1 if you are thinking in terms of offsets instead of indexes.
Henrik
13-May-2011
[1408]
that depends if both the concept of three states and index direction 
change can be merged into one function and if that makes sense.
BrianH
13-May-2011
[1409x5]
I like that PICK is stopping point for none propagation. PICK data 
none should trigger an error, because otherwise you couldn't tell 
the difference between that and PICK [#[none]] 1.
is -> is a
We keep adding more points of none propagation, and every time we 
add one it makes more errors propagate further away from their point 
of origin. This makes it harder to figure out which code caused the 
error where none wasn't screened for or checked for, making it that 
much more difficult to debug.
We don't want REBOL code to be as difficult to debug as SQL.
Although PICK does propagate none indexes for datatypes where PICK 
acts the same as SELECT, such as map! or object!.
Geomol
14-May-2011
[1414]
Tonight's Moment of REBOL Zen:

Literal and Get Arguments in R2

see: http://www.rebol.com/docs/core23/rebolcore-9.html#section-3.2

These functions use Literal Arguments:


 ++ -- ? ?? cd default deflag-face first+ flag-face flag-face? for 
 forall foreach forskip help l ls map-each remove-each repeat secure 
 set-font set-para source

This function uses Get Argument:

	quote

It could be questioned, why functions like

	get set unset in catch throw checksum


, which all have arguments named WORD, don't use Literal Arguments?
BrianH
14-May-2011
[1415x3]
Lit-word arguments are for functions that treat words as keywords 
or part of the syntax, or for interactive command line functions 
that are supposed to act like shell funcs. If you use lit-word arguments, 
you can't easily generate the value passed using an expression, especially 
in R2 - in R3, those expressions can be put in parens, as is emulated 
in the R2 mezzanine backports of R3 functions that take lit-word 
arguments. For instance, if you made GET take a lit-word argument, 
GET IN wouldn't work.
The only exception to the above is ++ and --, which take lit-word 
arguments because their primary use is with a literal word value, 
so taking a lit-word argument gets rid of a ' in the most common 
case. And since ++ and -- started in R3 and has its behavior explicitly 
emulated in R2, you can put word-generating expressions in parens 
for the less common case.
FIRST+ is part of the same exception as ++ and --.
GrahamC
14-May-2011
[1418]
Does it make sense to have a timestamp datatype as distinct from 
a date type