> From: <[EMAIL PROTECTED]>
> > Hello, REBOLers !
> >
> > Just for a bit of "syntactic sugar" :-)    :
> > Is it possible to define new infix operators ?
> > I tried :
> >
> > >> ||: make op!  ... etc.
> > ** Script Error: Cannot use make on datatype! value
> >
> > It would be a very nice feature (a la Prolog, or C++) to define (or
> > "overload") some operators.
> >
> > Cheers:
> > Geza Lakner MD
>
> Interesting idea.  In fact, I've been pondering the chicken and egg
argument
> about REBOL in terms of whether the operators are natively prefix or
infix.
> My guess is that they are defined as prefix, like most of REBOL, and then
> REBOL uses a dialect in essence in evaluating expressions as infix.
>
> It is "easy" to define new operators as prefix.  For example:
>
> ||: :or
> || 1 2 ; yields 3
>
> I know that this is not quite the syntactic sugar that you're looking for,
> but it demonstrates REBOL's flexibility, nonetheless.
>
> Maybe if it's not "top secret", or something, RT can put my mind to rest
> over whether the infix notation is just a type of dialect.  I.m really
> curious about this one.
> --Scott Jones

From: "Larry Palmiter"
> Hi Scott
>
> Interesting speculation, and there were early statements from RT that the
> infix form was translated to prefix by the interpreter before evaluation.
> But I think there has been some optimisation along the way that
invalidates
> "pure" models of the behavior. Here is an interesting test (450 MHz PII):
>
> >> t: now/time loop 10'000'000 [3 + 4] now/time - t
> == 0:00:08
> >> t: now/time loop 10'000'000 [+ 3 4] now/time - t
> == 0:00:12
> >> t: now/time loop 10'000'000 [add 3 4] now/time - t
> == 0:00:12
>
> Notice that "+" used as an infix operator is at least 1.5 times faster
than
> when used as a prefix operator. The prefix "+" and "add" execute in the
same
> time. If there were a simple translation from infix to prefix, the infix
> form would be slower.
>
> Cheers
> -Larry

Most excellent, Larry.  That was a clever approach,  (it would have been
even *more* clever if I had thought of it ;-), and I agree with your
conclusion.  Now maybe I can sleep again at night knowing that it is infix
before prefix (a curious play on words, if I must say so).  Thanks.

--Scott Jones

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to