unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Sam Steingold <sds@gnu.org>
To: emacs-devel@gnu.org
Cc: emacs-tangents@gnu.org
Subject: Re: Python vs Lisp (followups to -tangents)
Date: Thu, 10 Dec 2015 13:40:39 -0500	[thread overview]
Message-ID: <86oadyjgew.fsf@gnu.org> (raw)
In-Reply-To: n4c8ba$80v$1@ger.gmane.org

> * Random832 <enaqbz832@snfgznvy.pbz> [2015-12-10 16:13:30 +0000]:
>
> On 2015-12-10, Richard Stallman <rms@gnu.org> wrote:
>
>> I skimmed documentation of Python after people told me it was
>> fundamentally similar to Lisp. My conclusion is that that is
>> not so. `read', `eval', and `print' are all missing in Python.
>
> I must admit, I don't fully understand what you mean by this.
>
> Print is the most confusing. As a feature, Lisp's 'print' can be
> described as: Produce a string representation which can be read
> back of some objects (certainly not *all* objects - not buffers
> or subroutines, for example, and it's not structure-preserving
> for lists of lists), and display it on standard output.

This is false.
Nested lists are certainly printed readably:

--8<---------------cut here---------------start------------->8---
(defvar l '(1 (2 3) 4 (5 (6 (7 (8))))))
(equal l (read (prin1-to-string l)))
==> t
--8<---------------cut here---------------end--------------->8---


> Python's 'repr' could be regarded as an exact match in concept
> for prin1-to-string, a building block from which Lisp's 'print'
> can be trivially made. The essential feature - that there is a
> way to get a string that can be read back for objects for which
> it is reasonable/easy - is present.

True, but irrelevant.
An important feature is missing: repr is not defined for classes
automatically.

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

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

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.


-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 15.10 (wily) X 11.0.11702000
http://www.childpsy.net/ http://memri.org http://islamexposedonline.com
http://truepeace.org http://www.dhimmitude.org http://camera.org
Old Age Comes at a Bad Time.




  reply	other threads:[~2015-12-10 18:40 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 [this message]
2015-12-10 22:31                         ` Random832
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=86oadyjgew.fsf@gnu.org \
    --to=sds@gnu.org \
    --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).