Arc Forumnew | comments | leaders | submitlogin
Pervasive keyword args for arc
4 points by akkartik 2539 days ago | 5 comments
This is why my repo's been unstable lately: it now has pervasive (python-inspired) keyword args. Observe:

  > (def foo(a b) (cons a b))
  > (foo 3 4)
  (3 . 4) ; expected
  > (foo :b 3 4)
  (4 . 3) ; whoa!
I've also changed the syntax for optional args:

  > (def foo(a ? b nil) (cons a b))
  > (foo 3)
Optional args come after a '?' and must explicitly provide a default. (alternatives:

I find the best documentation for this feature is test cases:

Let me know if anybody sees bugs or other issues. I've tested it on both news.arc and readwarp and everything seems to work.

1 point by akkartik 2539 days ago | link

This seems like a good place to checkpoint my thinking on nil.

aw ( and waterhouse ( have spoken out strongly for nil to be a sym. I've chosen to leave it as () and without a type, primarily because that's the convention in the underlying PLT scheme. It just doesn't seem important enough to change (I'm still seeking counter-examples).

I'm starting to view arc not as a language but as a thin membrane over an underlying lisp. A leaky abstraction, one that has yielded for me both a gateway to ease into lisp programming, and a more elaborate vocabulary for thinking about lisp macros (code walkers and so on). But the underlying lisp is still doing 90% of the heavy lifting, and rather than try to hide that fact away I seek now to aggressively embrace the leakiness.

I now try to think of it as programming in PLT scheme or SBCL, rather than arc. I've been growing an SBCL implementation for arc based on waterhouse's code ( and when I use that version nil is a sym because that's how it is in common lisp. Surprisingly enough both views are equally easy to hold, and also to switch rapidly between.


3 points by jazzdev 2533 days ago | link

I'm starting to view arc not as a language but as a thin membrane over an underlying lisp.

When I first read this I thought, "But what about arc on top of other languages beside scheme?" Then I realized I started writing Jarc because I wanted a thin membrane over Java. Interesting way to think about it.


1 point by akkartik 2533 days ago | link

Yeah I started thinking this way after spending some time atop sbcl. I'll release that at some point. It's quite surprising how little code you need to build the arc transformer when you choose the right lisp implementation, when you're not going against the grain of the underlying lisp.


1 point by evanrmurphy 2539 days ago | link

I like this. Bravo. It's neat!

I'm also intrigued by your whitespace pattern:

  (def foo(a b) (cons a b))  ; no space between foo and its args
I'd always seen it one of these ways:

  (def foo (a b) (cons a b))

  (def foo (a b)
    (cons a b))
Omitting that space helps my eye to logically group things, and it could help make lisp look a bit more familiar to anyone coming from C-style syntax.


1 point by akkartik 2539 days ago | link

Yeah I've been using that unconventional layout in my code. (I started out as a C programmer.)

But it is unconventional, and I didn't want to change it in the arc repo itself, so let me know if you see it in any non-test files.