Skip to content
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

Capture unique statement count before doing any transformations #140

Open
nwinter opened this issue Feb 12, 2015 · 2 comments
Open

Capture unique statement count before doing any transformations #140

nwinter opened this issue Feb 12, 2015 · 2 comments

Comments

@nwinter
Copy link
Contributor

nwinter commented Feb 12, 2015

Proposed in this thread. This would let each parser do a sane job of counting how many real statements are used, instead of getting all crazy with trying to reverse-engineer what was once a meaningful statement from the transpiled output.

@Gazzonyx
Copy link

Originally I hadn't considered branches, but I think the most common case is probably an if/else or if/else if/else where the block that contains the most statements is probably the branch doing the work.

Of course, with loops where n is relatively large and you're expecting the common case to be a no-op and the exception being where you do work, that algorithm falls on its head. Also, I have to consider that this is geared a lot towards those who are newer to programming and their code very well might not reflect what my gut says is the common case.

But I think it's still possibly more workable than trying to reverse engineer translated code if you accept a wider margin of error. Anything else that I can think of involves injecting code into the emitted javascript to increment counters.

<thinkingOutLoud>
OTOH, that approach would allow for all languages to be supported if they can be translated to JS, but I suspect there would still be edge cases that are different for each language that would have to be dealt with on a per language basis and then we're back at square 1.
</thinkingOutLoud>

@nwinter
Copy link
Contributor Author

nwinter commented Feb 13, 2015

We can just count all unique statements; it's really not important whether they get run or not. The incentives are still there to minimize the amount of code you write.

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

No branches or pull requests

2 participants