unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Random832 <random832@fastmail.com>
To: emacs-devel@gnu.org
Cc: emacs-tangents@gnu.org
Subject: Re: Python vs Lisp (followups to -tangents)
Date: Thu, 10 Dec 2015 22:31:49 +0000 (UTC)	[thread overview]
Message-ID: <n4cugl$sb5$1@ger.gmane.org> (raw)
In-Reply-To: 86oadyjgew.fsf@gnu.org

On 2015-12-10, Sam Steingold <sds@gnu.org> 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))))...)

> 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.

>> 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>

> 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.)

> 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.




  reply	other threads:[~2015-12-10 22:31 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-28 23:29 First draft of the Emacs website Nicolas Petton
2015-11-28 23:51 ` Jean-Christophe Helary
2015-11-29  0:03 ` Daniel Pimentel
2015-11-29  1:02 ` Xue Fuqiao
2015-11-29  1:26   ` Nicolas Petton
2015-11-29  2:19     ` Alex Dunn
2015-11-29  3:31       ` Jean-Christophe Helary
2015-11-29  5:42         ` Random832
2015-11-29  8:15           ` David Caldwell
2015-11-29 14:25             ` Dmitry Gutov
2015-11-30 17:49             ` Emacs for Mac OS X bundle (was: First draft of the Emacs website) John Wiegley
2015-11-30 20:02               ` Emacs for Mac OS X bundle David Caldwell
2015-12-01  0:15                 ` Xue Fuqiao
2015-12-01  1:40                   ` David Caldwell
2015-11-30  0:02     ` First draft of the Emacs website Xue Fuqiao
2015-11-29  8:06 ` Przemysław Wojnowski
2015-11-29 10:27   ` Zack Piper
2015-11-29 12:36     ` Rasmus
2015-11-29 12:58       ` Nicolas Petton
2015-11-29 14:00       ` Marcin Borkowski
2015-11-29 10:15 ` David Engster
2015-11-29 12:56   ` Nicolas Petton
2015-11-29 15:17 ` Dmitry Gutov
2015-11-29 19:38   ` Nicolas Petton
2015-11-29 22:01     ` Dmitry Gutov
2015-11-29 22:11       ` Nicolas Petton
2015-11-29 16:21 ` Christopher Allan Webber
2015-11-29 19:39   ` Nicolas Petton
2015-11-29 21:45 ` Artur Malabarba
2015-11-29 22:11   ` Nicolas Petton
2015-11-30  0:04     ` Artur Malabarba
2015-11-30  1:29       ` Alex Dunn
2015-11-30  9:43         ` Artur Malabarba
2015-11-30 10:33           ` Dani Moncayo
2015-11-30 15:22             ` Drew Adams
2015-11-30 16:06   ` Nicolas Petton
2015-11-30 16:16     ` Yuri Khan
2015-11-30 16:23       ` Nicolas Petton
2015-12-01 14:37     ` Richard Stallman
2015-12-01 14:56       ` Nicolas Petton
2015-11-30 19:48 ` Milan Zamazal
2015-12-02 16:45   ` Drew Adams
2015-12-02 17:22     ` Nicolas Petton
2015-12-02 16:36 ` Random832
2015-12-02 17:12   ` Nicolas Petton
2015-12-02 18:07     ` Yuri Khan
2015-12-02 18:26       ` Nicolas Petton
2015-12-02 18:29       ` Nicolas Petton
2015-12-02 18:30         ` Yuri Khan
2015-12-02 23:47   ` Xue Fuqiao
2015-12-04  3:57     ` Random832
2015-12-04  5:17       ` License of the Emacs website (was: Re: First draft of the Emacs website) Chad Brown
2015-12-05  0:19       ` First draft of the Emacs website Richard Stallman
2015-12-03 13:58 ` Clément Pit--Claudel
2015-12-03 22:17   ` John Yates
2015-12-03 22:30     ` Nicolas Petton
2015-12-03 22:57     ` Drew Adams
2015-12-03 23:26       ` John Yates
2015-12-04  0:58         ` Drew Adams
2015-12-08 13:05           ` Valentijn
2015-12-08 15:09             ` Drew Adams
2015-12-08 15:21               ` Spencer Boucher
2015-12-08 16:08                 ` David Kastrup
2015-12-08 20:52                 ` Marcin Borkowski
2015-12-08 21:51                   ` Drew Adams
2015-12-08 21:58                     ` Drew Adams
2015-12-09 21:00                     ` Marcin Borkowski
2015-12-10  5:28                     ` Richard Stallman
2015-12-10  9:10                       ` David Kastrup
2015-12-10  5:27                   ` Richard Stallman
2015-12-10 16:13                     ` Python vs Lisp (followups to -tangents) Random832
2015-12-10 18:40                       ` Sam Steingold
2015-12-10 22:31                         ` Random832 [this message]
2015-12-16 15:57                           ` Sam Steingold
2015-12-16 17:56                           ` Christopher Allan Webber
2015-12-09  6:06                 ` First draft of the Emacs website Richard Stallman
2015-12-04  6:06         ` David Kastrup
2015-12-04  9:37           ` Eli Zaretskii
2015-12-04  9:42             ` David Kastrup
2015-12-04 10:11               ` Eli Zaretskii
2015-12-04 10:42                 ` Nicolas Petton
2015-12-04 10:44                 ` David Kastrup
2015-12-04 11:03                   ` Eli Zaretskii
2015-12-04 22:26                   ` Paul Eggert
2015-12-04 22:30                     ` David Kastrup
2015-12-04  8:42         ` Eli Zaretskii
2015-12-03 23:59     ` Clément Pit--Claudel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='n4cugl$sb5$1@ger.gmane.org' \
    --to=random832@fastmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-tangents@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).