Mike Loolard wrote:
> 
> 2) How do you create custom types ?
> I am talking of a way to emulate the typedef behavour in C ?
> How would you go to create an "enum" type in REBOL ?
> 

joel gave you a very in-depth answer, I'll proceed with a different perspective.

in most languages, you have a very strict syntax which identifies types, statements, 
functions, reserverd words, etc, etc.

in rebol you can throw all that thinking away.  Like joey said, there is NO syntax in 
rebol.

this being said, creating your own statement which initializes a series of words (in c 
you'd call these variable names) is quite easy.  although, they won't be datatype per 
say, because rebol lets you manage code as if it where content, you can easily create 
your own "statements" here is a quick func which will simulate your enum statement in 
C.

enum: function [word-block][counter][
        counter: 0
        foreach word word-block [
                set in system/words word counter
                counter: counter + 1
        ]
]

; you can then use your enum "statement" like so:

enum [null eine zwei drei vier funf]

print eine
==1
print vier
==4


if you want you can also call protect on the new words, if you want to be sure their 
value never gets overiden in your global namespace, but usualy, that is not a good 
idea unless you really need to.



joey's analogy of rebol being clay really makes sense.  you can "Shape" rebol to be 
what you need it to be.  in most other language, you have to use the contstructs they 
give you, however cool they are, you still are tightly bound to them. 



HTH!


-MAx
-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to