[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Python vs Lisp (followups to -tangents)
From: |
Sam Steingold |
Subject: |
Re: Python vs Lisp (followups to -tangents) |
Date: |
Wed, 16 Dec 2015 10:57:45 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
> * Random832 <address@hidden> [2015-12-10 22:31:49 +0000]:
>
> On 2015-12-10, Sam Steingold <address@hidden> wrote:
>> This is false.
>> Nested lists are certainly printed readably:
>
> What I meant by "not structure-preserving" is that the output is
> the same, ((1 2) (1 2)), for these lists:
>
> (let ((x '((1 2) (1 2)))) (eq (car x) (cadr x))) ==> nil
> (let* ((a '(1 2)) (x `(,a ,a))) (eq (car x) (cadr x))) ==> t
> (let ((x (read "((1 2) (1 2))"))) (eq (car x) (cadr x))) ==> nil
>
> (Or for that matter, let*
> ((b '(2)) (x (list (cons 1 b) (cons 1 b))))...)
please examine the `print-circle' variable.
>> True, but irrelevant.
>>An important feature is missing: repr is not defined for classes
>> automatically.
>
> Sure it is. It's just defined to the same kind of useless value
> that Lisp has for buffers and subroutines.
The #<...> format is reserved for objects which cannot be meaningfully
read back. Still, it contains plenty of information for a human.
Python prints junk when it could have been printing machine-readable info.
>>> Python's 'eval'/'exec' normally evaluates code directly from a
>>> string, skipping the need for 'read' entirely.
>>
>> A string is too unstructured.
>>
>>> However, if desired, the 'ast' module provides a rich framework for
>>> working with expression trees - the only difference is that they're
>>> built from class-based objects instead of just being a list of
>>> lists/symbols/literals.
>>
>> These class-based objects cannot be printed readably (IIUC).
>
> It's unfortunate that this is not their repr output, but the
> ast.dump function provides this:
>
>>>> ast.dump(ast.parse("1 + 1"))
> 'Module(body=[Expr(value=BinOp(left=Num(n=1), op=Add(), right=Num(n=1)))])'
>>>> eval(ast.dump(ast.parse("1 + 1")), ast.__dict__)
> <_ast.Module object at 0x7fcd79b24908>
yep, with some additional cruft Python can almost do something that Lisp
does for free.
>> The point Richard is making is that Python lacks macros, i.e., you
>> cannot easily write code which writes code.
>> You have to either operate at the level of strings (which is hard to get
>> right) or at the level of AST (which is even harder).
>
> I don't see how operating at the level of AST is harder than
> operating at the level of lists (backquote operates above the
> level of lists; it automatically searches the code you give it
> for placeholders to substitute values in. It probably wouldn't
> be hard to write an equivalent in Python.)
I am afraid you do not quite understand what you are talking about.
>> Even more succinctly, in Lisp data and code are the same: lists of
>> lists, symbols, strings &c.
>> In Python, data is (mostly) strings and code is AST.
>
> I guess I don't see how being a little rough around the edges or
> not working exactly the same way is the same thing as missing
> the essential features entirely.
>
> And this really isn't a valid objection to the claim being
> discussed, which is that Python is similar to a hypothetical
> M-expression lisp.
You have seen a car but never rode or driven one and you are trying to
convince me that your tricycle is better.
Seriously, this is the wrong forum for this discussion.
I suggest that you learn more about Lisp (see, e.g., Paul Graham's "On
Lisp", or http://letoverlambda.com/).
--
Sam Steingold (http://sds.podval.org/) on Ubuntu 15.10 (wily) X 11.0.11702000
http://www.childpsy.net/ http://think-israel.org http://americancensorship.org
http://openvotingconsortium.org http://memri.org http://mideasttruth.com
"A pint of sweat will save a gallon of blood." -- George S. Patton
- Re: First draft of the Emacs website, (continued)
- Re: First draft of the Emacs website, David Kastrup, 2015/12/08
- Re: First draft of the Emacs website, Marcin Borkowski, 2015/12/08
- RE: First draft of the Emacs website, Drew Adams, 2015/12/08
- RE: First draft of the Emacs website, Drew Adams, 2015/12/08
- Re: First draft of the Emacs website, Marcin Borkowski, 2015/12/09
- Re: First draft of the Emacs website, Richard Stallman, 2015/12/10
- Re: First draft of the Emacs website, David Kastrup, 2015/12/10
- Re: First draft of the Emacs website, Richard Stallman, 2015/12/10
- Message not available
- Re: Python vs Lisp (followups to -tangents), Sam Steingold, 2015/12/10
- Re: Python vs Lisp (followups to -tangents), Random832, 2015/12/10
- Re: Python vs Lisp (followups to -tangents),
Sam Steingold <=
- Re: Python vs Lisp (followups to -tangents), Christopher Allan Webber, 2015/12/16
- Re: First draft of the Emacs website, Richard Stallman, 2015/12/09
- Re: First draft of the Emacs website, David Kastrup, 2015/12/04
- Re: First draft of the Emacs website, Eli Zaretskii, 2015/12/04
- Re: First draft of the Emacs website, David Kastrup, 2015/12/04
- Re: First draft of the Emacs website, Eli Zaretskii, 2015/12/04
- Re: First draft of the Emacs website, Nicolas Petton, 2015/12/04
- Re: First draft of the Emacs website, David Kastrup, 2015/12/04
- Re: First draft of the Emacs website, Eli Zaretskii, 2015/12/04
- Re: First draft of the Emacs website, Paul Eggert, 2015/12/04