Skip to content

Capture unique statement count before doing any transformations #140

Open

Description

@nwinter

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.

Activity

  1. Gazzonyx commented on Feb 13, 2015

    @Gazzonyx

    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>

  2. nwinter commented on Feb 13, 2015

    @nwinter
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions