digitalmars.D - Can getHash be made pure?
- H. S. Teoh (9/9) Mar 09 2012 Still chugging away at implementing AA's in druntime proper, I reviewed
- Walter Bright (2/8) Mar 09 2012 It should be const, pure, nothrow, @safe.
- H. S. Teoh (25/35) Mar 09 2012 Hmph.
- Walter Bright (3/21) Mar 09 2012 For 2.059, yes.
- Martin Nowak (3/24) Mar 09 2012 Bottom-up instead of top-down?
- Walter Bright (2/3) Mar 09 2012 both.
- Jacob Carlborg (4/8) Mar 10 2012 Hard to find somewhere to start?
- H. S. Teoh (16/23) Mar 10 2012 [...]
- =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= (4/25) Mar 10 2012 That sounds like the best possible strategy.
- Dmitry Olshansky (4/25) Mar 11 2012 At least @safe 'leak' could be temporarily plugged with @trusted.
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? T -- The most powerful one-line C program: #include "/dev/tty" -- IOCCC
Mar 09 2012
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.
Mar 09 2012
On Fri, Mar 09, 2012 at 02:01:01PM -0800, Walter Bright wrote:On 3/9/2012 1:54 PM, H. S. Teoh wrote: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 WallStill 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.
Mar 09 2012
On 3/9/2012 5:15 PM, H. S. Teoh wrote: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 1Yeah, I know, it's viral. Can't do it piecemeal.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).For 2.059, yes.
Mar 09 2012
On Sat, 10 Mar 2012 03:18:59 +0100, Walter Bright <newshound2 digitalmars.com> wrote:On 3/9/2012 5:15 PM, H. S. Teoh wrote:Bottom-up instead of top-down?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 1Yeah, I know, it's viral. Can't do it piecemeal.
Mar 09 2012
On 3/9/2012 7:21 PM, Martin Nowak wrote:Bottom-up instead of top-down?both.
Mar 09 2012
On 2012-03-10 04:21, Martin Nowak wrote:On Sat, 10 Mar 2012 03:18:59 +0100, Walter BrightHard to find somewhere to start? -- /Jacob CarlborgYeah, I know, it's viral. Can't do it piecemeal.Bottom-up instead of top-down?
Mar 10 2012
On Sat, Mar 10, 2012 at 06:21:08PM +0100, Jacob Carlborg wrote:On 2012-03-10 04:21, Martin Nowak wrote:[...] Not that hard. Just search for toString in Object, and add qualifiers to it, then compile. You'll find a ton of errors caused by propagated qualifiers. Fix those, and you'll find more, ad nauseaum. After a few iterations of this, I found myself labelling almost every method in Object, TypeInfo, and a whole bunch of other places. I'll need to sit down someday to properly and thoroughly do this. Currently my git branch is uncompilable due to a couple o' nasty places, and I'm ready to throw in the towel. :-( Maybe I'll just finish up the actual AA implementation first, then come back to revisit pure/nothrow/const/ safe after the code itself is actually working. T -- There's light at the end of the tunnel. It's the oncoming train.On Sat, 10 Mar 2012 03:18:59 +0100, Walter BrightHard to find somewhere to start?Yeah, I know, it's viral. Can't do it piecemeal.Bottom-up instead of top-down?
Mar 10 2012
On 10-03-2012 18:48, H. S. Teoh wrote:On Sat, Mar 10, 2012 at 06:21:08PM +0100, Jacob Carlborg wrote:That sounds like the best possible strategy. -- - AlexOn 2012-03-10 04:21, Martin Nowak wrote:[...] Not that hard. Just search for toString in Object, and add qualifiers to it, then compile. You'll find a ton of errors caused by propagated qualifiers. Fix those, and you'll find more, ad nauseaum. After a few iterations of this, I found myself labelling almost every method in Object, TypeInfo, and a whole bunch of other places. I'll need to sit down someday to properly and thoroughly do this. Currently my git branch is uncompilable due to a couple o' nasty places, and I'm ready to throw in the towel. :-( Maybe I'll just finish up the actual AA implementation first, then come back to revisit pure/nothrow/const/ safe after the code itself is actually working. TOn Sat, 10 Mar 2012 03:18:59 +0100, Walter BrightHard to find somewhere to start?Yeah, I know, it's viral. Can't do it piecemeal.Bottom-up instead of top-down?
Mar 10 2012
On 10.03.2012 21:48, H. S. Teoh wrote:On Sat, Mar 10, 2012 at 06:21:08PM +0100, Jacob Carlborg wrote:At least safe 'leak' could be temporarily plugged with trusted. -- Dmitry OlshanskyOn 2012-03-10 04:21, Martin Nowak wrote:[...] Not that hard. Just search for toString in Object, and add qualifiers to it, then compile. You'll find a ton of errors caused by propagated qualifiers. Fix those, and you'll find more, ad nauseaum. After a few iterations of this, I found myself labelling almost every method in Object, TypeInfo, and a whole bunch of other places. I'll need to sit down someday to properly and thoroughly do this. Currently my git branch is uncompilable due to a couple o' nasty places, and I'm ready to throw in the towel. :-( Maybe I'll just finish up the actual AA implementation first, then come back to revisit pure/nothrow/const/ safe after the code itself is actually working. TOn Sat, 10 Mar 2012 03:18:59 +0100, Walter BrightHard to find somewhere to start?Yeah, I know, it's viral. Can't do it piecemeal.Bottom-up instead of top-down?
Mar 11 2012