[REBOL] Re: [datatypes] action! vs. native! vs function!
From: g:santilli:tiscalinet:it at: 23-Nov-2003 11:18
Hi Joel,
On Saturday, November 22, 2003, 11:15:09 PM, you wrote:
JN> Does anyone know the difference between NATIVE! and ACTION!
JN> types?
The list of the types in the ANY-FUNCTION! pseudo-type is:
native!
action!
op!
function!
As you say, FUNCTION! values are the one we can create. ACTION!,
OP! and NATIVE! values are "built in" in the interpreter, and we
cannot create them.
The distinction between the three is a little subtle, and is
mainly an implementation issue I think (IIRC, Carl once said this,
too). NATIVE!s are the "primitives", as you say. ACTION!s are
those primitives that are actually "methods" (to use terminology
from other languages) in other datatypes; that is, while for a
NATIVE! there is one C implementation inside REBOL, for an ACTION!
there can be more than one implementation; for example, PICK on a
PORT! is different from PICK on a BLOCK!. While doing what you
call "particle physics", I and others also discovered this:
>> second :print
== none
>> second :pick
== 40
While NATIVE!s do not have a "second" element, ACTION!s do, and it
is a number; our guess (and I think it was more or less confirmed
by RT) is that that number is actually an index in a function
table for the datatype.
Finally, OP!s are the infix version of ACTION!s (I'm not sure, as
I haven't checked, if OP!s only map to ACTION!s or if they can map
to NATIVE!s too). Being of type OP! is not enough to be treated as
an infix operator by REBOL, as this is the only place where the
function interpreter is "keywordized"; that is, only a number of
pre-defined words can be OP!s.
HTH,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/