> My main concern, after giving it some more thought, is that you can't > easily make the FFI check the pointer type, unless you enforce that > pointer tags are somehow either compile-time constants, or also stored > in some global that's directly accessible to the FFI. There should be > a low-overhead and simple type check, which is also statically > expressible, otherwise one might just as well define their own > foreign type with conversion procedures, so, a record type with the > pointer inside it like this [...]
You could use a simple global counter for tags and map this numeric tag to something else (like symbols) through a global table. The real meaning of the tag is only interesting in Scheme code (introspection, printing, error messages), but not on the FFI-level. The one situation where this gets complicated is when serializing, but then you could serialize the full tag value, together with the pointer (whether serializiing pointers is useful or not is another question, of course, but it may be needed sometimes.) felix _______________________________________________ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers