How about "auto" parameters?

Timon Gehr timon.gehr at gmx.ch
Tue Jun 7 09:24:22 PDT 2011


foobar wrote:
> KennyTM~ Wrote:
>
> > On Jun 7, 11 20:11, foobar wrote:
> > > I agree with Ary above and would also like to add that in the ML family of
languages all the variables are also default auto typed:
> > > E.g.:
> > > fun add a b = a + b
> > >
> > > 'add' would have the type ('a, 'a) ->  'a and the type inference engine will
also infer that 'a must provide the + operator.
> > > I feel that this is more natural than having a dedicated function template
syntax.
> > > Better yet, instead of auto parameters, just make parameter types optional
(as in ML) and let the compiler generate the template.
> > >
> >
> > I don't think HM type inference (ML, Haskell) support implicit cast,
> > i.e. you can't write { int a; double b; a + b; } anymore.
>
> As I've answered to Andrei, this is a good thing(tm) - it's a feature.
> I don't know if it has anything to do with the HM algorithm itself, but it is
one of ML core principals. ML is strictly typed unlike C (glorified assembly).
> [snip.]

Assembly does not have implicit conversions ;). I wonder how much code would get
broken if D changed to strict typing. I seldom rely on implicit casts.


Timon


More information about the Digitalmars-d mailing list