Implement `and` and `or` optimizations as ast passes rather than different macroexpansions.

Description

`and` and `or` have optimizations that are applied at macroexpansion rather than as ast-passes.

This prevents application of this type of optimization at more places and also introduces complications for code that attempts to use the macroexpanded code. An example of this is async 91.

Depends on

Environment

None

Activity

Show:
Daniel Sutton
June 30, 2020, 4:57 AM

Patch attached. Would love feedback. Couple things that had to change:

  • macroexpand and and or into let* form so i could attach metadata to it. Didn’t see a good way to get metadata from the let form into the ast.

  • when creating ast nodes from an existing ast node, i grabbed the form and threw it into analyze. Not sure if there’s a better way to do this?

  • i’m sure i’m dropping line/col information on the floor. Need to think about that more

I intend to add tests for this just wanted initial feedback if possible. I have two failing tests on master at the moment when running clj -A:test:run-tests but not sure if that’s the best way to run the tests.

David Nolen
August 23, 2020, 5:39 PM

I started looking into this but I think it will have to wait until after the next release. I’d like to this after a bit of refactoring to break apart the analyzer into smaller namespaces to allow for writing passes in a more modular way without continuing to dump everything into the analyzer ns.

Assignee

David Nolen

Reporter

Daniel Sutton

Labels

None

Approval

None

Patch

None

Priority

Minor
Configure