-
Notifications
You must be signed in to change notification settings - Fork 53
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
Discourage usage of version defconst in lieu of lm-version #35
Comments
👍 Don't know about the “lieu” thing, though ;) |
👍 |
Here's a possible complication: it's hard to use a constant wrong. I'm kinda worried that someone will end up calling |
@dgutov I've used |
@lunaryorn Me neither. Oh well, maybe it's fine. I don't like the idea of some code reading |
@dgutov How frequently does your code check the Company version?! |
You can always use |
@lunaryorn About never. It's a hypothetical concern. @bbatsov Can or should? |
@dgutov It'd vote for “can”, as in “if you really, absolutely, for some mad reason, need to read your version number every second”… otherwise just stick to |
@lunaryorn Here's a plausible scenario: suppose in 0.9 I change Maybe the style guide should advise about calling |
Depends on how worried one is about the performance. :-) |
@dgutov I'd argue that the backend author should check for a feature rather than a version number—i.e. use |
@lunaryorn Suppose tomorrow, |
@dgutov That'd be a bad change, specifically because it's almost impossible for downstream projects to detect that. If you need to switch to a different interface, you should much rather introduce a new variable, i.e. |
@lunaryorn How about a smaller change, where the new version Suppose we also want to get rid of doing things the old way at some point? Then passing in an extra argument with a special value, etc, is not a very attractive proposition. |
@dgutov I know too little about Company to really discuss this matter. At a last resort, you can always export a constant, i.e. But I stick to my opinion that any backwards-incompatible change which forces downstream packages to make such checks is a bad one. You don't avoid “bad” code with such changes, you're just pushing it to downstream packages. |
Okay then, here's a different question: if we don't consider programmatic use, why have a constant or a function at all? The user can just as well |
@dgutov Provided that the user installed Flycheck with package.el, yes. |
I agree with @dgutov in that you can get into a situation where you need to frequently know another package's version. But my answer to that would be to query this version at load time and stick that in a constant. You can use eval-after-load to ensure this constant stays up to date when the user upgrades. |
Ok, let's prescribe using |
Sounds good to me. Who'll do the actual update? |
See #32
Hopefully that's a correct usage of "in lieu".
The text was updated successfully, but these errors were encountered: