Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

match constants based on value as well as syntax #43

Open
josharian opened this issue Jul 16, 2019 · 2 comments
Open

match constants based on value as well as syntax #43

josharian opened this issue Jul 16, 2019 · 2 comments

Comments

@josharian
Copy link

e.g. gogrep 5 should match 2+3 and also the first part of 5+7.

@josharian
Copy link
Author

and also, usefully, gogrep 100 should match 100 and 1_0_0. this will help one of the concerns raised near the end of golang.org/issue/28493

@mvdan
Copy link
Owner

mvdan commented Jul 16, 2019

I think the simplest way to implement this would be a command which tries its best to simplify or resolve the current expression. It would turn 2+3 into 5, pkg.One + pkg.Two into 3, concatenate strings, and so on.

Initially this would only work on constants, but it would be good if it also worked on "partial" constants. For example, nonConst * 10 * 10 could be simplified into nonConst * 100.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants