Natives vs. Actions vs. Mezzanines

If you're a bit curious to learn some deeper aspects to how REBOL is built, it's practical to know the difference between native functions and mezzanine functions.

When you use the SOURCE function on another function, sometimes, you'll get the source code for that function and other times, you won't. Natives don't output source code:

>> source insert
insert: native [
{Inserts a value into a series and returns the series after the insert.}
series [series! port! bitset!] "Series at point to insert"
value [any-type!] "The value to insert"
/part "Limits to a given length or position."
range [number! series! port! pair!]
/only "Inserts a series as a series."
/dup "Duplicates the insert a specified number of times."
count [number! pair!]
]


Well, what is a native? Natives are the basic method for doing something. They are written in C, and therefore you can't see its source code in the console, because the function is part of the very core of REBOL and can't be altered directly.

Mezzanine functions are built of natives or a combination of natives and other mezzanine functions.

In the case of the native function INSERT, it's used to build other functions, like APPEND.

If you look at the output (too long to paste here) of:
>> source append

...you'll find the INSERT function inside it.

This is one of the reasons that REBOL has so many functions despite having such a small executable!

You can see the complete list of native functions, by calling up:
>> help native!

You can do that, because native functions have their own datatype, native!, while mezzanine functions are of type function!.

A third type called action! also exists, which is similar to natives, except that they are internally implemented differently as methods, where natives are more like normal C functions. For you, the REBOL programmer, there's no real need to know the difference between actions and natives.

Thanks to John Niclasen and Gabriele Santilli with helping with this blog post via AltME!
|