Re: Types in Mathematica thread

*To*: mathgroup at smc.vnet.net*Subject*: [mg62833] Re: Types in Mathematica thread*From*: Jon Harrop <usenet at jdh30.plus.com>*Date*: Tue, 6 Dec 2005 00:04:57 -0500 (EST)*References*: <dmp9na$hi2$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Kris Carlson wrote: > 1. Everything is an expression, which is wonderful in its simplicity. Thus > since everything is of the form head[body], everything is typed in at > least one way via the head, and everything can be tested for its type, eg, > with Head[expr]. Trying to define the type of a Mathematica expression as the result returned by Head is not a great idea because the result of Head is itself an arbitrary expression. For example, this definition of "type" becomes useless in the presence of currying. > ... > 5. Mathematica excels in pattern-matching, Mathematica certainly provides a lot of functionality in its pattern matcher but pattern matchers in other languages provide many benefits not found in Mathematica: 1. Exhaustiveness checking 2. Redundancy checking 3. Well-defined performance For example, the conventional implementation of a function to compute the length of a list has quadratic complexity in Mathematica: f[{}] := 0 f[{h_, t___}] := 1 + f[{t}] However, this may get fixed in the future. > 7. Downvalues are "default" function structures, or "common" functions, or > "built-in function" structures, or "broadest class" functions. Upvalues > are "special case" functions, or "user-defined" functions / modifications > of built-in or default functions, or "narrow-case" functions, or > "context-dependent" functions. (This latter is especially important for AI > and for a general understanding of the universe.) The fact that Mathematica distinguishes between up- and down-values is really incidental (a historical artefact). So I think you're over-analysing it. > What is overloading? Mathematica does not provide functions such as > plusII[ i1_Integer, i2_Integer], plusRR[ r1_Real, r2_Real ], plusRI[ > r_Real, i_Integer }, and so forth. You would not be using it if it did > [because it would be a big pain in the rear like we find in other > "strongly typed" languages--KWC]. Some strongly typed languages, yes. I still use other languages that do separate ints and floats into separate types. > The standard arithmetic operations are overloaded: they work with data of > many different types and perform conversions as necessary. Without a definition of "type", such statements have no value. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/ocaml_for_scientists/chapter1.html

**Follow-Ups**:**Re: Re: Types in Mathematica thread***From:*Daniel Lichtblau <danl@wolfram.com>