Idea: partially pure functions
Steven Schveighoffer
schveiguy at yahoo.com
Thu May 1 09:11:20 PDT 2008
"Bruno Medeiros" wrote
> Yes, if g() is not pure, then the compiler will not check if v points to
> global data or not. Thus we cannot guarantee that calling "f(v)" will not
> change global state. But so what?
> That doesn't mean we shouldn't allow it. It just means such call may have
> side-effects, and the compiler should threat that as a normal function
> call (make no particular pure optimizations). Thus "partially" pure: pure
> in some contexts, impure in other contexts.
I re-read this and I see what you are proposing.
I can see how that would work, but you would definitely need another
keyword. Any time a developer sees the pure keyword, he will assume he
doesn't need to worry about thread issues. However, a partially pure
function would be subject to thread issues when not called from a pure
function.
I still think it would be a worthwhile feature to have, as it would save on
implementing lots of functionality more than once.
BTW, forget my other post, we were arguing about totally different things.
-Steve
More information about the Digitalmars-d
mailing list