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

sweet.js macros #5

Closed
1 task done
KiaraGrouwstra opened this issue Jun 25, 2016 · 0 comments
Closed
1 task done

sweet.js macros #5

KiaraGrouwstra opened this issue Jun 25, 2016 · 0 comments
Labels

Comments

@KiaraGrouwstra
Copy link
Owner

why: DRY, boosts expressiveness. if that sounds like "just syntactic sugar", that's what programming languages do.

  • integrate with webpack
  • integrate with jspm
  • lambda shortcut
  • check punctuation list for this macro
  • wanted macros (doable):
    • immutable mutations (_: x = x |> _.blah(pars), Imm: x = x.blah)
      • actually less bad in store already
    • Store/Redux action: action(DEL_TODO, deleteTodo(id)) -> export const DEL_TODO = 'DEL_TODO'; export deleteTodo = (id) => ({ type: DEL_TODO, id })
    • getter: problem is macros can only be in statement/expression position; workarounds:
      • use assigned methods with initial babel pass?
        • can these really do get/set?
      • use class macro, add assigned methods to ditch babel?
    • setter: see getter.
    • pattern matching
      • old implementation used infix macros, huge code (if only few macro bits?)
      • combine comb macro's matching with destructuring (casep) and matching of predefined values
        • iterate over literals/variables (if declared check match, otherwise assign)
        • one try-assign pass for the check, another after to assign and return the result
        • if/unless guards
  • macros needing infix:
    • pipe
    • elvis: ?. / ?.[] / ?.['fixed', variable]
    • reverse assignment (<-)
    • await -- old macro
    • fakeAwait: from let a = fakeAwait PROM; to let a; PROM.then(x => { a = x; }); flushMicrotasks();

BLOCKED BY:

  • Sweet.js infix
  • TS support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant