jbr / sibilant

Just another compile-to-js LISP-like language
https://sibilant.org
MIT License
386 stars 47 forks source link

optional support for es6 spread operator/rest parameters? #93

Open riatzukiza opened 8 years ago

riatzukiza commented 8 years ago

Currently the compiler produces some strange looking application operation when the spread operator is used, and always uses "this" as the first arguement to the operation, which is not always what is intended, take for example:

(this.foo.method ...array-of-stuff)
;; -> this.foo.method.apply(this,arrayOfStuff);

This is obviously not what was intended to be done, and normally means that to use this feature one has to destructure the array outside of the context of the functions execution if the desired behavior is to occur.

It should not be difficult to get the above to translate instead to

this.foo.method(...arrayOfStuff);

As it would just be a direct symbol insertion.

It should be possible for me to do this for my self with a macro at least, but documentation on macros is sparse, and basicly non-existant for reader macros, which is how I imagine this would need to be done.

If I could at least be pointed in the right direction to create a macro that would override the "..." syntax that exists already, this would be appriciated.