MathGroup Archive 2005

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

Search the Archive

Re: Types in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62830] Re: Types in Mathematica
  • From: Jon Harrop <usenet at jdh30.plus.com>
  • Date: Tue, 6 Dec 2005 00:04:24 -0500 (EST)
  • References: <200511191053.FAA16418@smc.vnet.net> <dlp2ci$le$1@smc.vnet.net> <200511200950.EAA04496@smc.vnet.net> <dls4vp$mmc$1@smc.vnet.net> <dm1ak3$i1n$1@smc.vnet.net> <dmjrb8$5u6$1@smc.vnet.net> <dmm2tp$nmo$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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?

Entirely.

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.
http://www.ffconsultancy.com/products/ocaml_for_scientists/chapter1.html


  • 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