Treating the abusive unsigned syndrome

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Nov 25 19:55:17 PST 2008


Sean Kelly wrote:
> == Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
>> (You may want to check your system's date, unless of course you traveled
>> in time.)
>> Russell Lewis wrote:
>>> I'm of the opinion that we should make mixed-sign operations a
>>> compile-time error.  I know that it would be annoying in some
>>> situations, but IMHO it gives you clearer, more reliable code.
>> The problem is, it's much more annoying than one might imagine. Even
>> array.length - 1 is up for scrutiny. Technically, even array.length + 1
>> is a problem because 1 is really a signed int. We could provide
>> exceptions for constants, but exceptions are generally not solving the
>> core issue.
> 
> Perhaps not, but the fact that constants are signed integers has been
> mentioned as a problem before.  Would making these polysemous
> values help at all?  That seems to be what your proposal is effectively
> trying to do anyway.

Well with constants we can do many tricks; I mentioned an extreme 
example. Polysemy does indeed help but my latest design (described in 
the post starting this thread) gets away with simple subtyping. I like 
polysemy (the name is really cool :o)) but I don't want to be 
concept-heavy: if a classic technique words, I'd use that and save 
polysemy for a tougher task that cannot be comfortably tackled with 
existing means.

Andrei



More information about the Digitalmars-d mailing list