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

World: r3wp

[!REBOL3]

BrianH
5-May-2011
[8512x2]
Consistency might be a good enough excuse to do so, but I don't want 
to break code unnecessarily.
(I am totally in favor of breaking code necessarily.)
Ladislav
5-May-2011
[8514]
For me, there is no trouble in it, but others should tell what their 
preferences are. (maybe they just don't mind much, I could tell almost 
the same about myself)
BrianH
5-May-2011
[8515]
The advantage would be to trigger errors when you DO code that isn't 
properly bound or set. It's either an error that it isn't bound or 
set, or it's an error that you are trying to DO it.
Geomol
5-May-2011
[8516x3]
Brian wrote:

<quote>
>> b: quote 'a/1 
== 'a/1 
>> b 

== 'a/1 ; regular evaluation of lit-path value does not convert to 
path 
>> do :b 

== 'a/1 ; explicit evaluation of lit-path value does not convert 
to path


So it's not exactly like parens, but it's what Maxim, Geomol and 
I would prefer.
</quote>

No, I just posted the observed behaviour. I don't agree with it.
I would expect this behaviour:

>> do quote 'a/1
== a/1
Or better, as I'm not sure, I like get-words as function arguments 
(see source of quote):

>> do first ['a/1]
== a/1
Ladislav
5-May-2011
[8519]
as I'm not sure, I like get-words as function arguments

 - this formulation is unfortunate. What the spec block of the QUOTE 
 function does is that it specifies how the argument expression is 
 handled. In R3 it means "don't evaluate the argument".
Geomol
5-May-2011
[8520]
Yeah, of course get-words can be function arguments. :-)

As you said, get-words in function spec blocks. I'm also not too 
fond of lit-words in spec blocks. I know, functions like HELP and 
SOURCE works like they do because of this, but if used frequently, 
code will be less readable, as I see it.
Ladislav
5-May-2011
[8521]
The QUOTE function is fine, and it is actually necessary, since e.g. 
there is no LIT-LIT-WORD argument, so, to obtain a lit-word, the 
most natural way is to use

    quote 'a
Geomol
5-May-2011
[8522x2]
If it's necessary, then we need to come up with examples of functions, 
that take a lit-word as an argument. I can't think of any.
Beside trivialities like TYPE? :)
Ladislav
5-May-2011
[8524x4]
that take a lit-word as an argument
- that looks unrelated
do we understand each other?
For example, the INSERT function can take a lit-word as an argument, 
if that is what you asked
...but why did you ask that?
Geomol
5-May-2011
[8528x2]
Yes, that's an example. I'm ok with writing

insert blk to lit-word! 'a


