toHash => pure, nothrow, const, @safe

Jonathan M Davis jmdavisProg at gmx.com
Mon Mar 12 10:37:56 PDT 2012


On Monday, March 12, 2012 09:14:17 Martin Nowak wrote:
> > So I propose instead a bit of a hack. toHash, opEquals, and opCmp as
> > struct members be automatically annotated with pure, nothrow, and @safe
> > (if not already marked as @trusted).
> 
> How about complete inference instead of a hack?

Because that requires having all of the source code. The fact that we have .di 
files prevents that. You'd have to be able to guarantee that you can always see 
the whole source (including the source of anything that the functions call) in 
order for attribute inferrence to work. The only reason that we can do it with 
templates is because we _do_ always have their source, and the fact that non-
templated functions must have the attributes in their signatures makes it so 
that the templated functions don't need their source in order to determine 
their own attributes.

The fact that we can't guarantee that all of the source is available when 
compiling a particular module seriously hampers any attempts at general 
attribute inference.

- Jonathan M Davis


More information about the Digitalmars-d mailing list