Arc Forumnew | comments | leaders | submitlogin
5 points by malisper 3652 days ago | link | parent

I just want to start off by saying that you may want to show your professor Clamp[0]. It is a project I have been working on and my goal is to implement as many features from Arc as possible in Common Lisp. Most of the references are to code for Clamp.

Differences between Arc and Common Lisp.

Lisp-1 vs Lisp-2: Arc is what's know as a Lisp-1. That means that procedures are really just procedure objects stored in regular variables (ie "len" is just a variable in Arc, whose value is a procedure that can calculate the length of a sequence). Common Lisp on the other hand is a Lisp-2. This means that it is possible to have a procedure "len" (which can calculate the length of a sequence), and a variable "len" (which may be the length of a particular sequence), without any conflicts even though they are both named "len". Some people prefer a Lisp-1 because it makes code simpler and shorter (you never have to use something analogous to Common Lisp's funcall), and some people prefer a Lisp-2 because then don't have to deal with conflicts between procedures and variables having the same name.

Special Syntax: Arc provides a special kind of syntax called ssyntax, short for special syntax. Each ssyntax provides a shorter way for writing a common pattern. For example a&b is short for (andf a b), a:b is short for (compose a b), a.b is short for (a b), and a!b is short for (a 'b). The last two are extremely useful for accessing into data structures which I explain more in the next section. I just want to point out that it is possible to write a version of ssyntax in Common Lisp[1][2][3]. There are some issues that come up because Common Lisp is a Lisp-2.

Data Structure Access: In Arc, you can use data structures as procedures. Calling a list with an argument will get that place in the list [ie (x 5) will get the element at index 5 in x.]. Note that this is why the shorthand a.b and a!b are so useful. Anarki takes things a step further by allowing a programmer to define how to coerce types to other types and therefore allows one how to define what happens when you call an arbitrary object as a procedure. Common Lisp provides nothing like any of this.

Procedure Arguments: There are some differences in how procedures are defined and called between Common Lisp and Arc. Arc provides an easy way to destructure and argument. For example it is possible to a procedure to get the first element of a list as just (def car ((a . b)) a). It is possible to implement this feature in Common Lisp[4][5]. There are some slight differences with syntax to define a procedure that has optional arguments or rest arguments. Another difference between the two is that Common Lisp provides something called "keyword arguments". Keyword arguments provide a way of having arbitrary ordered optional arguments. For example I wrote a procedure "group"[6], which does roughly the same thing as both pair and tuple in Arc. There are some versions of Arc that provide keyword arguments (Anarki is not one of them).

Reader Macros: Arc provides a shorthand for lambda functions of one argument (Anarki has extended this feature to provide any number of arguments). It is possible to write [+ _ 5] instead of writing out (fn (_) (+ _ 5)). Common Lisp provides something much more general called "reader macros". Reader macros allow a programmer to design new syntax. While I won't go in depth about reader macros, they allow a programmer to create new syntax within Common Lisp. Using brackets as a shorthand for lambda functions is possible to implement with reader macros.

Module System: Most versions of Arc do not provide a module system.

Debugger: One of the most important differences between the two is Arc's lack of a debugger. AFAIK, the only way to debug Arc code is to include print statements throughout your code (using print statements is actually a really effective way to debug code), and there are ways of creating more advanced debugging techniques through the use of macros. Common Lisp provides a full debugger along with something called "restarts"[7]. The Common Lisp restart system is extremely useful, although it should be possible to implement something similar in Arc.

IDE: Arc does not have any sort of IDE, whereas Common Lisp has Emacs/Slime. I wrote about some of the features Slime provides here[8].

[0] https://github.com/malisper/Clamp

[1] https://github.com/malisper/Clamp/blob/master/tests/ssyntax-...

[2] https://github.com/malisper/Clamp/blob/master/experimental/s...

[3] https://github.com/malisper/Clamp/blob/master/experimental/s...

[4] https://github.com/malisper/Clamp/blob/master/tests/destruct...

[5] https://github.com/malisper/Clamp/blob/master/experimental/d...

[6] https://github.com/malisper/Clamp/blob/master/src/list.lisp

[7] http://en.wikibooks.org/wiki/Common_Lisp/Advanced_topics/Con...

[8] https://news.ycombinator.com/item?id=8474161



2 points by maxdeviant 3649 days ago | link

Thank you for your very thorough reply!

This is exactly the kind of information I have been looking for and that I think he would be interested in.

Clamp sounds very interesting as well, especially since we just covered macros in class last week.

-----