Positive

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Oct 4 22:55:43 PDT 2008


Graham St Jack wrote:
> I prefer your suggestion of ufloat/udouble/ureal to Positive, and I
> would definitely use these. I already use unsigned integer types a
> LOT, even more than signed ones.
> 
> Have you thought how (and if) auto-casting would work?

I did, and it would work. The problem is there's no precedent for it.

double x;
...
auto y = sqrt(x);

That will do a runtime check and throw if x is negative. That's 
unprecedented for an implicit cast, so I was thinking of defining a
universal "unsigned" template function that does the check:

auto y = sqrt(unsigned(x));

> As far as template instantiation goes, my feeling is that the "." is
> too easily confused with method invocation. I know you are trying to
> make them look more similar, but for we mere mortals that don't do
> much template programming, we need something that stand out more.
> Something less alarming than "!" would be ok, so long as there was
> ONLY ONE way.

I agree that in the end there should be only one man standing. And the 
reference to mere mortals makes me think we should bring the mountain to 
them instead of them to the mountain. I know, lame metaphor.


Andrei



More information about the Digitalmars-d mailing list