Replacing HANDLE! with Extension Types

I've made big progress on resurrecting the concept of "Extension Types".

The first implementation of them was creaky and I was just learning how the system would have to be shaped and redesigned to support them. But now they're starting to work, and work really well. This means we can basically have tons of datatypes and not break a sweat.

I Think They Can Completely Replace HANDLE!

The idea behind HANDLE! historically was just that you had some piece of data... like a pointer... and you needed a type to put it in.

In R3-Alpha it was basically an alias for INTEGER! such that you didn't confuse it for thinking it was an integer. Also, since integers were always signed, it meant you weren't representing pointers with negative numbers.

So when you did something like open an ODBC database, you'd get a HANDLE!. If you created a statement in that database, you'd get a HANDLE! representing the ODBC statement. If you were doing FFI and you were talking about some memory address, you'd get a HANDLE!.

Beyond that you had no information to distinguish them. Ren-C added the concept of putting a pointer to a function inside the handle that represented what would be called when the GC was garbage collecting it... and that could serve as something of an identity. This way the handle you passed ODBC could say "oh, the cleanup function is the cleanup function for ODBC Statements... hence the handle must be an ODBC statement..."

Screw all that. Just make ODBC-STATEMENT! and ODBC-DATABASE! extension types, and the world is a better place.

Can Extension Types Replace PORT! ?

It seems to me that PORT! has many of the same problems as HANDLE!. It was just this black box.

Extension types are handling this much better, and I think they're going to be taking over!

1 Like