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

World: r3wp

[!REBOL3]

Ladislav
2-Aug-2010
[4205x3]
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
BrianH
2-Aug-2010
[4213]
A little note about FUNCT vs. FUNCTOR: The word "functor" has a specific 
meaning in computer science, and that meaning is *not* what FUNCT 
does. There is no standard CS term for what FUNCT does, nor is there 
a standard English term. Any word we use would therefore have to 
be made up. FUNCT is not a bad made-up word: it's short, which is 
good for a function that will be used often in user code, and it 
starts with the same letters as FUNC and FUNCTION without being either 
one of those words.
Maxim
2-Aug-2010
[4214]
I'd rather we use PROC then.
Andreas
2-Aug-2010
[4215]
I strongly agree with Brian regarding the unsuitability of FUNCTOR.
Ladislav
2-Aug-2010
[4216]
Yes, I do agree too
Maxim
2-Aug-2010
[4217]
actually Lad, if a word is defined but stores a value of unset!  
(like what happens above with the [x:]  value? returns false.
BrianH
2-Aug-2010
[4218]
Some counterexamples where we messed this up:

- "functions" have side effects so they aren't really functions, 
they are procedures with return values.

- "closures" aren't really closures, though they are closer to that 
than REBOL "functions" are.
- "contexts" aren't contextual
The list goes on.
Maxim
2-Aug-2010
[4219x2]
cause x actually has not ever been set.
so if I get you right,  in REBOL: 

contexts are actually closures, 
functs are actually functions 
and funcs are actually procedures

;-)
BrianH
2-Aug-2010
[4221]
We actually had a function called FUNCTOR for a while, and it really 
created functors. And it went unused for more than a year, so we 
dropped it. It turned out that what FUNCT does is really useful, 
even though the concept is unique to REBOL. Apparently functors aren't.
Ladislav
2-Aug-2010
[4222]
Brian, agreed, but e.g. "functions" are somewhat "standard" (C, ...)
BrianH
2-Aug-2010
[4223x2]
FUNCTs and FUNCs are both procedure builders. Neither create functions. 
It's a common naming mistake in imperative languages.
Including C and the Pascal it was based on.
Maxim
2-Aug-2010
[4225]
but really, I would rather we use the term proc instead of funct
BrianH
2-Aug-2010
[4226]
Then it isn't like FUNC, and people are more likely to misunderstand 
the difference. It really is a unique concept, certainly nothing 
like the proc concept in other languages that have that term.
Andreas
2-Aug-2010
[4227]
I think proc would make things even worse. Nothing would indicate 
that FUNC and PROC are basically the same, except for a minor (but 
important difference). And choosing which does which is absolutely 
arbitrary.
Ladislav
2-Aug-2010
[4228]
agree with Andreas
Andreas
2-Aug-2010
[4229]
I actually preferred Ladislav's old LFUNC naming; but FUNCT is fine 
as well. There simply is no easy way to name this.
Maxim
2-Aug-2010
[4230]
I'd probably stop using func most of the time, and I can't see myself 
typing funct  20 times a day.


everytime I write it, I feel like I'm writing a less savory femal 
genital word in a strange dialect of german ;-)
Andreas
2-Aug-2010
[4231]
Yes. I think the only real choice we have is what behaviour we want 
to label with FUNC, which is probably the most prominent name among 
our options.
BrianH
2-Aug-2010
[4232]
Maxim, nothing in REBOL corresponds to a closure, though the closure! 
type is closer than other function types, and many other languages 
call something similar to that a closure too. We don't have contexts 
(though "dialects" are close). Neither FUNC nor FUNCT build real 
functions, but they both build what other imperative languages incorrectly 
call functions, so people won't get confused.
Graham
2-Aug-2010
[4233]
The value of funct over lfunct is that it sorts in proximity alphabetically
Ladislav
2-Aug-2010
[4234]
yes, that is why I think it is quite reasonable
Graham
2-Aug-2010
[4235]
lfunct = Lfunc
Andreas
2-Aug-2010
[4236x3]
Which is also its most prominent shortcoming, as readers pattern-match 
better at the beginning of a word then at the end.
So LFUNC is visually more different to FUNC then FUNCT is.
than*
Graham
2-Aug-2010
[4239]
depends on whether you want to stress the similarities or differences
Maxim
2-Aug-2010
[4240]
I also prefer LFUNC the L actually has meaning in that word.  the 
mind unwraps the L to "Local" automatically.   while FUNCT really 
is obscure everytime you read it.
BrianH
2-Aug-2010
[4241]
I have two reasons why I like keeping FUNC the way it is:

- FUNC is the simplest function-creating function, so giving it the 
shortest name seems appropriate.

- As a rule, we prefer to not rename old functions and then give 
their old names to new functions. That would be user-hostile.
Maxim
2-Aug-2010
[4242]
I agree, func is the basis of just about every script out there.
Andreas
2-Aug-2010
[4243]
But never forget bug#666.
BrianH
2-Aug-2010
[4244x3]
FUNCT doesn't just gather locals ("lfunc"), it also optionally binds 
the function body to an object ("friend-func" to adapt the C++ term.
Andreas, I also don't forget bug#667.
The rule in bug#667: "We are trying to keep our breaks in compatibility 
of legacy functions limited to semantic changes, removed or changed 
options and such, and only when necessary (see #666). Some legacy 
functions have been removed altogether. None have been renamed yet 
- except as in the example above, with the old name still there."
Andreas
2-Aug-2010
[4247]
Thanks, but we are discussing hypothetically here.
Maxim
2-Aug-2010
[4248x2]
yes, but its a refinement, and even then, it still acts "locally" 
within that object (I'm assuming its using function locals on words 
in didn't bind to).
in = it
Andreas
2-Aug-2010
[4250]
(And FUNCT/WITH would warrant a discussion on it's own.)
Ladislav
2-Aug-2010
[4251]
I posted #1640 just today related to it
Andreas
2-Aug-2010
[4252]
But given the hypothetical blank slate, I'd still agree with Brian's 
first argument, namely the using FUNC as name for the simplest common 
case is sensible.
Maxim
2-Aug-2010
[4253]
why not call it GOSUB   ;-)
Graham
2-Aug-2010
[4254]
Of course nothing to stop you from creating new names ...

F: :func
LF: :funct