On Fri, Aug 4, 2017 at 11:37 AM, Ulrich Telle <ulrich.te...@gmx.de> wrote:
> Regarding the development of SQLite extensions (UDFs) and using the > pointer-binding interface to communicate between different extensions (AFAIK one of the reasons to introduce the new pointer-binding interface) > the advice to use string literals is certainly good. > I think on the contrary they are more meant to communicate across different UDFs of the *same* extension, and not across extensions. Typical use (IMHO) of the pointer-binding interface is to pass around a pointer to an extension-defined struct from one function to another, from an inner "parsing" function (e.g. taking JSON text and parsing it into a compact and efficient binary representation) whose result is used by another UDF of the same extension that is aware of the custom struct of the "parsed representation" of the JSON and can therefore do more efficient processing. In that context, pointer equality of string literals can be used and relied upon w/o even a strcmp(), and both UTFs are "tightly coupled". The "type-pointer" is simply a "poor man's type system" to guarantee the hard-cast in the receiving UDF is "safe". I'm not even sure you can guarantee uniqueness of string literals across dynamically loaded shared libraries, maybe the runtime linker merges equivalent read-only "static" text from different libs, but that seems very platform-dependent and not something to rely on. It's also probably unusual IMHO for different extensions to share headers to have a common understanding of a custom struct to share at runtime via SQLite pointer-binding in UDFs across these extensions. Not impossible, but seem rather unlikely to me. When you look at it from this lens, then enforcing string literals for the type-pointer makes sense. My $0.02, FWIW. --DD PS: Yes, like others I'd love it if DRH went further into this "custom type" route, even persistent ones longer term with a format change, since pointer-binding with type-string-pointer is going in that direction, at least at runtime-only, and only for "temporaries" across UDFs, but I'm afraid we're a long way from that, and I'm not holding my breadth :) _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users