[REBOL] Re: General REBOL questions
From: joel:neely:fedex at: 16-Jun-2002 16:35
Hi, Kemp,
Kemp Watson wrote:
> Great questions, I've been wondering these myself.
>
> Here's a few more:
>
> 1. What's the execution model for Rebol? It seems to combine the
> best of my favorite HLL (Smalltalk) and LLL (FORTH), and I'm
> wondering if it's basically stack-based as in FORTH?
>
Simply think expressions. Forget stacks. They don't help you to
understand REBOL behavior at all. (And I'm was an old FORTH hacker
years ago...)
> Any docs on this? Any docs on in-memory structures, esp 'image ?
>
No. Well-guarded secret, or something.
> 2. Is it purely interpreted, or runtime-compiled (Q1 above may
> answer this if FORTH is indeed the answer :)
>
Neither. When the interpreter LOADs REBOL source, it builds a
structure that is essentially equivalent to what the source says.
There's no assembly-like "byte code" or any such stuff. What you
see is what it gets (conceptually). However, you can also write
REBOL expressions that build up blocks and then cause their
evaluation (as code) in much more interesting ways, since REBOL
doesn't distinguish between "code" and "data". For example:
>> phrase: [print ["has" "letters"]]
== [print ["has" "letters"]]
>> foreach word ["my" "dog" "has" "fleas"] [
[ stuff: copy/deep phrase
[ insert next second stuff length? word
[ insert second stuff mold word
[ do stuff
[ ]
"my" has 2 letters
"dog" has 3 letters
"has" has 3 letters
"fleas" has 5 letters
You can add
print mold stuff
at the end of the body of FOREACH if you want to see what got
build, but the punch line is that conventional notions of
translation don't apply (and are, in fact, harmful to learning
to use REBOL).
Hope that helps!
-jn-
--
; Joel Neely joeldotneelyatfedexdotcom
REBOL [] do [ do func [s] [ foreach [a b] s [prin b] ] sort/skip
do function [s] [t] [ t: "" foreach [a b] s [repend t [b a]] t ] {
| e s m!zauafBpcvekexEohthjJakwLrngohOqrlryRnsctdtiub} 2 ]