MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Types in Mathematica

  • To: mathgroup at
  • Subject: [mg62830] Re: Types in Mathematica
  • From: Jon Harrop <usenet at>
  • Date: Tue, 6 Dec 2005 00:04:24 -0500 (EST)
  • References: <> <dlp2ci$le$> <> <dls4vp$mmc$> <dm1ak3$i1n$> <dmjrb8$5u6$> <dmm2tp$nmo$>
  • Sender: owner-wri-mathgroup at

Steven T. Hatton wrote:
> I believe most people here will agree that Mathematica is not a strongly
> typed programming language.

Actually, one can productively say that Mathematica is a strongly typed
language because it has only one type (expr). Indeed, this is an important
observation about Mathematica and separates it from many other languages.

> What would a type system in Mathematica be?

Anything you want.

> What might be gained by having a type system in Mathematica?

Performance, correctness.

> What might be lost?

Simplicity, brevity, clarity.

> To what extent /does/ Mathematica have a type system?

Results of the "Compile" function do some run-time type checking (e.g. for
machine-size real input). Many other built-in functions check the "types"
of their arguments but that is slightly different to conventional dynamic
type checking.

> To what extent can a type system be implemented within Mathematica without
> modifying the language?


Because Mathematica is a rewrite system, it is comparatively easy to write
interpreters and compilers in it (compared to C, for example). As a type
system and, more importantly, a type checker is part of a
compiler/interpreter, these can be written in Mathematica.

> How would a type system in Mathematica be similar to one in another
> language?

You could write a type checking function to type check Mathematica programs.
This could mimic an ML-like type system, for example.

> How would a type system in Mathematica differ from one in another
> language?

It would be optional because it is not fundamental to the language.

To improve performance, the use of a more refined type system could be
entirely automated and invisible to the user.

To improve correctness, the type system must be exposed to the user in the
form of static type errors.

Dr Jon D Harrop, Flying Frog Consultancy Ltd.

  • Prev by Date: Re: Extracting just the value of the variable from the result of Solve/NDSolve
  • Next by Date: Re: Types in Mathematica, a practical example
  • Previous by thread: Re: Types in Mathematica
  • Next by thread: Re: Types in Mathematica