On Fri, Mar 09, 2012 at 02:01:01PM -0800, Walter Bright wrote: > On 3/9/2012 1:54 PM, H. S. Teoh wrote: > >Still chugging away at implementing AA's in druntime proper, I reviewed > >the code for methods that can be marked pure but ran into a major road > >block: getHash() is not marked pure. That makes a lot of AA methods > >impure, that could, and probably should, be marked pure. > > > >Is it possible to make TypeInfo.getHash() pure? AFAICT there's no good > >reason why it shouldn't be pure. Am I missing something? > > It should be const, pure, nothrow, @safe.
Hmph. I tried to make getHash() const pure nothrow @safe, but found that in some places it calls toHash() which isn't marked const pure nothrow @safe. So I fixed that as well, then found that toHash() calls toString() which isn't pure, nothrow, nor @safe... and before I knew it, I was deep into marking a *lot* of druntime functions (as perhaps they *should* be), and then I ran into this: src/object_.d(648): Error: function object.TypeInfo_AssociativeArray.next () is not callable using argument types () src/object_.d(648): Error: function object.TypeInfo_AssociativeArray.next () is not callable using argument types () src/object_.d(759): Error: function object.TypeInfo_Class.info () is not callable using argument types () src/object_.d(1334): Error: cannot uniquely infer foreach argument types src/core/runtime.d(483): Error: cannot uniquely infer foreach argument types make: *** [lib/libdruntime-linux32.a] Error 1 I'm not sure how to proceed from here. A related question though: have we implemented automatic propagation of attributes like pure/nothrow/etc., yet? Just wondering if I can just modify the base class and have the attributes propagate, or I have to search for every override of every affected function in order to mark them (as I have been doing -- just wanted to make sure it isn't for nothing). T -- It won't be covered in the book. The source code has to be useful for something, after all. -- Larry Wall