Hello everyone,
I was wondering if there is a way to test if the implementation we are running on can create weak pointers. In the case of Flexichain (and I think this might be a possibility for other libraries) using weak pointers isn't completely required, but it's preferred to avoid leaking memory slowly.

Currently Flexichain has its own 15-line function that creates weak pointers, which is very similar to that of trivial-garbage, except that it returns the provided value if it cannot create a weak pointer (after warning the user at load-time). We'd like to replace this with a call to trivial-garbage:make-weak-pointer to avoid duplication, but we also want to fall back to just returning the value as previously mentioned; I could do (or (tg:make-weak-pointer value) value) as it will fall through to returning nil, but that feels icky and then I need to figure out a similar trick for weak-pointer-value. 

If there isn't such a test, I have written a trivial implementation, simply gathering all the #+ forms to choose a constant to return: https://github.com/nodefunallowed/trivial-garbage/blob/master/trivial-garbage.lisp#L105 Again, this is probably good for a class of programs that uses weak pointers in a way that isn't strictly necessary but very useful.

Thanks very much.