News for hackers. Stuff that matters.
Re:X server in 5000 lines of Common Lisp by e12e on Saturday December 07, 2013 @11:11PM (#6868922)
Hm, am I right in thinking that numbers are defined to be atoms in lisp. And also that there are limits to how one can use macros, in that you'd not be able to a) rename FIRST, as in (FIRST list) to 1 (or '1): (1 list) or ('1 list); and b) that you couldn't modify the syntax to "decompose"/parse a slice syntax like: (1:2 (list-of-lists)) (here 1:2 would mean for example first element of second sublist/cons) ?

Now, you could of course write an interpreter for such a language in lisp, but am I correct in assuming that there's no reasonable way to get a (standard'ish) lisp to compile an expression like (1:2 ...) to the equivalent caadr(?)-like expression?

I saw there's a library for clojure that adds "slice notation" -- but does so by adding a (slice x y list)-macro which of course is fine -- but it would seem that (x:y list) would give similar benefits to the cadr/cddr etc -- allowing selected subsets to be highly optimized, for example? (As well as offering concise syntax)

Re:X server in 5000 lines of Common Lisp by lispm on Sunday December 08, 2013 @03:44AM (#6869301)
Functions like CADDR are not much used in modern Lisp.

I would not write `slice` as a `macro` or special syntax. I would use the `SUBSEQ` function, which already exists.

    CL-USER 7 > (subseq '(a b c d e f) 2 4)
    (C D)
The simplest way to introduce a special syntax for it is to use different parentheses:

    {1 '(1 2 3 4)}  -> 2
But the default Lisp style is this

    (functionname arg0 ... argn)
where `functionname` is a real symbol. It may be longer on the character level, which may be a problem for some users - not for me.
Re:X server in 5000 lines of Common Lisp by e12e on Sunday December 08, 2013 @05:57AM (#6869467)
I suppose what I was really wondering, but cleverly hid in formulating my comment, was "what are read[er] macros?".

That'd be how you could redefine "{" and "}" to work something like this?

At least I came across the following that seems to indicate that:

http://letoverlambda.com/index.cl/guest/chap4.html

http://jlongster.com/2012/02/18/its-not-about-macros-its-abo...

Re:X server in 5000 lines of Common Lisp by lispm on Sunday December 08, 2013 @08:12AM (#6869619)
Reader macros allow you to write parser functions for characters. So you could write a reader macro for { such that it collects all enclosed content until a } character. The it could transform that content and return the transformed result. The result is always Lisp data, not a string. How you transform the enclosed text is up to you.

Common Lisp itself tries to minimize its usage of characters. It is expected that users or libraries want to make use of characters like {, }, [, ], and many others.