On Tuesday, 11 December 2018 at 12:57:03 UTC, Atila Neves wrote:
@property is useful for setters. Now, IMHO setters are a code
stink anyway but sometimes they're the way to go. I have no
idea what it's supposed to do for getters (nor am I interested
in learning or retaining that information) and never slap the
attribute on.
Imagine you have void delegate() prop() and use the property
without parentheses everywhere then suddenly m.prop() doesn't
call the delegate. So it's mostly for getters and should be used
only in edge cases, most code should be fine with optional parens.
inout
Template this can accomplish the same thing and is more useful
anyway.
"Everything is a template" is a spiritual successor to
"everything is an object" hype :)
Returning a reference
It’s practically pointless.
See
https://github.com/dlang/druntime/blob/master/src/core/stdc/errno.d#L66
Also AFAIK alias this doesn't dereference pointers automatically,
and retaining the pointer may be not desirable.
I think there’s a general consensus that @safe, pure and
immutable should be default.
I can agree there are at least 5 people holding that firm belief,
but that's hardly a consensus.
I’ve lost count now of how many times I’ve had to write @safe
@nogc pure nothrow const scope return. Really.
If immutable was default, wouldn't you still need to write const
attribute everywhere, and @nogc, and nothrow? Strings are like
the only relevant immutable data structure (and they are already
immutable), everything else is inherently mutable except for use
cases with genuine need for immutability like a shared cache of
objects.