       Re: Re: Types in Mathematica thread

```On 7 Dec 2005, at 13:10, Jon Harrop wrote:

> Andrzej Kozlowski wrote:
>> Yes, but obviously if the discussion is about types in the sense that
>> computer scientists (not me!) use the term, then the type of objects
>> with Head Real in Mathematica is exactly what is known as inexact
>> numbers, or floating point number or floats etc.
>
> or intervals. As I've said, using Head is not a generally useful
> definition
> of "type" in the context of Mathematica code:
>
> Out= Power

Of course I agree with you and I never expressed any support for the
idea that Heads of Mathematica expressions are "types", although they
sometime serve a similar purpose. But this example isn't terribly
convincing since Sqrt is simply converted to 2^(1/2) and is no
different form, say

Plus

or

Sin

etc, etc. None of these expressions will return True if you apply
AtomQ to them. Obviously Heads of non-atomic expressions are not
"types". Whether Heads of atomic expressions can be regarded as types
is more to the point (but I think on the whole it is not a very
useful way of thinking).

>
>> Mathematica does not know it but correctly computes its numerical
>> approximation:
>>
>> NSum[10^(-k!), {k, 1, Infinity}]
>>
>> 0.110001
>>
>> But in any case, all this has nothing to do with "types" in the sense
>> of computer science.
>
> The word "type" means different things to different people even within
> computer science. Some type systems provide numerics in the type
> system,
> even if it is accidental (e.g. church numerals encoded in C++
> templates).

One reason why I think of this whole discussion as being kind of
beside the point, is that it completely ignores what in my opinion is
the most fundamental aspect of Mathematica:  that it is a computer
algebra system. Therefore the most important thing about its
programming language has to be suitability for being used together
with the vast amount of algebra functionality built into Mathematica.
I think the current structure, including the concepts such as
expression, its Head etc, are extremely well suited to this purpose
(and so are the pattern matching and arrays used by Mathematica -that
you mentioned in another posting. Again, they have to be considered
primarily in relation to suitability for a CAS, not for other
purposes).  I expect that they came about by thinking in terms of the
CAS aspect of Mathematica and not in terms the kind of things that
are important in languages like C++, which serve a quite different
purpose.
In particular, if you are developing a programming language for a CAS
system you had better have a good understanding of the complexity of
various algorithms used frequently in manipulating mathematical
expressions. This is why the idea of having a "type" corresponding to
the mathematical concept of a real number seems quite inane to me. Of
course, I am assuming that "types" are supposed to be something that
is checked rather frequently.  The difficulty of deciding whether a
numerical expression represents a real number (as opposed to checking
its Head)  even when it can be done, would grind you programs to a
halt before they got to anything really substantial. This is in an
entirely different game from checking heads of expressions or types
in programs like C.
On the other hand, if one is talking about something meant for a
special purpose, to be used only when you actually want to decide if
something is a real number, then Mathematica's concept of domains
already provides this functionality. It even incorporates "inheritance":

In:=
Assuming[Element[x,Reals],FullSimplify[Element[x,Complexes]]]

Out=
True

In:=
Assuming[Element[x,Rationals],FullSimplify[Element[x,Reals]]]

Out=
True

I do not know whether anybody in computer science would say this
has anything to do with "types", but it certainly has nothing to do
with the function of Heads like Real, Rational or Complex in
Mathematica.

Andrzej Kozlowski

```

• Prev by Date: Re: Re: Re: Types in Mathematica
• Next by Date: Re: Re: Re: Types in Mathematica