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

World: r3wp

[Core] Discuss core issues

[unknown: 5]
22-Feb-2009
[12578x2]
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
BrianH
22-Feb-2009
[12598x2]
Functions don't evaluate their arguments, the evaluator does. Your 
change to LIT-WORD? would break it. When you DO a lit-word! it returns 
the associated word! value. That is what lit-words mean in DO code: 
Literal words.
Just like DO treats set-words as shortcuts for SET, get-words as 
shortcuts for GET, etc.
[unknown: 5]
22-Feb-2009
[12600]
Brian, my point is that I would rather have lit-word? do what it 
says it does.
BrianH
22-Feb-2009
[12601]
It does that already.
[unknown: 5]
22-Feb-2009
[12602x2]
Oh it does - does it?  Well let's check.
Tell me what datatype this is Brian:

'test
Izkata
22-Feb-2009
[12604x3]
What context?  Is it being evaluated or now?
or not?*
Rebol from the command line, as well as a running script IS a 'do 
session, that's what we're trying to get at.  'do is what's converting 
the lit-word! into a word! before it reaches the function
Rebolek
22-Feb-2009
[12607]
Paul, when you write 

>>lit-word? 'test 

what is really happening is this: 

>>lit-word? ('test)
Anton
22-Feb-2009
[12608x2]
Paul, I agree with everything BrianH has said in this discussion.
When, you've typed something at the console:

	>> 'test	

, and you press Enter, it is as if this is happening in a script:

	do ['test]


The result is equivalent - a lit-word reduces to a word, which is 
returned.
Rebolek
22-Feb-2009
[12610]
yes, and
>> lit-word? 'a
can be written as
>> do lit-word? do 'a
or 
>> (lit-word? ('a))
[unknown: 5]
22-Feb-2009
[12611x2]
As I said guys it is just me that doesn't like how it lit-word? operates.
As I said before I know what is happening but rather it didn't happen 
that way.
Henrik
22-Feb-2009
[12613x2]
I wonder how you would make it work like you want, because that is 
up to the interpreter, not LIT-WORD?.
>> a: func [b [lit-word!]][return b]
>> a 'test
** Script Error: a expected b argument of type: lit-word
** Near: a 'test
[unknown: 5]
22-Feb-2009
[12615x2]
I made one that works like I want and it doesn't use lit-word? at 
all
>> is-lit-word? 'test
== true
>> is-lit-word? first ['test]
== true
>> is-lit-word? "test"
== false
>> is-lit-word? 'do
== true
Izkata
22-Feb-2009
[12617]
what happens with "is-lit-word? first [test]"  ?
[unknown: 5]
22-Feb-2009
[12618x5]
That would be true also.
>> is-lit-word? first [test]
== true
See to me the question comes down to the fact that I wanted a function 
that tells me what the argument was passed to it as not what the 
function recognizes it as.
So then I have to determine what is a lit-word?  It is merely a word 
that is has the tick symbol at the beginning or is it a word that 
in affect is of the same characteristic as a word with a tick symbol. 
 I chose the latter since it is more in form with REBOL.
http://www.tretbase.com/forum/viewtopic.php?f=8&t=30&p=141#p141
Izkata
22-Feb-2009
[12623]
So.. it looks to me like this is just what you wanted:  any [word? 
val  lit-word? val]
Is it, or does is-lit-word? do something I'm missing?
[unknown: 5]
22-Feb-2009
[12624x2]
Almost does.  I fixed it up a bit for you to give you more of a match 
to my function here:


 a: func [val][if any [word? val lit-word? val][return true] false]

However, you used lit-word? which was what I was avoiding.
I would have to look at it much more to see how closely it matches 
but via the test posted here it seems to work.
[unknown: 5]
23-Feb-2009
[12626x2]
Nope yours doesn't do exactly what I wanted.
Works for most cases but some important ones it fails on.