[Issue 13397] allow postfix function attributes like 'safe', 'system' and so on without '@'

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Aug 29 02:08:39 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13397

--- Comment #9 from Ketmar Dark <ketmar at ketmar.no-ip.org> ---
(In reply to bearophile_hugs from comment #8)
> (In reply to Ketmar Dark from comment #7)
> Adding contextual keywords to D is an increase in complexity for users too.

aren't existing '@'-attributes are kind of contextual keywords too?

besides, things like '@safe' can be easily misunderstood as 'real' UDAs. so
compiler tend to ignore almost all UDAs except some special ones? but why?
there is no logic behind this execept that "we don't want to add more keywords
to the language".

yet there is perfectly clear context for 'system', 'safe', etc: postfix
function attribute declaration.

the only thing that will break is delegate decls, i.e.:

  void foo (void delegate bar() safe)

this will declare nameless arg instead of declaring arg with name 'safe'. yet i
believe that there is no production/library code that using attr names as
variable names anyway. and this can be fixed by allowing such decl:

  void foo ((void delegate bar() safe) safe)

yes, it's ugly, but the alternative is yet another syntax for function
attributes, smth. like:

  void foo (void delegate bar() [safe] safe)

ah. do not want.


> I think that remembering where to put the @ is simpler for the user.
i believe that user should not even think about this. people kept asking me why
they must write '@safe', but not '@pure'. and in what module '@safe' UDA is
defined.

i'm ok with any decision: either 'all @' or 'nothing @', but the current state
of things is inconsistent and hard to explain to newcomers.

--


More information about the Digitalmars-d-bugs mailing list