[Date Index]
[Thread Index]
[Author Index]
Re: Types in Mathematica
*To*: mathgroup at smc.vnet.net
*Subject*: [mg62644] Re: Types in Mathematica
*From*: "Steven T. Hatton" <hattons at globalsymmetry.com>
*Date*: Wed, 30 Nov 2005 00:06:40 -0500 (EST)
*References*: <dme722$i89$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Bill Rowe wrote:
> On 11/27/05 at 2:40 AM, hattons at globalsymmetry.com (Steven T.
> Hatton) wrote:
>
>>A related question follows from this example:
>>In[n]:=Information[Plot3D]
>
>>Plot3D[f, {x, xmin, xmax}, {y, ymin, ymax}] generates a
>>three-dimensional plot of f as a function of x and y. Plot3D[{f,
>>s}, {x, xmin, xmax}, {y, ymin, ymax}] generates a three-dimensional
>>plot in which the height of the surface is specified by f, and the
>>shading is specified by s.
>
>>Note there is no specification of /what/ "f", "x", "xmin", "xmax",
>>"y", "ymin", and "ymax" should be. What difficulties exist which
>>prevent the specification of the "types" of these parameters?
>
> It isn't clear to me as to what point you are trying to make here.
I don't know that I was really trying to make a point. I was really asking
a question. The question does hint at a more general idea, but addressing
the question might serve to address the more general notion of function
signatures and parameter types. There are "type" mechanisms in Mathematica
such as NumericQ, NumberQ, etc.
I am inclined to think of type systems in other programming languages as a
means of communicating to both the compiler, and the human reader of a
program the intent of the programmer. In a strongly typed language, it is
often possible to leverage function signatures, and return value types as a
means of creating skeleton documentation. Often such skeleton
documentation is sufficient for presenting the API to a programmer without
any additional "human" contribution. For examples, see Doxygen, and
JavaDoc.
http://www.stack.nl/~dimitri/doxygen/
http://java.sun.com/j2se/javadoc/
> The description returned by Information isn't intended to be a full
> documentation of the function. Basically, all it provides is a minimal
> description showing arguements. But a clickable link is also provided
> which allows you to quickly access more complete documentation which
> includes usage examples and links to further documentation.
Information[] doesn't actually provide that hyperlink, but ? and ?? will.
Nonetheless, the additional documentation does not provide a more detailed
"type" specification than does Information[]. At least not in the case of
Plot3D. What I guess I'm really asking is whether there is a technical
reason that makes such a type system impractical in Mathematica. The only
"primitive" type that exist in terms of function return value in
Mathematica appears to be provided by the NumericFunction attribute. But
it seems to me,that attribute can "lie" about what the function actually
returns.
>>What about the notion of "return values"? For example Plot3D
>>returns a SurfaceGraphics object, but the documentation resulting
>>from Information[Plot3D] does not mention that. Why?
>
> Why should that be included?
Perhaps for completeness. If it were part of the formal definition of the
function, it might be valuable in validating programs and finding errors.
OTOH, there may be technical considerations which make such a type system
impractical. I am fully aware that the inertia of previous design choices
can be a valid argument against introducing such changes at this point.
> Again, the purpose of Information is to give
> a short description not full documentation. Clearly, what is omitted from
> any shortened description is somewhat arbitrary. I would think most of the
> time Plot3D is used to generate a graphic that is not further manipulated.
> Assuming this is true, it seems reasonable to provide a list of the
> argumenents in a shortened description but not much detail as to output
> objects.
Is it reasonable to speak in terms of a well defined return type in
Mathematica? One place such a feature might be useful is in creating
support tools which aid a programmer. Such tools may not be as
advantageous in Mathematica as they are in programming languages intended
for application development.
--
The Mathematica Wiki: http://www.mathematica-users.org/
Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html
Math for the WWW: http://www.w3.org/Math/
Prev by Date:
**Re: Re: Package development**
Next by Date:
**Please completely ignore my previous posting**
Previous by thread:
**Re: Types in Mathematica**
Next by thread:
**extract from list and keep track**
| |