Mitigating the attribute proliferation - attribute inference for functions
Martin Nowak via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 17 10:36:07 PDT 2015
On Friday, 17 July 2015 at 16:40:56 UTC, Jonathan M Davis wrote:
> On Friday, 17 July 2015 at 12:43:33 UTC, Martin Nowak wrote:
>> =================== Attributes are hardly useful
>> ======================
>
> nothrow and pure - pure especially - help with reasoning about
> code. You actually lose out a fair bit with them IMHO when
> they're inferred, since a lot of their value is derived from
> the programmer knowing for sure that a function is nothrow or
> pure.
But I already know if a function is "logically" pure or not from
what it does.
http.get -> impure
writeln -> impure
swap -> pure
reduce/map/filter/any algo -> pure
containers -> pure (no longer when they use std.allocator?)
gettime -> impure
random -> impure
format string -> pure
fib -> pure (even when using a TLS memorization)
Using global state in a non-obvious way is an indicator for bad
code.
More information about the Digitalmars-d
mailing list