natefaubion / sparkler

Native pattern matching for JavaScript
MIT License
693 stars 18 forks source link

Provide a "wavy" arrow as a macro? #15

Closed vendethiel closed 8 years ago

vendethiel commented 10 years ago

Something like ~> ? That'd be like function { }:

doSomething(~> {
  String ...
})
yuchi commented 10 years ago

probably this

macro ~> {
  rule {} => { function }
}

could do the job.

natefaubion commented 10 years ago

@yuchi yes, the macro itself is really simple. The problem is macro modules can't import other macro modules currently, so you'd have to put that in any file that wants to use it. You might be able to do it manually using the low level API for loading macro sources. There's an ongoing PR for ES6 module support in sweet.js that solves this problem.