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

World: r3wp

[Core] Discuss core issues

Henrik
1-Apr-2008
[9977]
>> first find [false true] 'false
== false
>> type? reduce first find [false true] 'false
== word!
Fork
1-Apr-2008
[9978]
That much I get, I just thought that reduce turned false-as-word 
into false-as-logic and it does not
Geomol
1-Apr-2008
[9979]
Yes, it's still a word! and not a logic!, even if you reduce it.
Fork
1-Apr-2008
[9980]
So what turns it into a logic, if not reduce?
Dockimbel
1-Apr-2008
[9981]
do
Henrik
1-Apr-2008
[9982]
reduce the block instead
Fork
1-Apr-2008
[9983]
>> if ( do first find [false true] 'false ) [print "false is in the 
list"]
== none
Henrik
1-Apr-2008
[9984]
looks like R3 does not exhibit that behavior. it's reduced to logic!
Fork
1-Apr-2008
[9985]
Ok, great, that's the case I was worried about then...
Geomol
1-Apr-2008
[9986]
Or LOAD:
>> load to string! 'false
== false
Fork
1-Apr-2008
[9987]
I'm confused as to why reduce, which seems to perform other evaluations, 
would not (in R2) turn false into a logic!... Henrik, you are saying 
it does?
Henrik
1-Apr-2008
[9988]
Fork, Rebol 3 does, so this may be an inconsistency in Rebol 2.
Geomol
1-Apr-2008
[9989x2]
It's often works, if you turn stuff into a string and then load that. 
Other ways to turn stuff into strings:

>> load mold 'false
== false
>> load form 'false
== false
*It* often works ...
btiffin
1-Apr-2008
[9991]
Not quite;    reduce 'false  is a word,  reduces as a word!     reduce 
[false]   reduces the block, evaluating false to the logic! false. 
  It's fun stuff.   ;)    mold/all  can be your friend exploring 
the ins and outs of evaluated values.
Geomol
1-Apr-2008
[9992]
oops! :D
btiffin
1-Apr-2008
[9993]
Sorry John; responding to Forks confused post not yours.   I always 
trust Geomol advice  :)
Geomol
1-Apr-2008
[9994]
I got confused too. :)) REBOL is funny to play with!

>> type? load form 'false
== word!
>> type? load mold 'false
== word!
Dockimbel
1-Apr-2008
[9995]
In R2, REDUCE main purpose is to reduce block! values. For general 
evaluation use DO.
Geomol
1-Apr-2008
[9996]
btiffin, I make mistakes too! :-)
btiffin
1-Apr-2008
[9997]
Yeah any word! reduced is still the word!
Henrik
1-Apr-2008
[9998]
sorry:

>> type? false
== logic!
>> type? reduce false
== logic!

R2 and R3 behave identically here.
Geomol
1-Apr-2008
[9999]
Henrik, yes, but
>> type? reduce 'false
== word!

Is that the same in R3?
Fork
1-Apr-2008
[10000]
It seems like reduce is a core notion, and it would be nice to see 
a list mapping what conversions it performs.  Changing that between 
R2 and R3 seems rather... fundamental?
btiffin
1-Apr-2008
[10001]
Fork;   There are also "lexical forms" for all these values.   #[false] 
 is loaded by REBOL as the logic! value false.  No need to evaluate 
in that case.

John; yes.
Fork
1-Apr-2008
[10002]
I'd suggest coming up with a new keyword, e.g. reduce3, if something 
like that were to change.
Henrik
1-Apr-2008
[10003]
geomol, yes, they are identical
Geomol
1-Apr-2008
[10004]
Fork, we're normally ok with not being completely compatible with 
new versions. Better to correct the failures as soon as possible.
btiffin
1-Apr-2008
[10005]
Brian;   It comes down to the ill-documented sequence of  load/evaluate 
and the spellings of some the values.  false, true, none are the 
most common gotchas.
Henrik
1-Apr-2008
[10006]
Fork, R3 is not meant to be compatible with R2, so that would not 
be likely to happen. If a function doesn't behave consistently, it 
will change. Just for the record. :-)
Geomol
1-Apr-2008
[10007]
Alternative:

>> type? do load form 'false
== logic!

But the most simple must be:
>> type? do 'false
== logic!

There are so many ways to get the same result.
Fork
1-Apr-2008
[10008x3]
Ok, I appreciate the help... but I do wonder if there is a certain 
answer that Rebol 3 reduces words to logic
So my earlier example, would it act different in R3?
>> if ( reduce first find [false true] 'false ) [print "false is 
in the list"]
false is in the list
btiffin
1-Apr-2008
[10011]
Nope;  words reduce as words.

Here is a good article by one of heroes;   http://en.wikibooks.org/wiki/REBOL_Programming/Advanced/Interpreter
Henrik
1-Apr-2008
[10012x2]
same result
and it would be because we are in that example always dealing with 
words.
Fork
1-Apr-2008
[10014]
Ok, so Henrik, does that mean you retract your statement "Fork, Rebol 
3 does, so this may be an inconsistency in Rebol 2."
Henrik
1-Apr-2008
[10015]
yes :-) sorry about that. I mixed up some results.
Fork
1-Apr-2008
[10016x2]
In regards to what I said: "Im confused as to why reduce, which seems 
to perform other evaluations, would not (in R2) turn false into a 
logic!... Henrik, you are saying it does?"
Ok, whew.  Good :)
btiffin
1-Apr-2008
[10018]
Give Ladislav's article a read...it cleared up a lot for me, but 
I still can't explain it  :)
Fork
1-Apr-2008
[10019x2]
reduce does not turn words into logic.  do does.  I'll write that 
down :)
Thanks for the link, I will check it out.  Ladislav seems to think 
about some of the same general issues I do, as he apparently made 
lfunc... we're probably on the same page in other ways...
Geomol
1-Apr-2008
[10021]
Fork, you also have a problem with your check, if 'false isn't in 
the series:

>> first find [true something-else] 'false

** Script Error: first expected series argument of type: series pair 
event money date object port time tuple any-function library struct 
...
Henrik
1-Apr-2008
[10022]
generally I only use REDUCE on blocks, because it does not seem very 
useful on anything else.
Fork
1-Apr-2008
[10023]
Yes, I knew that bit :)
Geomol
1-Apr-2008
[10024]
ok
Henrik
1-Apr-2008
[10025]
Geomol, that works in R3. :-)
btiffin
1-Apr-2008
[10026]
Yep;  he seems to "get it".  Normal rebols just flail about until 
it sinks in.