Edi Weitz opined:
On Fri, 17 Feb 2006 13:21:14 -0500, "Dan Muller" s8ctxw402@sneakemail.com wrote:
I'm thinking that a cleaner solution might be an optional target-type argument to BOX, although that requires RDNZL to pick the conversion needed.
Yeah, maybe. The advantage of my workaround is that you don't have to call BOX explicitely because RDNZL calls it as needed. So, you should be able to just INVOKE a method with arguments like 3.4d2 and RDNZL will convert it to a System.Single automatically.
True. Although as you pointed out, you can run into trouble when both single and double floats are wanted by the same method. I think that this would work in general, because .NET would implicitly up-convert a single to a double again; but at that point some precision would be lost unnecessarily. One can also imagine situations where a method taking a single is overloaded by a method taking a double, and the latter becomes completely inaccessible -- just the opposite of what you'd want to have happen if your Lisp uses only doubles!
Also, I wonder about similar problems that could arise involving other types.
Or perhaps even more generally, a way to call a method of an object or type with some arguments, but get the return value without conversion, boxed if necessary. With that, I could have called System.Convert.ToSingle and gotten a boxed Single back. Perhaps calling it INVOKE-RETURNING-CONTAINER.
But you'd have to do this for PROPERTY and FIELD as well. And you'd lose the advantages of the special reader syntax. A bit messy.
Again, true, but I'm thinking here mainly of low-level mechanisms with which one could address any similar problems, with precise control. How to make them convenient requires some more thought.