Re: Types in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg62836] Re: Types in Mathematica
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Tue, 6 Dec 2005 00:43:03 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 12/5/05 at 3:37 AM, hattons at globalsymmetry.com (Steven T. Hatton) wrote: >I have come to realize that there are (or appear to be) certain >limitations as to what can be done with type conversions in >comparison to how they are used in C++. For example, in C++ it is >possible to create type conversion operators which will be invoked >according to the parameters accepted by a function. For example, >you might have some kind of counter object which automatically >converts to an integer when passed as a variable of integer type. >I don't believe I could do something similar with Mathematica. For >instance, if I have a type Vector3D[x,y,z], I don't see a way of >getting that to convert to a List[x,y,z] when passed to an >arbitrary function taking a List as an argument. I don't understand your comment here. I can easily do the following: In[3]:= a = Vector3D[x, y, z]; b = List @@ a; Head[b] Out[5]=List Given this, why shouldn't Apply (@@) be considered a "type" conversion in this context? -- To reply via email subtract one hundred and four