Arc Forumnew | comments | leaders | submitlogin
2 points by almkglor 6071 days ago | link | parent

> Attaching too much information to an object leads to serious problems. Think about fixnums: they're usually implemented using 2 bits out of 32 as a type tag. This way you don't have to allocate them on the heap. If you attach an extra information you have to put everything on the heap (very slow for fixnums).

Then let's not attach both types to the same object. pg's implementation creates a new object and attaches the type to that object, leaving the original representation object (type id and all) untouched. Basically we have an annotation type which just contains the attached type and the original object, leaving the type id bits untouched.

> This doesn't handle setting values, but I think that a few macros could solve the problem.

Looks like a job for settable-fn ^^