Hi all!
[EMAIL PROTECTED] wrote:
>The current discussions of weirdnesses, idiosyncracies, and so forth
>related to
>scope, garbage collection, protection via USE, etc. are all verging around the
>same space. With no disrespect intended to Carl or anyone on the Rebol team
>(they're certainly tracing historical mistakes, Cf. McCarthy's early probs.
>nailing the scope issue in Lisp) there is at lease one good system, very
>similar
>in many ways to Rebol, from which they could steal liberally: Scheme. It's
>lexically scoped, has first-class closures which are in essence a
>stronger, more
>formal block, a fundamental symbol / object distinction, and GC... *very*
>similar to Rebol indeed, but with a unified formal approach to scope, GC,
>and so
>on. It's a beautiful, simple, and powerful language that has never really
>gone
>mainstream due to its Lisp-like legacy and syntax, which most folks don't
>grok.
>IMO, Rebol could easily be the Scheme for the masses... but every little
>idiosyncracy and gotcha -w- scope, GC, and so on will create adoption
>friction.
JB, you may not be familiar with REBOL history, but the 1.x
versions of REBOL were based on Scheme semantics. REBOL was
much slower back then, and had a larger executable, both the
result of using the Scheme model. I've got a copy of 1.0.3
for Windows if you're curious.
I have been using Scheme for about 8 years now and have done
my own Scheme compiler/interpreter, so I know what you mean
when you sing its praises. REBOL and Scheme are more similar
than you realize, though. For the most part you can simply
translate from Scheme to REBOL with no loss of functionality,
and more speed too. For example:
First-class closures:
- Scheme: (set f (lambda (x) x + 1)) or (define (f x) x + 1)
- REBOL: f: func [x] [x + 1]
Symbol/Object distinction:
- Both: 'symbol object
Lexical scoping (other than in functions):
- Scheme: (let ((x 1) (y 2)) x + y)
- REBOL: use [x y] [x: 1 y: 2 x + y]
The "main" REBOL dialect implements lexical scoping as its
default behavior, just in a different way than Scheme does.
Scheme (interpreted) has dynamic binding, so all variables
are mapped to values in a lexical context, but symbols are
bound to variables at runtime, at every reference. With
REBOL the symbols are bound to variables once, before the
code is executed. Direct binding makes REBOL more similar
to compiled Scheme, even when it is interpreted.
Fluid variables: Scheme needs this as a hack to get around
the limitations of lexical scoping. REBOL doesn't need them
because direct binding is much more powerful.
Macros: With Scheme, code only looks like data, so it needs
a macro mechanism. With REBOL, code IS data, so there is no
distinction needed between macros and other functions. The
REBOL functions for code-building are more powerful too.
Language and execution model:
- Scheme: Lisp-like lexically scoped language (conceptually)
built on a continuation engine - pretends to be stack-based
for implementation efficiency, at least if you avoid call/cc.
- REBOL: Unique, two-level language (dialects on data language)
built on a Forth-like stack engine for efficiency that Scheme
only gets after heavy optimization (sometimes not even then).
Tail-recursion: Scheme has it (side effect of the continuation
engine, hacked when stacks are used); REBOL dropped it when it
switched to 2.x for efficiency reasons (whoops!). I guess you
have to use REBOL's extensive iterative functions instead.
Continuations: Scheme has them (base of its execution model);
REBOL dropped these too when it switched to a stack engine.
Continuations don't make much sense with a stack engine - they
only work well when the execution model is continuation-based.
If you can't refactor your code to use callbacks or some such,
you probably don't understand it well enough to be programming
with continuations. Take a look at Icon - its goal-directed
evaluation beats continuations any day of the week.
Numerics: REBOL is comparable to most Schemes, but that is only
because most Schemes don't implement the entire capabilities of
the Scheme standard. Most people don't do much numerics in an
interpreted language anyway, but I miss bignums :(
List manipulation and data structures: REBOL does all of what
Scheme does, and usually does it faster. The map functions are
missing, but easily replaced, like replacing this:
(set y (map (lamda (x) x + 1) '(1 2 3)))
with this:
y: copy [1 2 3]
forall y [change y (first y) + 1]
y: head y
or if you really want map, you can make it easily yourself.
Other changes (mostly to factor out some recursion) are just
as easy to do. Most data manipulations are easier in REBOL.
String manipulation and parsing: Throw your Scheme code away -
you'll never regret it. The incredible REBOL parse dialect gets
better every day - you'll wonder how you got by without it in
primitive languages like Scheme :)
As for unified, formal approaches, well Scheme wins there.
REBOL is easily as unified as Scheme, but Scheme has been
formalized to death - no contest. Hey Gabriele, do you want to
help turn our context argument into a formal paper, tutorial
or something? Any one else up for papers?
By the way, there is nothing about REBOL's GC problem that is
inherent in its execution model. It can be fixed, and it can
be avoided easily until it is fixed. As GC bugs go, I've seen
much worse than that. I'd still like it fixed, though :(
Over all, I've found REBOL to be better at almost everything
Scheme is supposed to be good at, with few exceptions. Scheme
has been a great tool for years, but REBOL is much better.
>Unsolicited $0.02,
>
>jb
I think I've put in at least $0.04, no less unsolicited :)
Brian Hawley