Arc Forumnew | comments | leaders | submitlogin
1 point by akkartik 4165 days ago | link | parent

I've been reading http://subjectivelisp.org/wiki/Differences_with_Nu and noticed that your definition of let permits multiple variables. I'm curious if you considered the use case of destructured binding:

  (let (a b) (list 3 4)
    ..)


2 points by Pauan 4165 days ago | link

Shameless plug: this is how Nulan handles it:

  # Single binding
  w/var foo = 5
    ...
  
  # Multiple bindings, like "withs" in Arc
  w/var foo = 5
        bar = 10
    ...
  
  # Look, ma, destructuring works
  w/var {foo bar} = {1 2}
    ...

-----

1 point by akkartik 4165 days ago | link

Nice. What is the s-exp for each?

I've considered replacing with and just keeping the serial version. But I like encouraging myself to not worry about ordering as much as possible.

-----

2 points by Pauan 4165 days ago | link

Only supports a single variable currently, though it would be cool to support multiple:

  w/each x = {1 2 3}
    prn x
Nulan's macro system is not only hygienic, but it plays very nicely with customizable syntax too, as you can see in the definition of "w/each":

  $mac w/each -> {('=) x y} body
    w/uniq i len
      w/complex y
        'w/var len = y.length
           for (var i = 0) (i ~= len) (++ i)
             w/var x = y[i]
               body
And a couple more examples:

  # Simulating a `for` loop using a `while` loop
  $mac for -> init test incr body
    '| init
     | while test
         | body
         | incr

  for (var i = 0) (i < 10) (++ i)
    prn i


  # Simulating a `do..while` loop using a `while` loop
  $mac do -> body {('while) test}
    'while %t
       | body
       | if ~ test
           &break;

  var i = 0
  do
    | prn i
    | ++ i
    while (i < 10)
P.S. Sorry for hijacking the thread, but I've been itching to talk about Nulan, since I've made so much progress on it (as shown by the many commits on Github).

-----