-
Notifications
You must be signed in to change notification settings - Fork 208
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
Make it easier to do same-type transforms #51
Comments
My comment on #17 (comment) proposed the following rule:
That rule would be mostly backwards compatible (at least it affects no usages inside Google) and I can't imagine why anyone would want the behavior that it would prevent). I know you disagree slightly and believe it should be "since the last non-(Transform or TypeAssertion or Indirect) step", but I like the simplicity of my proposed rule. In practice, I don't think the difference is going to matter. If we accept that proposed rule change (implementation in #29 has been pending for a while), then you won't need |
The proposed rule seems fine to me, if somewhat distressingly subtle. Wouldn't a simpler approach to rounding time.Times be to use a Comparer instead of a Transformer? |
@neild I have the comparer, but I wouldn't call it simpler than using a transform (assuming transforms behave in the new way @dsnet is describing). The transform only has to think about one value, but a comparer has to think about two. In this case it's a one-line difference because |
\cc @bcmills are you okay with making the policy change from #51 (comment)? |
Yep. |
I wanted to treat
time.Time
s as rounded to the nearest microsecond. I first tried a transform, but it got into an infinite loop (as advertised). I had to add a FilterPath in front of it. This turned a one-line option into a ~10-line option.So how about adding something like this to cmpopts:
I know we discussed this earlier, but I still don't really understand why this isn't the default behavior of transformers.
/cc @bcmills
The text was updated successfully, but these errors were encountered: