[M3devel] in favor of mixed operators..

Jay K jay.krell at cornell.edu
Mon Jan 18 04:37:30 CET 2010


I am mostly a believer in static types.

 

Though there sure is an interesting place in

languages like C#, C++, ML, where the compiler

is *obligated* in many contexts to deduce static

type and in which it really isn't very controversial.

 

This leads to, for example, qsort that can "easily"

inline the comparison function and beat C.

 

C# has this nifty "LINQ" stuff where to actually

have the programmer state the static types

would be quite onerous.

 

 

A similar scenario is "expression templates" in C++.

Where you have a + b * c / d and the types

of a, b, c, d are a variety of vectors/matrices,

and there are no actual intermediate computations done,

just one inner loop, because the type of the overloads

doesn't hold an intermediate result but rather sort of "directions"

on how to proceed. See Todd Veldhuzien's fascinating work.

http://en.wikipedia.org/wiki/Expression_templates

 

 

The dynamic type proponents do have strong arguments in some situations:

 - You are going to throw out the code soon anyway, sometimes.

 - You have to run it, test it, and that somewhat substitutes for whatever checks the "compiler" makes.

 

 - Jay





 
> Date: Sun, 17 Jan 2010 21:21:35 -0500
> From: hendrik at topoi.pooq.com
> To: m3devel at elegosoft.com
> Subject: Re: [M3devel] in favor of mixed operators..
> 
> On Sun, Jan 17, 2010 at 05:58:33PM -0800, Mika Nystrom wrote:
> > 
> > Jay I think the following paragraph is important and demonstrates why
> > this article is perhaps less relevant to Modula-3:
> > 
> > When you write a function implementing a numeric algorithm (for example,
> > calculating the phase of the moon) you typically expect the arguments
> > to be specified as floating point numbers. However, since Python doesnt
> > have type declarations, nothing is there to stop a caller from providing
> > you with integer arguments. In a statically typed language, like C,
> > the compiler will coerce the arguments to floats, but Python does no
> > such thing the algorithm is run with integer values until the wonders
> > of mixed-mode arithmetic produce intermediate results that are floats.
> > 
> > Mika
> > 
> > Jay K writes:
> > >--_671e4a34-689a-4d86-98d3-1f8935f7844b_
> > >Content-Type: text/plain; charset="iso-8859-1"
> > >Content-Transfer-Encoding: quoted-printable
> > >
> > >
> > >http://python-history.blogspot.com/2009/03/problem-with-integer-division.ht=
> > >ml
> > >
> > >
> > >He argues that for a "high level" language=2C of course
> 
> He identifies python as a high-level language. His arguments about what 
> a high-level language should do are based on python's absence of static 
> typing. Thus he comes to his conclusion, having identified the concept 
> of "high level" with "no static typing". Presumably he thinls that 
> types are an inconvenience inflicted by the desire for run-time 
> efficiency. Many people believe this, failing entirely to notice that 
> static typing is a powerful tool in the pursuit of correctness.
> 
> -- hendrik
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100118/3ce6d925/attachment-0002.html>


More information about the M3devel mailing list