Dropping the NATIVE/BODY Feature From Core

Rather early on in hacking around on Rebol I had an interesting (to me) idea.

It seemed that quite often, native functions were really nothing that couldn't be done in usermode...they were just written as natives because they were supposed to be faster. I thought it might be interesting to preserve or define the original code as part of the native spec.

A very simple example, this explains how DID might be made to force any value to its truthy status by applying NOT twice:

//
//  did: native/body [
//
//  "Synonym for TO-LOGIC"
//
//      return: "true if value is NOT a LOGIC! false, BLANK!, or NULL"
//          [logic!]
//      optional [<opt> any-value!]
//  ][
//      not not :optional
//  ]
//
REBNATIVE(_did_)  // see TO-C-NAME
{
    INCLUDE_PARAMS_OF__DID_;

    return Init_Logic(D_OUT, IS_TRUTHY(ARG(optional)));
}

There's A Good Idea In Here...But

Expressing what natives do as usermode code is a good way of understanding what that code does.

However it needs to be tested or it's doomed to get out of sync. I had the idea that natives would swap out their behavior for their usermode equivalents every now and again and we'd run the tests. But if you're actually intercept calls to natives and implement them with other natives, what happens when two of them use interdependent definitions?

This Testing And Documentation Doesn't Belong In The Core

It's nice to be able to see it there with the native spec. But compiling these bodies into the executable just makes it unnecessarily bigger.

There's a lot of other testing and documentation enhancements that are higher priority, and the complexity incurred from this feature suggests dropping it.

It was a neat idea from a long time ago that has been superseded in importance by many other neat ideas. :slight_smile:

3 Likes