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

World: r3wp

[Core] Discuss core issues

Rebolek
21-Feb-2009
[12548]
first is function! that gets evaluated. it takes one argument - block! 
that argument is also evaluated and block! is evaluated to block!. 
then it returns first value of that block. this value is not evaluated 
- but that's ok, it's 'first's behaviour
Oldes
21-Feb-2009
[12549]
But it's better to submit it as a wish into CureCore and see what 
Carl means
[unknown: 5]
21-Feb-2009
[12550]
Oldes I was going to personally take it to Carl via RebDev but I 
won't if the community doesn't desire it to report true in such a 
case.
Izkata
21-Feb-2009
[12551]
Paul, how would you check that?  String manipulation?  Because trying 
to get the first character of a word! or a lit-word! errors
[unknown: 5]
21-Feb-2009
[12552]
Izkata, how does REBOL know that this is a string?:

this
Izkata
21-Feb-2009
[12553]
Without a context, it doesn't:
>> X: to-word {"this"}
== "this"
>> ? X
X is a word of value: "this"
Oldes
21-Feb-2009
[12554]
:)
[unknown: 5]
21-Feb-2009
[12555]
Izkata, I'm sure that REBOL is written in C language and in C we 
use a char type for this.  So it is possible to detect the ' character.
Oldes
21-Feb-2009
[12556]
Why do you need this behaviour?
[unknown: 5]
21-Feb-2009
[12557]
Just seems more consistent to me Oldes that is all.
Oldes
21-Feb-2009
[12558]
>> test: first ['foo]
== 'foo
>> lit-word? :test
== true
[unknown: 5]
21-Feb-2009
[12559]
what happens Oldes if you do this:  

lit-word? 'test
Oldes
21-Feb-2009
[12560]
And here?
>> get-word? :test
== false
>> type? :test
== lit-word!
BrianH
21-Feb-2009
[12561x5]
>> val: first ['a]
== 'a
>> lit-word? val
== false
>> lit-word? :val
== true
>> lit-word? first ['a]
== true


It's not the assignment or LIT-WORD? that is converting the lit-word! 
to a word!, it is DO. This is a good thing.
It is not *in any way* a bug, it is intended behavior.
If you want DO to just get a value and not treat active values as 
values, use a get-word expression. This is evaluation model stuff. 
You need to be able to distinguish between the data that your code 
is working on, from the data that your code *is*, itself.
The difference is between your data:
>> ['a]
== ['a]
and the data of the DO function:
>> 'a
== a


Just because your code is data, doesn't mean your code is *your* 
data. It is actually DO's data, and DO interprets its data as what 
we think of as the REBOL syntax. I didn't see you complain that the 
set-word! in your code was treated as an assignment, or that the 
word! print is treated as a function call. The treatment of lit-word! 
values *in code* is no different from those.
This whole discussion belongs in the "I'm new" group, or maybe "Rebol 
School".
[unknown: 5]
21-Feb-2009
[12566]
Brian, just for you information.  Remember that in REBOL 'test is 
not a lit-word.
Oldes
21-Feb-2009
[12567]
Paul.. so you really think, that:
  get-word? :test
should return true? Because it's the same case.
Or what about:
  set-word? x:
[unknown: 5]
21-Feb-2009
[12568x2]
Oldes, no I don't because words are the medium for data in REBOL.
Actually Oldes, I do believe they should be in your example.  But 
that is just me.
PeterWood
21-Feb-2009
[12570x5]
Paul .. Would you expect the argument to this function to be a lit-word 
or a word?

myfunc 'a
>> myfunc: func [word-or-lit-word] [print type? word-or-lit-word]

>> myfunc 'a

word
I suspect it would be a major change to Rebol for functions to receive 
unevaluated values which is what I believe you want.
I believe it would require much more than writing a native lit-word? 
function.
Perhaps when we get "plugins" or whatever they're called in Rebol 
3 will can experiment to find out.
Anton
21-Feb-2009
[12575]
It looks like what Paul wants is for lit-word? to take its argument 
literally. eg:

	*lit-word?: func ['val][lit-word? :val]
	*lit-word? 'hello ; == true


but this ends up causing problems, as discovered elsewhere with functions 
taking arguments literally, eg:

	my-val: first ['hello]

 *lit-word? my-val ; == false    <---------- Unexpected because MY-VAL 
 taken literally.

and


 *lit-word? first ['hello] ; == ['hello]     <----- Unexpected because 
 FIRST was not evaluated.
BrianH
22-Feb-2009
[12576]
Paul, in REBOL 'test is a lit-word!. The problem is that you are 
getting datatypes and evaluation rules mixed up. When you are evaluating 
your own data, you can treat lit-words any way you like. When DO 
is evaluating *its* data (what you would call normal REBOL code), 
it treats lit-words as active values. Active values are normally 
evaluated when DO encounters them - the only exception is when they 
are just retrieved from some word they are assigned to, either using 
GET, or DO's shortcut for GET: get-words. All of DO's active values 
work this way.


And there is a good reason DO treats lit-words as active values: 
If there were no active lit-words, DO wouldn't be able to refer to 
word values without breaking words as variables, and normal REBOL 
code would cease to function.


When I say that it is not a bug that lit-words are active values, 
I am understating things. What is really the case is that lit-words 
being active values is the *entire reason for their existence* - 
if they weren't active values, there would be no point to them at 
all. Oh, and REBOL code wouldn't be able to work with its current 
syntax.
[unknown: 5]
22-Feb-2009
[12577x3]
Anton you get it.  But in yoru second exampel it would be lit-word? 
:my-val since word is already defined.
Brian, my point is that 'test is NOT a lit word  as you can see here:

lit-word? 'test
==false
I have no beef with DO and how it works elsewhere.  Again, only how 
lit-word? and other functions work in that regard.
BrianH
22-Feb-2009
[12580]
Try the lit-word 'test without running it through DO:
>> type? second [lit-word? 'test]
== lit-word!
[unknown: 5]
22-Feb-2009
[12581]
Not my point Brian.  lit-word? says it isn't.
BrianH
22-Feb-2009
[12582]
By the time LIT-WORD? sees the value, DO has already converted it 
to a word!, the way it is supposed to. LIT-WORD? works fine.
[unknown: 5]
22-Feb-2009
[12583]
Anton must have read thru this because he narrowed down to the fact 
that I'm talking about what lit-word? returns when passed 'test as 
its argument.
BrianH
22-Feb-2009
[12584]
LIT-WORD? is just a type test.
[unknown: 5]
22-Feb-2009
[12585x2]
Brian, I don't care about what lit-word is actually doing.  I'm not 
trying to understand what it does.  I already get that part.  I'm 
saying it should be modified to identify 'test as a lit-word.
and 'test is a lit-word
BrianH
22-Feb-2009
[12587]
You aren't passing 'test as an argument to LIT-WORD? whenn you do 
this:
lit-word? 'test
==false

What you are doing is *evaluating* 'test and then passing *that* 
value to LIT-WORD?. There's a difference.
[unknown: 5]
22-Feb-2009
[12588x2]
No, lit-word? must be evaluating 'test.  nothing else is.
Trace it Brian.  The interpreter sees it as a lit-word.  It doesn't 
evaluate it to word!
BrianH
22-Feb-2009
[12590]
DO is evaluating 'test. DO is the evaluator.
[unknown: 5]
22-Feb-2009
[12591]
I'm not using 'DO
BrianH
22-Feb-2009
[12592]
Yes you are, every time you run REBOL code.
[unknown: 5]
22-Feb-2009
[12593]
Thats not true
BrianH
22-Feb-2009
[12594]
IF runs DO, as does WHILE, EITHER, LOOP, ...
[unknown: 5]
22-Feb-2009
[12595]
Functions do brian.  Which is my point that lit-word? could be modified 
to handle this.  You act like it can't be done.
BrianH
22-Feb-2009
[12596]
Just because it doesn't show up in trace doesn't mean it doesn't 
happen.
[unknown: 5]
22-Feb-2009
[12597]
Brian, if it was Do'ing the word then it would report back that it 
has no value when I do:

lit-word? 'test