-
-
Notifications
You must be signed in to change notification settings - Fork 609
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
fix issue 20915 - add support for is(identifier == version)
#11255
Conversation
|
Thanks for your pull request and interest in making D better, @NilsLankila! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#11255" |
|
Hum... Should |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bar the small implementation note. Please read up on the last 20 years history of why version (!ident) has been rejected time and time again.
I'm aware of that but this is not an attempt to introduce fragments of version expressions sneakily. |
This fills the small gap that existed because `__traits(allMembers)` could return the identifiers of the `VersionSymbol`s defined in the source but there was no way to identify them as such.
But what arguable difference would there be between the rejected |
|
indeed, incredible, I didn't realize at all that the change allowed version operators, although the syntax is a bit verbose. |
People already abuse 'enum + static if' everywhere to work around the absence of version expressions. If allMembers returns versions, there must exist a predicate to filter them out. |
Well I'd probably let @WalterBright weigh in, but my feeling is that you should not be including predefined symbols in the What about @Geod24's question? Is there a use case for |
|
Various versions of this proposal (algebraic combinations of versions) have come up before. We are not doing this. The version system in D is specifically designed to discourage this sort of programming. Besides, if you want to know if a version is a version: |
|
|
|
I've actually been wanting some kind of available version detection to help document possible compile time options. I'll probably work it into my doc generator though since it has its own parser and can look for both version=X and version(X) and at least generate a list. |
O, gosh! This was not a proposal for algebraic combinations at all! We are well aware of your aversion to those. Having an ability to introspect into version identifiers is a completely different and potentially useful feature (Adam has a use for it). The fact that the version-detecting predicate can be abused is completely irrelevant (as I said, people are already abusing 'static if' to work around your ban on version algebra). Side note: language design based mainly on preexisting use cases and personal experience means another dead language in the near future. |
|
there's a callback_API now in DMD if you need things that don't change the semantic... |
|
@adamdruppe see 2efa524. You can propose more callbacks if you need. |
|
@maxsamukha, it wasn't sure, not directly ;] |
Indeed I do have 40 years of experience with the stinky pile of poo that always results from algebraic combinations of versions. |
This fills the small gap that existed because
__traits(allMembers)could return the identifiers of theVersionSymbols defined in the source but there was no way to identify them as such.If accepted spec PR will follow.