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

World: r3wp

[!REBOL3]

Ladislav
2-Aug-2010
[4163x3]
No difference with FUNCT, stop that
OK, I understand, that your preferences are to set these arguments 
to #[none]
so many coding patterns depend on it
 - is that a general sentiment here?
Maxim
2-Aug-2010
[4166]
I have a counter question.  why would be set them to unset!  ?
Ladislav
2-Aug-2010
[4167x3]
Because they are, in fact, "undefined", which, by convention, is 
commonly expressed by having such variables unset in other cases
Even in functions, undefined arguments are in other cases unset, 
not set to #[none]
(I guess, that you know examples for that)
Maxim
2-Aug-2010
[4170x2]
in R2 everything is set to none, not sure about R3.
though I (and many others) often use none, to indicate the use of 
a default or fallback value.
Ladislav
2-Aug-2010
[4172]
R2 example (you surprised me not knowing it):

>> f: func [x [any-type!]] [value? 'x]
>> f
== false
Maxim
2-Aug-2010
[4173x2]
ah, but here you actually supplied unset to the function.

in a way, its not the same as not specifying the /refinement.
but yes, the line is thin.
Ladislav
2-Aug-2010
[4175x2]
>> g: func [/local x [any-type!]] [value? 'x]
>> g
== true
>> g/local
== false
(R2 example too)
Maxim
2-Aug-2010
[4177x2]
but the use of  any-type! is what specifically allows this "trick".

R3 removed the ability to not supply arguments...

>> a: func [x [any-type!]][value? 'x]
>> a
** Script error: a is missing its x argument
IIRC this was the great "equalizer" when make was overhauled... it 
now always accepts exactly one argument, because it is forced to.
Gregg
2-Aug-2010
[4179]
R2's behavior has always worked well for me. Unset is the special 
case I avoid unless I really, REALLY think there's a need to leverage 
it. I very rarely use any-type! for that reason. I like declared 
locals being NONE. I can't think of a time I tripped over using a 
refinement without passing its arg, but there unset would have to 
be intentionally expected as well.
Ladislav
2-Aug-2010
[4180x3]
>> b: func ['x [any-type!]][value? 'x]
>> b
== false
(R3)
Well, anyway, because of this, RebolTutorial completely ignoring 
any explanation makes a bad publicity to Rebol stating that "FUNCT 
and FUNC are incompatible", which is just nonsense.
Maxim
2-Aug-2010
[4183]
ok, but that is a fringe case which probably got put there specifically 
to allow that specific pattern so that some command-line functions 
can be simplied... 
its not the intended use of Rebol.


argument passing by reference is rarely used (a few mezzanines and 
highly specialized situations)
Gregg
2-Aug-2010
[4184]
Agreed. And things like the R3 behavior for a missing arg when using 
a lit-word! param versus a word! param would be good to note in the 
FUNC docs.
Maxim
2-Aug-2010
[4185x2]
in the above cases, they should be unset, because in fact they are 
passed unset!
the 'x refers to no value
Gregg
2-Aug-2010
[4187]
I think Ladislav dislikes lit-word params anyway, as they are a pain 
when generating code, but they make for good examples and thought 
experiments.
Maxim
2-Aug-2010
[4188]
they are mainly used for command-lines and code analysis funcs (?? 
for example)
Ladislav
2-Aug-2010
[4189]
Explanation: the "partially evaluated arguments" as used in R3 are 
OK with me, I disliked their R2 counterparts.
Gregg
2-Aug-2010
[4190]
OK. :-)
Maxim
2-Aug-2010
[4191x2]
yes, I agree completely.  this is now an intended setup, not an interpreter 
loophole leveraged as a feature.
Lad, can you explain simply, what is the difference between func 
and funct which RebolTutorial claims?
Ladislav
2-Aug-2010
[4193]
I cannot, because there is none
Maxim
2-Aug-2010
[4194]
ok
Ladislav
2-Aug-2010
[4195x2]
Example:
>> f: funct [] [[x:] value? 'x]
>> f
== true
Maxim
2-Aug-2010
[4197]
but I meant what does HE claim is the difference?
Ladislav
2-Aug-2010
[4198x3]
RebolTutorial claims, that the behaviour of the above F differes 
from FUNC, which is just nonsense, since the SOURCE function tells 
us:
>> source f
f: make function! [[
    /local x
][[x:] value? 'x]]
I do not think it deserves any more comments
Maxim
2-Aug-2010
[4201]
yeah, he doesn't seem to grasp that there is just one function! type 
 ;-)

and there is that nice little line in funct :   collect-words/deep/set/ignore

which pretty much explains it all  :-)
Ladislav
2-Aug-2010
[4202x6]
Nevertheless, the whole issue is related to his misunderstanding 
how the values of "unused refinement arguments" are set in functions
And, in my opinion, this actually *is* a gotcha for beginners
Since HELP tells us what the VALUE? function is supposed to do, which 
just does not look like being the case above
Reading the HELP string of the VALUE? function, I do not know, how 
I can reasonably expect F to yield #[true]
(which does not mean I don't respect Max's feelings on this)
The funny thing is, that the COLLECT-WORDS/IGNORE looks like being 
Tutorial's strategy when communicating with me ;-)
Maxim
2-Aug-2010
[4208x4]
/local x  sets the value of x to none in the F above.
if F was defined like so instead (R2)

>> f: make function! [/local x [any-type!]][[x:] value? 'x]


then you can call it with with unspecified /local arguments and it 
will yield #[false]

>> f/local
== false
things is funct doesn't add that [any-type!] in its param block.
(for locals)
so yes... the value?  help string makes sense... its defined as a 
local within the function, as 'FUNCT is supposed to do automatically.
Ladislav
2-Aug-2010
[4212]
defined as a local

 - yes, that is true, but in my example below, 'x is clearly defined 
 as "nonlocal", yet the function yields #[false], in accordance with 
 its help string:

>> g: func [] [[x:] value? 'x]
>> g
== false