Why D is annoying =P

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Oct 24 13:09:55 PDT 2012


On Wed, Oct 24, 2012 at 09:50:18PM +0200, Mehrdad wrote:
> On Wednesday, 24 October 2012 at 19:41:42 UTC, Mehrdad wrote:
> >So you can't really write a real program in D, to put it bluntly.
> 
> 
> Case in point: there's no way to tell an arbitrary object/struct to
> give you its hash code.

Huh?  All objects implement toHash(). If the default toHash() doesn't
satisfy you, override it with your own.

You can just use rt.util.hash.hashOf for structs. Use UFCS to make it
callable as toHash(). Implement your own toHash() where hashOf isn't
good enough. Problem solved.


T

-- 
Once bitten, twice cry...


More information about the Digitalmars-d mailing list