Andrew Dalke said:
Python isn't doing that. It's lives in a perfectly good niche wherein
Lisp is not the most appropriate language. At least not until there's a
macro which works like
(#python '
for i in range(100):
print "Spam, ",
print
)
This is trivial:
(DEFUN SPLIT-ARGUMENTS (STRING)
(DO ((CHUNKS '()) (START 0) (POS 0))
((<= (LENGTH STRING) POS)
(PROGN (WHEN (< START POS) (PUSH (SUBSEQ STRING START POS) CHUNKS))
(NREVERSE CHUNKS)))
(IF (CHAR= (CHAR STRING POS) (CHARACTER " "))
(PROGN (WHEN (< START POS) (PUSH (SUBSEQ STRING START POS) CHUNKS))
(INCF POS) (SETQ START POS))
(INCF POS)))
);;SPLIT-ARGUMENTS
(SET-DISPATCH-MACRO-CHARACTER
(CHARACTER "#") (CHARACTER "!")
(LAMBDA (STREAM CHAR ARG)
(DECLARE (IGNORE CHAR ARG))
;; first read the interpreter path and arguments.
;; next read the script up to a line beginning with "!#".
;; then generate statements to the interpreter and feed it the script.
(DO ((INTERPRETER (SPLIT-ARGUMENTS (READ-LINE STREAM NIL NIL T)))
(SCRIPT '())
(LINE (READ-LINE STREAM NIL NIL T)
(READ-LINE STREAM NIL NIL T)))
((AND (<= 2 (LENGTH LINE)) (STRING= "!#" LINE :END2 2))
`(LET ((INTERP-INPUT (EXT:RUN-PROGRAM ,(CAR INTERPRETER)
:ARGUMENTS ',(CDR INTERPRETER)
:INPUT :STREAM :OUTPUT :TERMINAL)))
;; Sorry, clisp specific. Please replace ext:run-program by
;; your favorite hook.
(DOLIST (LINE ',(NREVERSE SCRIPT))
(FORMAT INTERP-INPUT "~A~%" LINE))
(CLOSE INTERP-INPUT)))
(PUSH LINE SCRIPT))))
[27]> #!/usr/bin/python
for i in range(100):
print "Spam, ",
print ""
!#
T
[28]> Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam, Spam,
Therefore Python lives in a perfectly good niche wherein Lisp IS the
most appropriate language. QED you can forget Python.
And of course, while trivial when implemented in Lisp, it's so
powerfull it's not limited to python:
[29]> #!/bin/bash
ls -m *.lisp
!#
T
[31]> ai.lisp, antispam-test.lisp, antispam.lisp, ascii.lisp, basic.lisp,
benford.lisp, bits-old.lisp, bits.lisp, bottle.lisp, brent.lisp, c-order.lisp,
clos-test.lisp, clx-sample.lisp, clx-tutorial.lisp, compare-lts.lisp,
copy-over.lisp, dbc.lisp, ddj-combin.lisp, dec.lisp, def-if-undef.lisp,
defstrmacro.lisp, deriv.lisp, diagram.lisp, directory-and-pathname.lisp,
dot.clisprc.lisp, douze.lisp, exemple-cloture.lisp, expert.lisp, fast-io.lisp,
fibonacci.lisp, fixed-point.lisp, four.lisp, html.lisp, ib.lisp, ig.lisp,
inferior-lisp.lisp, integ.lisp, lecture-au-vol.lisp, lisp1-in-cl.lisp,
livre-qui-rend-fou.lisp, lpt-bug.clisprc.lisp, marienbad.lisp, num.lisp,
old-marienbad.lisp, packages.lisp, pg-psql.lisp, pg.lisp, pi.lisp,
picture-test.lisp, posix-dirent.lisp, protocoles.lisp, pttp-1i.lisp,
python.lisp, quine.lisp, scratch.lisp, sdraw.lisp, sum.lisp, symbol.lisp,
test-format.lisp, test-special.lisp, test.lisp, text.lisp, tree.lisp,
turing.lisp, wang.lisp, word-count.lisp
Personnaly, I prefer to write, consistently:
(dotimes (i 100)
(format t "Spam, "))
(format t "~%")
That is, consistently with the rest of my programs.
The question being whether it's better to be needing several different
languages to solve a set of problems because none of them languages is
powerful enough, or if it's better to have one good and powerful
language that helps you solve all your problems?