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

World: r3wp

[Core] Discuss core issues

[unknown: 5]
21-Feb-2009
[12525x2]
Trace shows that it does see it as a lit-word
>> 'test
Trace:  'test (lit-word)
== test
Izkata
21-Feb-2009
[12527x2]
Trace shows that the interpreter - not the lit-word? function - sees 
a lit-word before it gets evaluated
not after
[unknown: 5]
21-Feb-2009
[12529x2]
Exactly!!!  So why don't we modify lit-word? function so that it 
can say true when it sees it?
See if I asked someone to tell me what type this is:

'test


They would most likely respond a lit-word.  So shouldn't the lit-word? 
function say the same?  I say it should.
Izkata
21-Feb-2009
[12531x2]
Rebol, the interpreter, sees a lit-word!.  Trace shows this.  It 
*then* evaluates it to a word!, *then* passes it to lit-word?, and 
lit-word? never sees the original lit-word!
I would ask if it's a line of code or data
[unknown: 5]
21-Feb-2009
[12533x3]
Trace doesn't show that it evaluates it to a word.  I don't know 
where you get that.
If it did, then I would think that Trace woudl show that but it doesn't 
- again:

>> 'test
Trace:  'test (lit-word)
== test
nothing about it being word! in that trace.
Izkata
21-Feb-2009
[12536]
Exactly, trace doesn't show that.  Trace doesn't show everything.
[unknown: 5]
21-Feb-2009
[12537]
Well then how can we be sure that is the case?
Izkata
21-Feb-2009
[12538]
>> Gettype: func [A][print type? A  return A]
>> lit-word? Gettype 'Test                   
word
== false
[unknown: 5]
21-Feb-2009
[12539]
In other words how do we not know that the native lit-word? function 
couldn't be modified to in fact report true in this case?
Izkata
21-Feb-2009
[12540]
Unless large modifications are made to the language itself, it would 
also start returning true for regular word! values
[unknown: 5]
21-Feb-2009
[12541x4]
Well that is my Izkata, how do we know that - are we just assuming 
that?  I mean we know that it can handle the data as a lit-word while 
it is in an unevaluated block.
For example, why can first ['test] return lit-word then?
Surely we can return true with a modification to lit-word? function 
to do the same for lit-word? 'test
Izkata, let my pose a hypothetical question to you.  If lit-word? 
could return TRUE to this statement:

lit-word? 'test

Would you desire that ability?
Izkata
21-Feb-2009
[12545]
No, as I would then never know if something's datatype was a word! 
or a lit-word!
[unknown: 5]
21-Feb-2009
[12546]
sure you would.  a word that doesn't have the tick in front of it 
woudl be a word!
Oldes
21-Feb-2009
[12547]
No
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.