Off The Air
Someone should make a mirror because I can't figure out how to download my posts!
Concision is equivalent to powerfulness
(def upcase (x)
(let upc (fn (c)
(let n (coerce c 'int)
(if (or (< 96 n 123) (< 223 n 247) (< 247 n 255))
(coerce (- n 32) 'char)
c)))
(case (type x)
string (map upc x)
char (upc x)
sym (sym (map upc (coerce x 'string)))
(err "Can't upcase" x))))
What you are left is is the bare essense of coding. Everything written is essential. Nothing is superfluous. There are truly no onions. The specification of Arc (which is the implementation of Arc) can be printed on just a few pages (full duplex); the whole thing is 4609 lines of code!
Let's be clear. Paul Graham is the #1 Lisp luminary right now. When he writes that he is a typical Lisp hacker, it's also 100% true. But there's another factor. He's typical, to the nth degree. When he says Lisp needs to go in a new direction, people who know nothing about Lisp will sit up and listen. It's his kind of leadership that will bring Lisp back into the mainstream.
This blog post is a little long. I'll leave you with the axioms of the new Lisp world:
(define (ac s env)
(cond ((string? s) (string-copy s)) ; to avoid immutable strings
((literal? s) s)
((eqv? s 'nil) (list 'quote 'nil))
((ssyntax? s) (ac (expand-ssyntax s) env))
((symbol? s) (ac-var-ref s env))
((ssyntax? (xcar s)) (ac (cons (expand-ssyntax (car s)) (cdr s)) env))
((eq? (xcar s) 'quote) (list 'quote (ac-niltree (cadr s))))
((eq? (xcar s) 'quasiquote) (ac-qq (cadr s) env))
((eq? (xcar s) 'if) (ac-if (cdr s) env))
((eq? (xcar s) 'fn) (ac-fn (cadr s) (cddr s) env))
((eq? (xcar s) 'set) (ac-set (cdr s) env))
; this line could be removed without changing semantics
((eq? (xcar (xcar s)) 'compose) (ac (decompose (cdar s) (cdr s)) env))
((pair? s) (ac-call (car s) (cdr s) env))
(#t (err "Bad object in expression" s))))
(mkreddit frontpage-downvotes: #false)
Labels: arc, brevity, littlelanguages, paulgraham, power
(defmacro wif (stream filename &rest; body)
`(with-open-file (,stream ,filename :direction :input
:element-type 'character
)
,@body))
(defun filestr (file)See? Much more concise, and all within the limitations of Common Lisp (except for strmlen, which shells out to the "stat" shell command to get the file length).
(w/file (strm file)
(let-1 buf (mkbuf (strmlen strm) 'chr)
(dotimes (i (strmlen strm) buf)
(setf (chr buf i) (readchr strm))))))
Scheme is a dialect of Lisp that stresses elegance and simplicity. It is a stripped-down version of Common Lisp. In fact, the language specification is about 50 pages, while the Common Lisp’s specification is about 1,300 pages. Scheme is often used in computer science courses to teach abstraction and programming concepts. Even though it is used primarily as a teaching language, Scheme has numerous applications — the GIMP allows users to write GIMP-loadable modules in Guile.
(gif (some-test)
(print "The test is true") (print "And this also prints when true")
(print "The test is false") (print "And this also prints when false\")