I asked, because you said, QUOTE is necessary. I don't see it as 
really necessary.
(old discussion, I know) :)
Ladislav
5-May-2011
[8530x2]
insert blk first ['a] is much more reasonable than that (your example 
converts a word to a lit-word, and unnecessarily so.
...because it first converts the said lit-word to a word (undesirably)
Geomol
5-May-2011
[8532]
well, if it works and do the job. And it's nice, there are more than 
one way to do things.
Ladislav
5-May-2011
[8533x5]
...and I do not think it has been discussed thoroughly, but, anyhow, 
I guess, that nobody objects against having lit-words or lit-paths. 
In that case, it is strange to object against QUOTE, especially taking 
into account, that QUOTE is much more universal, so, instead of saying

    get 'word

we can always say

    get quote word
I guess, that you feel, that the ' is much less universal (available 
only in some cases), while QUOTE is universal in R3 (always usable).
Why I wrote "QUOTE is necessary" - because that is the only way how 
to do it directly. Using the "double conversion method" you can do 
it usually as well, but that certainly does not count as a "direct 
method".
I even recall we used QUOTE to explain some issues to a beginner, 
which would be impossible to explain using the "double conversion 
method"
Moreover, the first ['a] method does not apply as a "direct method" 
as well, since it really performs some action, namely it gets the 
first value of a block, which is not a trivial operation, like QUOTE.
Geomol
5-May-2011
[8538]
If allowing get-words in spec blocks, then QUOTE is fine. I'm questioning 
allowing get-words in spec blocks. It can lead to uses as this:


I make a function, that can do a paren! (in lack of better example, 
but it makes the point, I think):
>> do-paren: [:p] [do p]
I can try it on a paren:
>> do-paren (1 + 2)
== 3
Works ok so far, so I try having a var holding a paren:
>> q: quote (1 + 2)
== (1 + 2)
>> do-paren q
== 3
I got the feeling, I know how do-paren works, until I write:
>> do-paren quote (1 + 2)
** Script Error: do is missing its value argument
Hm, what if I use the old method:
>> do-paren first [(1 + 2)]

** Script Error: p expected series argument of type: series pair 
event money date object port time tuple any-function library struct 
even...

That's confusing, as I see it. (Example done in R2.)
Ladislav
5-May-2011
[8539x2]
do-paren: [:p] [do p] - the only problem with the function is, that 
the function is so, that it can "do a paren", but only if that "paren" 
is already supplied as a value, i.e. not as an expression
reformulation: is should have said: "only if the said 'paren' is 
not supplied as a result of an expression"
Geomol
5-May-2011
[8541]
I remember reading, parens are evaluated (an active type, I think 
you call it). It's a very fundamental thing. Breaking this rule make 
the code less readable. Is it really necessary? What natives or mezz 
have get-word arguments? Kinda the same with lit-word arguments (in 
the spec block). My guess is, Carl made those, so he could write:
help add
instead of
help 'add
Ladislav
5-May-2011
[8542x2]
Please, stop writing "get word arguments", they are not "get word 
arguments"
Similarly, the "lit word arguments" are not "lit word arguments"
Geomol
5-May-2011
[8544x2]
right, what should we call them to not make confusion?
Maybe "get-word func parameters"?
Ladislav
5-May-2011
[8546x2]
they are "unevaluated arguments" in case of the QUOTE function, and 
and "partially evaluated arguments" in case of e.g. the first argument 
of the FOREACH function.
by "unevaluated" is meant "never evaluated", by "partially evaluated" 
is meant "sometimes evaluated, sometimes not evaluated"
onetom
5-May-2011
[8548]
(i didn't know about the :p where is it documented? otherwise i used 
the 'p notation many times. it even allows to add explanatory words 
to the parameters, so u can make a nice dialect by using the default 
'do evaluator...)
Geomol
5-May-2011
[8549]
The R2 doc for "get arguments" is here:
http://www.rebol.com/docs/core23/rebolcore-9.html#section-3.3
onetom
5-May-2011
[8550]
thanks a lot. i thought i know the core docs in and out :)
Geomol
5-May-2011
[8551x3]
:) I look in them now and then, as it's easy to forget many of the 
features in the language.
About unevaluated lit arguments (or literal arguments, as Carl call 
them), the functions FOR, FOREACH, REPEAT and maybe more use them 
(I couldn't remember earlier when I posted). And yes, it's more convenient 
to write
	repeat i 10 [...]
than
	repeat 'i 10 [...]


But used in some cases, it's probably easier to create less readable 
code. I can imagine a language, where this is different. About the 
other type of unevaluated arguments (get arguments as Carl call them), 
I haven't found other functions than QUOTE, that use it. There must 
be others!?
there is no LIT-LIT-WORD argument, so, to obtain a lit-word, the 
most natural way is to use: quote 'a

Some thoughts:

So one use of this is to make it easier to e.g. insert a lit-word 
in a block. I come to think of how to insert a block in a block. 
We can't do:

	insert blk [a b c]


as that will insert the 3 words, a, b and c, in blk. So I can write:

	insert blk [[a b c]]
or
	insert/only blk [a b c]


Why not use the same kind of thinking, when dealing with lit-words? 
So I can write:

	insert blk ['a]
or maybe
	insert/only blk 'a


(maybe the refinement should be called something else than /only). 
Now, the rule for INSERT should then be, that if it get a word (the 
lit-word, 'a, will be translated to the the word, a), it should change 
that to a lit-word, if it got the refinement too.


Result is, that unevaluated get arguments can be avoided making the 
REBOL scanner/parser simpler.
BrianH
5-May-2011
[8554x2]
Geomol, if you agree with this model:
>> do quote 'a/i
== a/1
, put your agreement in http://issue.cc/r3/1434where it counts.
As for functions with get-word arguments, the DO dialect used to 
need more of them, but in R3 most of those needs are handled by QUOTE. 
For other dialects though it is much more useful, as it prevents 
evaluation by the DO dialect when it is unwanted. It can be used 
on occasion in security situations if you want to block calculated 
values. Also, it could be used in a statically compilable subset 
of REBOL for the block arguments of all control and loop functions 
like IF and WHILE.
Geomol
5-May-2011
[8556]
No need, Ladislav already put it there. If that's for Carl to read 
through, it's an awful lot of information.
BrianH
5-May-2011
[8557x4]
Consensus adds to the strength of an argument. Chiming in with an 
"I agree with Ladislav" on a potentially controversial issue reduces 
the controversy that might otherwise block it, especially if you 
are sometimes someone who disagrees with Ladislav effectively (which 
is pretty difficult to do).
This has worked very well before with CureCode tickets and such. 
If Carl doesn't have a strong opinion either way, he will wait for 
consensus.
Back to QUOTE and get-word arguments...


We need something like QUOTE, especially for set-*, *-paths, and 
functions, because these block an evaluation that may have side effects, 
or at least cause a value copy. Even if QUOTE is the only function 
with this evaluation model, it depends on DO supporting something 
like get-word argument evaluation in order to work at all. The alternative 
is to make 'quote a keyword in the DO dialect, which decidedly doesn't 
have keywords. So we can't get rid of get-word arguments altogether 
without ridding ourselves of QUOTE, and you'd get a bit of resistence 
from anyone who's used it if you want to do that.
If you want a SECURE 'get-word constraint that you can apply after 
QUOTE is defined, that will block some but not all function hacking 
attempts using function values. The "but not all" part is critical 
though, so we are better off from a security standpoint if developers 
aren't allowed to think of function values as being safe to call 
without precautions, since the consistency of the need for that precaution 
makes it more commonly applied.
Geomol
12-May-2011
[8561]
Is this because string implementation isn't finished?

>> next "abc"
== "^@^

Maybe related to UTF?