Skip to content

std.traits: provide short alias for FunctionAttributes#4274

Closed
wilzbach wants to merge 1 commit intodlang:masterfrom
wilzbach:shorten_fa
Closed

std.traits: provide short alias for FunctionAttributes#4274
wilzbach wants to merge 1 commit intodlang:masterfrom
wilzbach:shorten_fa

Conversation

@wilzbach
Copy link
Contributor

@wilzbach wilzbach commented May 1, 2016

It's quite common to abbreviate FunctionAttribute with FA - this just makes it official.
As you can see even all the tests use it.
The enum is only used for functionAttributes, e.g. functionAttributes!func & FA.pure_ which already explains the name.

Note: it doesn't try to change the existing name nor deprecate it.

General question: why don't we provide the abstraction hasFunctionAttributes!(func,FA.pure_)? It just seems to me that's what the user wants anyways and bitwise OR-ing seems not really like a Phobos-style.

edit: you even already provide isSafe and isUnsafe ...

@ntrel
Copy link
Contributor

ntrel commented May 2, 2016

why don't we provide the abstraction hasFunctionAttributes!(func,FA.pure_)?

I think we should add it, but maybe taking strings instead:

hasFunctionAttributes!(func, "pure", "@safe")

@JackStouffer
Copy link
Contributor

LGTM

@DmitryOlshansky
Copy link
Member

I think we should add it, but maybe taking strings instead:

Agreed

@wilzbach
Copy link
Contributor Author

wilzbach commented May 4, 2016

Okay will send hasFunctionAttributes after dconf ;-)
Anything that needs to be added here? Should we add a notice somewhere?

@dnadlinger
Copy link
Contributor

I disagree with adding the name. A local alias or with statement works just fine. This stuff is used infrequently enough (I say that having written parts of the related code) that having a two-character name is even more confusing to the end user, because they won't be familiar with it.

@dnadlinger
Copy link
Contributor

Also, as a general thing, the alias would need to be documented (at least using /// ditto) if it's a public name.

@AndrejMitrovic
Copy link
Contributor

Yeah I'm against this too, it just introduces a poorly named global name and will likely cause the dmd spellchecker to often suggest using this symbol.

@DmitryOlshansky
Copy link
Member

Not very popular idea;) going to close it

@wilzbach wilzbach deleted the shorten_fa branch May 7, 2016 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants