-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Force experimental switch to be able to use call/dot operators #16924
Conversation
don't error when defining dot/call operators without experimental switch only check for dot/call operators with experimental switch document call operator and add tests
nimpy, nimsl and react break with these changes |
that's a necessary evil to fix #13034; plus, experimental flags are explicitly not part of stability guarantee (my understanding of experimental flags is: the API can change but the feature is likely to remain available in some form or another) can you list in PR description the list of broken packages, to make it easier to patch them? options to make this PR green:
if callOperator in c.features:
result = overloadedCallOpr(c, n)
=>
if callOperator in c.features or isDefined(c.config, "nimLegacySpecialOperators"):
result = overloadedCallOpr(c, n) (this could be passed in nimble command for such packages or, if that doesn't work, via nim-lang/RFCs#336) |
I can see it can be disruptive for people to have to write the |
failing packages:
@hlaaftana since it's only 3 packages, how about sending 3 PR's to unblock yours? |
I might be missing something, but are you saying you're breaking nim 1.0, some existing code (likely all nimpy users and some nimsl users), to make their code uglier (add experimental pragma wherever needed), just to hide the real issue (which was always there) where a generic |
I claim that dotCalls and dotFields is a useful feature to the extent that many people using it don't find it that unstable. Please prove me wrong. But if we all agree on that, I'd focus the efforts on moving the feature out of its experimental status, by fixing the few remaining issues. It's discouraging to see how much effort you guys are wasting to do the opposite. Regarding the #13034, I'd just fix the spec and call it a day. |
The changes to the experimental switches themselves required no "effort". The point is that it's more intuitive this way, not that people should go through more trouble to use these operators. A lot of people have most likely been adding the experimental switch to their code that uses the operators already (via pragma or command), because that's what's intuitive. I don't know the compiler well enough to find out what causes #6981, and there are bugs like #7777, #15607 which I also don't understand. I can't really deal with pondering the question of whether this feature should be experimental at all, because I personally can't measure the intensity of these specific bugs and predict the timeframe of when they will be fixed or how much they matter or whether or not there are worse bugs. I made this PR despite that, you can blame me for "discouraging" you but I won't care if the operators are made non-experimental and my change isn't made. I can't stop myself from working on remotely potentially helpful changes, but there's seriously no reason for anyone to be "discouraged". Beyond that, it is a mistake to have both the experimental switch and the new tests/docs in the same PR, I can make a new one for the new tests/docs. |
It just occurred to me that dotOperators and callOperators require different experimental pragmas, so I suggest we discuss them as separate features. #6981 is actually about the callOperator, and is somewhat concerning since the feature affects otherwise unrelated code. I myself hit quite a few problems with callOperators previously, so I prefer to avoid them now. On the other hand #7777, #15607 are about dotOperators, but the issues happen within intentional use of those. #13063 is a nuisance indeed, but it's about an error message, as the code is invalid anyway. Therefore I'm asking to reconsider the breakage of dotOperators for little to no reason. For "intuitive way" sake the dotOperators should be working with respective experimental pragma. For backwards compatibility and the fact that one day they will become stable, they should be working without the pragma :).
@hlaaftana no offense, "discouraging" might not be the right word, maybe "sad" would be a better one. Regardless, I value your contributions, please continue, and don't let my words discourage you 🙏 |
I can agree there is not much immediate advantage to these changes. I don't know which is more suitable, perhaps tag as "Postponed", or close so that it may be reopened again, when there is an objective reason to cave in to stricter experimental switches, but it's unlikely to find this reason. Or maybe the new behavior should be opt-in, which would be odd and I don't know if it would prevent only user error and not bugs. |
Sounds good to me
Can you clarify what you mean by that? |
A define or something where |
These experimental operators should be removed from Nim altogether, IMHO. I completely dislike the idea that |
Please tell me more. Just tried |
The highest operators in precedence would be like |
note that i was able to forgo the use of dotOperators in std/wrapnils (see #16996), which leaves us with the use of dotOperators in jsffi/nimpy + friends, where you need some kind of dynamic field access (note: in D, that's essentially
proposalchange precedence rules so that when true:
import macros
macro deb(a: untyped): untyped =
echo a.lispRepr
deb a.b.c # parsed as: (a.b) . c
deb a.b.?c # parsed as: (a.b) .? c
deb a.?b.c # parsed as: a .? (b.c) (DotExpr (DotExpr (Ident "a") (Ident "b")) (Ident "c")) under this rule, let j = (a: 1, b: 2).toJson
j.?bar.?baz there are 2 reasonable ways to do that: proposal A1we defined dot like operators as operators starting with proposal A2we defined question-mark operators as operators ending with so that notethat leaves with remaining cases where dotOperators could still be useful, namely type punning, where we change an API transparently (more so than via a EDIT: see RFC nim-lang/RFCs#341 |
I like your "proposal A1" much better. We should implement it and see what it breaks. :-) |
I think these proposals warrant RFCs. They can be treated independently as they are not mutually exclusive.
As breaking as it already is, this PR would be a good start for this (if the feature is removed, defining the operators should be a nop, it's really only at callsites where the feature can cause problems). Even though I don't support removing the operators, I think it's still worth seeing what people think; maybe say deprecate for now instead of remove.
I guess this is pretty uncontroversial (I actually thought you couldn't start operators with About PR: I don't see a need for another commit for now, will let merge conflicts pile up until and if CI can be expected to pass |
=> RFC nim-lang/RFCs#341 |
I'll save most of it for the RFC (if I can muster up the courage), but I think this doesn't go far enough and dot operators need a much bigger rethink. |
Closing, doesn't seem this will improve anyone's experience at the time. |
closes #13034
This changes the behavior of call and dot operators, they can now be defined without an experimental switch without erroring, but the switch must be turned on in order to use them. This means that before, an operator could be defined with one
push experimental
, and then to use it you did not need an experimental switch, but now it's the opposite.This is going to break a fair amount of code, they will need to turn on the experimental switches like done in some old tests in this PR, but the errors should not be too uninformative and it's better to deal with this than silently having experimental operators available.
Currently breaks tests for:
EDIT: refs callOperator, dotOperators (more searcheable)