jbr / sibilant

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

Why there is no `let` macro out of box? #75

Closed 11111000000 closed 9 years ago

11111000000 commented 10 years ago

Imo let is more natural than var concept.

jbr commented 10 years ago

There is now a let keyword in ECMAscript, so perhaps the let macro should compile to that. Otherwise, what would (let (a 1 b 2) (console.log a b)) compile to? I see several alternatives:

//this isn't very different from (scoped (var a 1 b 2) (console.log a b))
(function() {
  var a = 1, b = 2;
  console.log(a, b);
})();
 // this is not particularly readable, but is concise
(function(a, b) {
  console.log(a, b);
})(1, 2);

But in general, the strength of having such a flexible language defined in terms of macros is that it should be very easy for people to package up "flavors" of sibilant macros and publish them as npm packages. Without any change to sibilant, users could (import "let-macros") and then have access to whatever redefined or extended macros you want.

jbr commented 10 years ago

@11111000000 Did this address your issue? Does anyone else have comments on this? I'm going to close this as stale if there's no additional feedback.

11111000000 commented 9 years ago

ok, thanks, think that answer is helpful