Alpheus Madsen said on Fri, 20 Jul 2012 11:25:54 -0700: > First of all, I want to make it clear that I'm not completely opposed to > using "." as an option for indentation.
Good! > Having said that, I think your examples are flawed; the logic of your example > is difficult to follow. I also don't think you're using COND correctly--but > that could just be me, because I'm an inexperienced Lisper, but I'm coming > from a Common Lisp background. > I've tried to re-write this as a classical s-expr, and I got this: This is cool, the following is called a "classical s-expr" and it has curly-infix and modern-expressions embedded inside it. Mark this date down :-)!!! BTW, I don't normally enable HTML display of email, but I sure couldn't follow this post *without* enabling it. I'm going to repost this as ordinary text, so that others who only see straight text can follow it. First, here's the S-expression as written by Alpheus Madsen: > (cond > ((expr1? f) (let ((var (list-of x > ({t in '(1 2 3 4)} > (pred? t) > {x in range-of(0 t)}))) > (var2 (kitty ('meow) ('meow)))) > (execute > ((foo var)) > ((quux var2))))) > ((expr2? f) (progn (kitty > ('niaw) > (expand-upon('niaw))) > (woorf f))) > (#t (error "bobcat: NYAWR"))) I haven't done a detailed study of the code, but the format looks okay on a quick look. > Then I've re-written this as a sweet-expression: > > cond > exprl?(f) \\ let > \\ var list-of(x > ({t in '(1 2 3 4)} > pred?(t) > {x in range-of(0 t)})) > var2 > kitty > 'meow > 'meow > exprl2?(f) \\ progn > > kitty > 'niaw > expand-upon('niaw) > woorf(f) > #t \\ error("bobcat: NYAWR") This rewritten form isn't the same as "traditional" S-expr that precedes it. The fragment: > cond > exprl?(f) \\ let is by definition exactly the same as: > cond > exprl?(f) > let which is (cond (exprl? f) let ...). "Split" in the middle of a line essentially causes a line break, and starts over at the next indent. It's just a way of expressing in one what you'd otherwise have to say in 2. Also, > \\ var list-of(x is exactly the same as: > var list-of(x Again, "\\" is like a newline, but since the next line is at the SAME indent level, nothing happens. This is useful for showing a line that is logically related to the previous one, but has to NOT actually be a child. Is that clearer? In general, conds aren't usually written that way in sweet-expressions. If the test conditions and the expressions of the result actions are short, you'll likely see (using "!" as an indentation character): cond ! condition1 resulting-expression1 ! condition2 resulting-expression2 ... If they aren't short, then the expressions would be children of the condition: cond ! condition1 ! ! resulting-expression1 ! condition2 ! ! resulting-expression2 A "let" is going to typically look like this: let ! \\ ! ! var1 expr... ! ! var2 expr.. ! expression-calculating-let. I think sweet-expressions handle "cond" nicely. Let, less so. This is complicated, obviously: (cond ((expr1? f) (let ((var (list-of x ({t in '(1 2 3 4)} (pred? t) {x in range-of(0 t)}))) (var2 (kitty ('meow) ('meow)))) (execute ((foo var)) ((quux var2))))) ((expr2? f) (progn (kitty ('niaw) (expand-upon('niaw))) (woorf f))) (#t (error "bobcat: NYAWR"))) Here's one way to rewrite it (if "!" is an indentation character) that I believe is an accurate reflection of the s-expression version: !cond ! expr1?(f) ! let ! \\ ! var ! list-of x ! {t in '(1 2 3 4)} pred?(t) {x in range-of(0 t)} ! var2(kitty(('meow) ('meow))) ! execute (foo(var)) (quux(var2)) ! expr2?(f) ! progn kitty(('niaw) (expand-upon('niaw))) woorf(f) ! #t error("bobcat: NYAWR") (If I made a mistake, let me know.) --- David A. Wheeler ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss