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

World: r3wp

[Core] Discuss core issues

Henrik
22-Aug-2011
[2206]
http://www.rebol.net/cgi-bin/rambo.r?id=4332&
Dockimbel
22-Aug-2011
[2207]
Same issue with FIND on native! values: http://www.rebol.net/cgi-bin/rambo.r?id=4126&
Geomol
22-Aug-2011
[2208]
A sidenote about SWITCH: I often find myself needing a switch, where 
I look for datatypes, like:

	switch type? value reduce [
		integer! [...]
		word! [...]
	]


It works, but only if I include the REDUCE, else the words in the 
block are just words. I was thinking, if SWITCH should have a refinement 
telling it to reduce the block, or something. Do you have same kind 
of switch as me?
Henrik
22-Aug-2011
[2209x2]
geomol, use type?/word
that returns the type as a word. it seems to be made precisely for 
this scenario.
Geomol
22-Aug-2011
[2211]
ah, didn't notice type?/word, thanks! :)
Rebolek
22-Aug-2011
[2212]
I tried it only in R3, I'm not sure about R2
Geomol
22-Aug-2011
[2213]
So my original FIND can be solved with:

>> find [[] [] block!] to word! block!
== [block!]
Henrik
22-Aug-2011
[2214]
well, if the block is reduced elsewhere, that would be a problem.
Geomol
22-Aug-2011
[2215]
yes
Pekr
23-Aug-2011
[2216x2]
I have got a question of soon-to-join-us-here reboller, asking about 
the possibility to launch new rebol process, using lowered security.

launch "some-script.r" works
lanuch "--secure allow --script some-script.r" does not work

I think I might use 'call instead?
Hmm, strange. When I type: launch "-s some-script.r", then uninstall 
dialog box appears.
Endo
23-Aug-2011
[2218x2]
Yep there are some problems using launch I think.

launch {-s --noinstall} ;--> starts nre Rebol process in trace mode. 
just like I use -t option.
Strange..
>> launch/as-is {-s}
** Script Error: Feature not available in this REBOL
** Near: launch/as-is "-s"
Pekr
23-Aug-2011
[2220]
I suggested my friend to use: call "rebol.exe -si my-script.r"
Endo
23-Aug-2011
[2221]
better option I think as launch is really problematic.
Gregg
23-Aug-2011
[2222]
LAUNCH, RUN, and CALL make things confusing. I almost always use 
CALL now.
Henrik
24-Aug-2011
[2223x2]
Composing a lit-path:

>> f: [b d e f]
== [b d e f]
>> i: 2
== 2

It would be nice that instead of this:

>> compose 'f/(i)
== f/(i)

you would get:

== f/2
Doesn't work in R3 either.
Rebolek
24-Aug-2011
[2225]
I think that it should throw error, because 'compose should accept 
only block! value.
Henrik
24-Aug-2011
[2226x2]
lit-path is a series, so I think the argument is sound for the latter 
result.
It gets rid of a workaround, where I must store a path, where some 
values in the path can't be determined until storage, the moment 
where COMPOSE needs to act. The workaround is to create the path 
as a block, and then TO-PATH it on use.
Ladislav
24-Aug-2011
[2228x2]
>> f: [b d e f]
== [b d e f]

>> i: 2
== 2

