Hi! Glad to see activity on this list. I wanted to offer some constructive criticism.
1. On adding @@: Less is more. As (I believe) David noted, trying the syntax to the underlying semantics is a losing proposition. I wouldn't worry about every corner case. If a given language has a construct or two that doesn't look great in sweet expressions, let's not fret about it. 2. On the procedure(...) form: I'm thinking this should not be a part of SE. It saves no characters. It distances SE from regular homoiconic syntax. I love the idententaion and brackets as macro, but this component seems less necessary. Again, great work all around. These examples have been great! -Mark On Thu, Nov 13, 2008 at 5:21 PM, David A. Wheeler <[EMAIL PROTECTED]> wrote: > I've added more examples to: > http://www.dwheeler.com/readable/version02.html > They are for NewLisp, Clojure, and ISLisp. Again, I'm trying > to make sure that the syntax is reasonable for a variety of semantics; > using Lisp variants & applications is a way to make that so. > > Below is the current version of the text. > > --- David A. Wheeler > > =============================== > > NewLisp > NewLisp is "Lisp-like, general purpose scripting language", with an > implementation released under the GPL. > Original Lisp > Here is a sample from their Code patterns document: > > (dolist (file-name (3 (main-args))) > (set 'file (open file-name "read")) > (println "file ---> " file-name) > (while (read-line file) > (if (find (main-args 2) (current-line) 0) > (write-line))) > (close file)) > > This is the original formatting. It's a little misleading; the write-line is > actually inside the "if", not a sibling of it. Yet another example of how > formatting can mislead a reader, when humans use it but computers don't. > > Non-Infix default > > Same thing, with sweet-expressions: > > dolist (file-name (3 (main-args))) > set 'file open(file-name "read") > println "file ---> " file-name > while read-line(file) > if find(main-args(2) current-line() 0) > write-line() > close file > > > > Clojure > Clojure is a Lisp dialect running on top of a Java JVM. differences with > other Lisps explains some of the differences. > > Clojure is inspired by Lisp, but it also has several syntactic additions. As > discussed in its section on the reader, its syntax includes support for: > > * Lists. Lists are zero or more forms enclosed in parentheses: (a b c) > * Vectors. Vectors are zero or more forms enclosed in square brackets: [1 > 2 3] > * Maps. Maps are zero or more key/value pairs enclosed in braces: {:a 1 :b > 2} Commas are considered whitespace, and can be used to organize the pairs: > {:a 1, :b 2} Keys and values can be any forms. > * Sets. Sets are zero or more forms enclosed in braces preceded by #: #{:a > :b :c} > > Original Lisp > The example of Clojure agents gives this example, which is "an implementation > of the send-a-message-around-a-ring test. A chain of n agents is created, > then a sequence of m actions are dispatched to the head of the chain and > relayed through it": > > (defn setup [n next] > (if (zero? n) > next > (recur (dec n) (agent {:next next})))) > (defn relay [x m] > (when (:next x) > (send (:next x) relay m)) > (when (and (zero? m) (:report-queue x)) > (. (:report-queue x) (put m))) > x) > (defn run [m n] > (let [q (new java.util.concurrent.SynchronousQueue) > tl (agent {:report-queue q}) > hd (setup (dec n) tl)] > (doseq m (reverse (range m)) > (send hd relay m)) > (. q (take)))) > ; Time 1 million message sends: > (time (run 1000 1000)) > > Non-Infix default > Sweet-expressions work well with Clojure, but a few notes should be made > first. Clojure uses [...] to notate vectors; to me, this suggests that the > rule for sweet-expressions should be 'interpret unprefixed [...] as whatever > the base language does' (which would help Clojure and Arc, among others). For > sweet-expressions, I'll assume that [...] disable indentation processing > inside, just as (...) and {...} do. In Scheme, unprefixed [...] should be > considered the same as (...), since that's the meaning for Scheme R6. So, Arc > and Clojure have refined the sweet-expression rules for [...]. > > It's easy to imagine an extension of sweet-expressions that has additional > syntactic support for special types, just as Clojure's built-in syntax does. > But for the moment, I'll just use map(...) to transform a list into a map, > instead of having more syntactic support. Clojure uses curly braces for maps, > but we'll continue to use curly braces for infix lists. > > Finally, one odd thing is that in Closure, "." is a symbol, and an important > one you can include at the beginning of a list. That is weird; in many Lisps, > "(. hi)" is the same as "hi" because of the way list reading is typically > implemented, and I presumed that when I spec'ed sweet-expressions. For the > moment, I'll write the symbol "." as "\.". > > Given all that, here's one way to notate this in sweet-expressions: > > defn setup [n next] > if zero?(n) > next > recur dec(n) agent(map(:next next)) > defn relay [x m] > when :next(x) > send :next(x) relay m > when {zero?(m) and :report-queue(x)} > \. :report-queue(x) put(m) > x > defn run [m n] > let [q new(java.util.concurrent.SynchronousQueue) > tl agent(map(:report-queue q)) > hd setup(dec(n) tl)] > doseq m reverse(range(m)) send(hd relay m) > \. q take() > ; Time 1 million message sends: > time(run(1000 1000)) > > > > ISLisp > ISLisp (also capitalized as ISLISP) is a programming language standardized by > the ISO. Its intent was define a small core language based on only the > features shared between existing LISPs, particularly Common Lisp, EuLisp, Le > Lisp, and Scheme. It provides basic functionality and object-orientation, and > was intended to "give priority to industrial needs over academic needs". It > has separate function and value namespaces (hence it is a Lisp-2). It is > standardized as ISO/IEC 13816:1997 and later revised as ISO/IEC 13816:2007 - > Information technology – Programming languages, their environments and > system software interfaces – Programming language ISLISP. ISLisp is > rarely used; Common Lisp and Scheme are far more common. > Original Lisp > > Sadly, ISO still hasn't arrived at the 21st century, so it still doesn't > release standards to the web as a matter of course. A draft of the ISLisp > spec draft 23 is available, and it gives these examples for "and": > > (and (= 2 2) (> 2 1)) ; t > (and (= 2 2) (< 2 1)) ; nil > (and (eql ’a ’a) (not (> 1 2))) ; t > (let ((x ’a)) (and x (setq x ’b))) ; b > (let ((time 10)) > (if (and (< time 24) (> time 12)) > (- time 12) time)) ; 10 > > Non-Infix default > Here's a version using sweet-expressions: > > {{2 = 2} and {2 > 1}} ; t > {{2 = 2} and {2 < 1}} ; nil > {{’a eql ’a} and not({1 > 2})} ; t > let ((x ’a)) {x and setq(x ’b)} ; b > let ((time 10)) > if {{time < 24} and {time > 12}} > {time - 12} time ; 10 > > > --- David A. Wheeler > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Readable-discuss mailing list > Readable-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/readable-discuss > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss