3 ms·
In Common Lisp you can embed arbitrary data structures in to your code because the reader can build them at read-time, and it can also evaluate arbitrary code a
by jpr 16y ago
In Common Lisp you can embed arbitrary data structures in to your code because the reader can build them at read-time, and it can also evaluate arbitrary code at read time (you can turn this feature off for safety). So "embedding a graph" means something totally different in CL. The CL reader can also basically read both persistent pointers (symbols) and ephemeral pointers (the #N= #N# notation with which you can even read self-recursive structures).
Contrast this to Java, where there are no literal datastructures, no reader, and all your data structures must be explicitly built from constructor up.
I really wish these things would be something that people would be thaught at universities, but thanks to Java-schools, they aren't.
- ww520 16y agoThat's a good feature in Lisp. How would that negate the need of a graph library? I once needed to do topological sort on a graph. Sure I can code it myself but I ended up calling the Boost library for it.
- rikthevik 16y agoI think he's referring to defining existing graphs in the code. Because of the relationship between code and data in lisp, you don't need to define graph objects and connect them all at run-time, which you'd have to in Java. It's like who in Python you could say mydict = { "a":1, "b":2 } as opposed to HashMap d = new HashMap(); d.put("a", 1); d.put("b", 2);
- ww520 16y agoIf that's the case, why does one need to use a graph library to construct simple graph data structure? It looks like JGraphIt is used as a strawman argument to exaggerate the difference. BTW, Java does support some notion of literal construction using array. e.g. new Object[] {"abc", "xyz", 1, 2, 3, new Integer[] {4, 5, 6}, new Node(2)};