>> my-path: rejoin [to path! [] 'f i]
== f/2
or, in R2:

    my-path: rejoin [#[path! []] 'f i]
Steeve
24-Aug-2011
[2230]
or
>> append to-path 'f i
Geomol
24-Aug-2011
[2231x2]
A fast way is:
>> to path! reduce ['f i]
== f/2

(Maybe the fastest?)
But yes, Henrik, COMPOSE should maybe work on path too, as it is 
a series. And maybe also on parens (also a series), where COMPOSE 
should work on parens inside.
Gregg
24-Aug-2011
[2233]
REBOL handles parens in paths today. I can see the usefulness of 
having that evaluation return a composed path.
Henrik
14-Sep-2011
[2234]
>> equal? make object! [] make object! []
== false

is this intentional?
Sunanda
14-Sep-2011
[2235]
It may be because they are considered to have distinct 'self's

    a: make object! []
    b: make object! []
    equal? a b
    == false
    equal? (first  a) (first b)
    == true
    equal? (second  a) (second b)
    == false
    equal? (third  a) (third b)
    == true
    a/self = b/self
    == false
Endo
14-Sep-2011
[2236x2]
and it's more useful than the other way I think. Once I wrote a function 
to test if two object is similar. It looks a bit silly but works 
for me. Can be extended to test values also:

similar?: func [
    {Returns true if both object has same words in same types.}
    o [object!] p [object!] /local test
][

    test: [if not equal? type? get in o word type? get in p word [return 
    false]]
    foreach word sort first o test
    foreach word sort first p test
    true
]
>> similar? make object! [] make object! []
== true
BrianH
14-Sep-2011
[2238x2]
There's some (fixable) bugs in R3 related to equality of objects, 
and some different (unfixable) bugs in R2. In R3 at least:
>> equal? make object! [] make object! []
== true
R2's behavior in this may not be intentional, but it's not fixable 
because of backwards compatibility :(
Henrik
15-Sep-2011
[2240]
ok, interesting, thanks.
Geomol
16-Sep-2011
[2241]
Today's Long Moment of REBOL Zen:


When making an object, code in the block argument is executed. I 
found, BREAK stops further execution:

>> o: context [a: 1 break b:2]
>> ? o
O is an object of value: 
   a               integer!  1


So the B assignment isn't carried out. Ok, what about a RETURN in 
object creation then? I'll use MAKE OBJECT! instead of CONTEXT, so 
the RETURN is not handled by CONTEXT, which is a function:

>> o: make object! [a: 1 return 0 b:2]
>> ? o
O is an object of value: 
   a               integer!  1


It seems like, making objects can handle returns ... in R2 at least. 
This has changed in R3, where the result is:

>> o: make object! [a: 1 return 0 b: 2]
** Throw error: return or exit not in function


This seems reasonable. What if I use CONTEXT and use RETURN in the 
object creation? In R2 CONTEXT doesn't have a THROW function attribute, 
so my guess is, RETURN will return from CONTEXT, and the rest of 
the object isn't made, and this is what happens:


>> o: context [print "before return" return 0 print "after return"]
before return


Ok, I now want to fix CONTEXT by putting the THROW attribute in, 
and then test it by making an object using CONTEXT, but this time 
inside a function:

>> context: func [[throw] blk] [make object! blk]

>> f: does [context [print "before return" return 0 print "after 
return"] print "still in f"]


When running F, I would expect to just see the words "before return", 
but

>> f
before return
still in f


I see, that THROW doesn't work as intended, when making objects. 
This is the same in R3, where CONTEXT also doesn't have THROW, and 
when trying to fix that by changing CONTEXT, it's still the same 
behaviour as in R2.
BrianH
16-Sep-2011
[2242x2]
There is not yet any equivalent to R2's [throw] attribute in R3, 
and there have been many tickets and much discussion related to this 
issue, none of which have yet led to any changes, though that may 
change.
As for your attempt to fix R2's CONTEXT using the [throw] attribute, 
you do manage to fix CONTEXT, but there's no fixing the MAKE object! 
it calls catching the RETURN when it shouldn't. So only one of the 
bugs is fixed, not the other. Guess that's why CONTEXT didn't have 
a [throw] attribute already.
Henrik
18-Sep-2011
[2244x3]
MAP-EACH under R3:
>> map-each v [] [v]
== []

MAP-EACH under R2:

>> map-each v [] [v]
** Throw Error: Return or exit not in function
** Where: map-each
OK, already ramboed in #4394.
is there a fix for this?
Ladislav
18-Sep-2011
[2247x3]
Certainly there is. In R2 it is a mezzanine, which can be corrected.
The easiest way would be to remove the RETURN in the source
e.g. by using EITHER
Henrik
18-Sep-2011
[2250]
ok, Ladislav, are we sure that it will not affect any sources in 
NLPP?
Ladislav
18-Sep-2011
[2251]
Why should it, if done right?
Henrik
18-Sep-2011
[2252]
the incorrect behavior won't necessarily cause a crash, but of course, 
it's probably not likely that map-each is used that way.
Ladislav
18-Sep-2011
[2253]
Hmm, if somebody relies on the incorrect behaviour, then it is good 
if such a mistake is revealed
BrianH
19-Sep-2011
[2254x2]
There is a fix in R2/Forward already. I'll post it here.
Unfortunately, this is an old problem with an old fix, but not as 
old as the last version of R2.