How about "auto" parameters?
foobar
foo at bar.com
Tue Jun 7 11:58:56 PDT 2011
Walter Bright Wrote:
> On 6/7/2011 9:01 AM, foobar wrote:
> > Also ML has only two types: integers and floating point.
>
> That changes everything. C has 11 integer types and 3 floating point types,
> which makes it ugly (and surprisingly buggy) to be forced to explicitly cast
> when doing mixed type expressions.
Personally I think that all those types are redundant but regardless I don't think that int -> long is the same as int -> double.
you can leave the size promotion rules untouched (implicit) since it's equivalent to upcasting. integral -> floating can however cause loss of precision and hence should be IMO explicit.
E.g. in pseudo D:
auto add (a, b) { return a + b; }
int a = ...;
long b = ...;
auto c = add (a, b);
// type for both parameters and return type is long
double d = ...;
auto e = add (a, d); // IMO, compile time error
More information about the Digitalmars-d
mailing list