-
-
Notifications
You must be signed in to change notification settings - Fork 741
Fix Issue 5359 - std.traits : isDelegate returns false on a delegate #1164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cc @9rnsr |
To allow both types and names to be passed to the template. |
Yah, but that doesn't explain the bug. |
Yeah it should have only accepted types to begin with. |
I honestly don't know now whether it should be fixed to allow expressions like |
@andralex : A variadics parameter with Most of std.traits templates (e.g. I think that most of std.traits templates should work for both type and symbol. In the view of library user, they works as like "generic predicate for language entities", and in library implementation, the behaviors for both kinds can be distinguished. |
@9rnsr: got it. I'd change the name of isDelegate to isDelegateType but I think now we must live with it. If we add now isDelegateSymbol or isDelegateObject that's a slippery slope - we'll need to add such traits for /everything/. For example we have isIntegral, so for consistency we'd need to add isIntegralValue. And so on... So I'd say let's stick with types in traits. |
I don't get why you want to stick with types in traits. There is no rational reason to prohibit symbols. Also this implementation works (I used that approach for fullyQualifiedName):
|
I said it: to avoid duplication everywhere. |
@andralex That is hardly an excuse for standard library. Imagine new comer who meets a limitation in generic code that makes no sense (delegates can be both types and symbols after all, we call all of them "delegates") - he may conclude that either language is not powerful enough to do it, or library implementors are bad, and I believe neither of those has place. Code duplication is an issue to solve, not a reason to avoid allowing meaningful interfaces, Better to discuss what can be done to avoid code duplication so this can be "done right". Obvious way can be to generate wrapper boilerplate via mixin, but that feels a bit dirty. Another approach that comes to my mind is to allow types as a parameters to typeof so that is(typeof(T) == T). |
@Dicebot: wasn't an excuse. There are traits of types and traits of values. Being a delegate is a trait of a type. I think that's the correct design. No need to change anything. |
(c) http://dlang.org/type.html#Delegates If official docs call symbols delegates, it is natural from user to expect from std library to match them. |
I understand. But then consider:
This is just colloquial description for the fact that |
@andralex I can understand your desire to keep things minimal (and it is your decision to make for sure) but than documentation needs to be tightened and official position stated explicitly somewhere easy to notice. After all, it is an only official documentation about the language and the lib, every single point of ambiguity there should be considered as a bug. This is one of the reasons comparison with C++ standard docs style keeps popping up. |
We should be consistent with the rest of the relevant traits: |
I am now sorry I allowed those to go through. |
I agree. We could separate them into those which take a Type and ones which take an alias, and add a deprecation stage for the alias ones? |
I'm taking over this one. |
http://d.puremagic.com/issues/show_bug.cgi?id=5359
I recall Kenji introduced the variadics. What was the intent here?