Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Crippled reflection in Rebol?

 [1/6] from: xapwing:gma:il at: 26-Mar-2007 22:54


Hi all, when I tried to find out the type of several words, I stumbled upon a few problems: when I do:
>> value? :*
== true but:
>> value? :/
** Syntax Error: Invalid word-get -- : ** Near: (line 1) value? :/ Also, when I do:
>> type? '*
== word! but:
>> type? '/
** Syntax Error: Invalid word-lit -- ' ** Near: (line 1) type? '/ So, in Rebol "everybody is equal, but some are more equal than others"... ;-) This way there is no consistency and retrieving such elementary properties can be a pain. Or, what very well might be the case, an I missing something obvious? Another thing is that I tried to obtain the type for a rebol word which I have stored in a string!; example:
>> x: "purple"
== "purple" I found a way to obtain the type in a little bit awkward way:
>> do rejoin ["type? " x]
== tuple! Is there an easier / better way to do it? TIA ! -- Met vriendelijke groet / with kind regards, Arie van Wingerden Yes I'm old. Old enough to remember when the MCP was just a chess program! Dumont (A character in the film TRON) Doneer gratis op / donate free at http://www.voedselhulp.nl & http://www.freedonation.com Kijk op / look at http://www.dorcas.nl & http://www.dorcas.net

 [2/6] from: hallvard:ystad:babelserver at: 26-Mar-2007 23:04


Dixit Arie van Wingerden (22.54 26.03.2007): [...]
> >> type? '/ > ** Syntax Error: Invalid word-lit -- '
<<quoted lines omitted: 4>>
>can be a pain. >Or, what very well might be the case, an I missing something obvious?
Guess this has got something to do with '/ being both a function and the start of a path...
>Another thing is that I tried to obtain the type for a rebol word which I >have stored in a string!; example:
<<quoted lines omitted: 4>>
> == tuple! >Is there an easier / better way to do it?
type? do x == tuple! Normally, I would want to LOAD the string, but since LOADing this string returns a WORD, DOing does just fine. It also works on other values:
>> g: "15"
== "15"
>> type? do g
== integer!
>> yy: to-string now
== "26-Mar-2007/23:01:35+2:00"
>> type? do yy
== date! Regards, HY

 [3/6] from: Izkata::Comcast::net at: 26-Mar-2007 16:08


Here you go:
>> value? to-get-word "/"
== true
>> type? to-word "/"
== word!
>> X: "purple"
== "purple"
>> type? get to-word X
== tuple! And, of course, the to-* functions can have interesting results sometimes - such as, a word! with a space in it:
>> to-word "foo bar"
== foo bar
>> type? to-word "foo bar"
== word! On Mon, 2007-03-26 at 22:54 +0200, Arie van Wingerden wrote:

 [4/6] from: chris-ross::gill::com at: 26-Mar-2007 22:34


On Mar 26, 2007, at 4:08 PM, Izkata wrote:
>> value? to-get-word "/"
== true
>> type? to-word "/"
== word!
>> X: "purple"
== "purple"
>> type? get to-word X
== tuple! -- You can also use get/any to avoid a no-value error:
>> type? get/any to-word "/"
== op!
>> type? get/any to-word "purple"
== tuple!
>> type? get/any to-word "foo"
== unset! - Chris

 [5/6] from: lmecir::mbox::vol::cz at: 27-Mar-2007 10:47


Arie van Wingerden napsal(a):
> Hi all, > > when I tried to find out the type of several words, I stumbled upon a few > problems: > > when I do: > >> value? :* > == true >
although it looks "normal", it is not exactly what you think. The VALUE? function is designed to handle words as its help string suggests, so my guess is, that you actually wanted something like: value? '* ; == true or value? first [*] ; == true
> but: > >> value? :/ > ** Syntax Error: Invalid word-get -- : > ** Near: (line 1) value? :/ >
this example does not have a good sense IMO, see above
> Also, when I do: > >> type? '*
<<quoted lines omitted: 3>>
> ** Syntax Error: Invalid word-lit -- ' > ** Near: (line 1) type? '/
in this case you can use: type? first [/] ; == word!
> So, in Rebol "everybody is equal, but some are more equal than others"... > ;-)
<<quoted lines omitted: 10>>
> Is there an easier / better way to do it? > TIA !
-L

 [6/6] from: xapwing::gmail::com at: 27-Mar-2007 14:16


Thanks to you all! A lot of useful info there. Rebol doesn't stop to amaze me. Grtz, Arie

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted