`@safe` by default. What about `@pure` and `immutable` by default?
Eugene Wissner
belka at caraus.de
Wed Apr 17 07:25:24 UTC 2019
On Tuesday, 16 April 2019 at 21:33:54 UTC, Jonathan M Davis wrote:
>
> pure can be nice when it works, but really basic things like
> I/O don't work if pure is used. You can get around that for
> debugging with debug blocks, but if you have a bunch of code,
> and it turns out that you need to do something in it that isn't
> pure, you'd be screwed unless you go and mark a ton of code
> with impure (or whatever the opposite of pure would be). It's
> not like you can just opt-out in the middle like you can with
> @safe by using @trusted to use @system code.
>
I/O doesn't work in pure code, because I/O isn't pure. And if you
want an impure statement in pure code, you can just cast purity
away same as pureMalloc does it.
pure doesn't make any sense if it isn't default. Plenty of people
for a valid reason don't care about the attributes. As soon as
you have dependencies, you can't mark your own code as pure
because you use some dependencies that may be 100% pure but
aren't annotated as such. It is possible to write pure-annotated
code only if you have not-invented-here-syndrom like me and have
no dependencies.
Pure should either be default or be completely removed, it is
absolutely useless as it is today.
More information about the Digitalmars-d
mailing list