Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #71317

Re: Values and objects

X-Received by 10.66.65.202 with SMTP id z10mr1116341pas.45.1399817531696; Sun, 11 May 2014 07:12:11 -0700 (PDT)
X-Received by 10.50.143.71 with SMTP id sc7mr356970igb.4.1399817531585; Sun, 11 May 2014 07:12:11 -0700 (PDT)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!r10no3073009igi.0!news-out.google.com!gi6ni804igc.0!nntp.google.com!c1no4599157igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Sun, 11 May 2014 07:12:11 -0700 (PDT)
In-Reply-To <536f723c$0$29980$c3e8da3$5496439d@news.astraweb.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=59.95.16.32; posting-account=mBpa7woAAAAGLEWUUKpmbxm-Quu5D8ui
NNTP-Posting-Host 59.95.16.32
References <235C4BFA-9770-481A-9FCF-21C3F036769C@gmail.com> <87ppjpwafk.fsf@elektro.pacujo.net> <536ad8f2$0$29965$c3e8da3$5496439d@news.astraweb.com> <lkjitj$d0c$1@speranza.aioe.org> <87zjiqbmy5.fsf@elektro.pacujo.net> <9cc0ebf9-dbed-4d3d-91fc-2abb9b0103d0@googlegroups.com> <mailman.9841.1399689216.18130.python-list@python.org> <536dc3f7$0$29980$c3e8da3$5496439d@news.astraweb.com> <mailman.9843.1399706518.18130.python-list@python.org> <536decca$0$29980$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmqynuf6giRvYP5P7SA_g2DH_MhRp-2=w72kLthsFqx74g@mail.gmail.com> <536E799D.6080602@stoneleaf.us> <mailman.9867.1399757236.18130.python-list@python.org> <536eebc1$0$29980$c3e8da3$5496439d@news.astraweb.com> <mailman.9874.1399779013.18130.python-list@python.org> <536f069b$0$29980$c3e8da3$5496439d@news.astraweb.com> <mailman.9875.1399785752.18130.python-list@python.org> <3fb2d95e-2fb6-43a5-a725-c6d38444b80c@googlegroups.com> <87ppjksum0.fsf@elektro.pacujo.net> <qot4n0wd8la.fsf@ruuvi.it.helsinki.fi> <536f723c$0$29980$c3e8da3$5496439d@news.astraweb.com>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <35eb82b8-ca79-438e-bdde-430c6ffbfa3c@googlegroups.com> (permalink)
Subject Re: Values and objects
From Rustom Mody <rustompmody@gmail.com>
Injection-Date Sun, 11 May 2014 14:12:11 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:71317

Show key headers only | View raw


On Sunday, May 11, 2014 6:21:08 PM UTC+5:30, Steven D'Aprano wrote:

> The point is, it is *logically impossible* for a language to use 
> precisely the same syntax for value-assignment and variable-assignment. 
> Consider the variable called "x", which is bound to the value 23. If the 
> language has a single assignment operator or statement:

Its called set in classic lisp.
Here's an emacs lisp session (the oldest lisp I can lay my hands on)
The semicolons are comments like python's #

*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (set (quote d) "Hello World")
"Hello World"
ELISP> (set (quote c) (quote d))
d
ELISP> ; those quote-s are getting boring
ELISP> (set 'b 'c)
c
ELISP> ; once more short-form a very common case
ELISP> (setq a 'b)
b
ELISP> ; Now unfold the chain
ELISP> ; Level 0
ELISP> 'a
a
ELISP> ; Level 1
ELISP> a
b
ELISP> ;Level 2
ELISP> (eval a)
c
ELISP> ;Level 3
ELISP> (eval (eval a))
d
ELISP> ;Level 4
ELISP> (eval (eval (eval a)))
"Hello World"
ELISP> 


IOW set UNIFORMLY evaluates its 2 arguments.
To get usual assignment like behavior of normal programming languages,
one (typically) quotes the first argument.


This is a sufficiently common case that it gets its own 'special
form' -- setq (ie set-quote)

However the more general case in which (the name of)* the variable is
evaluated at run-time is always available.

* "Name of" is strictly not correct because:
ELISP> (symbol-name 'a)
"a"

However if I dont say the "name of..." its hard to speak in
an intelligible way.

Here is the relevant intro from the elisp manual:

A "symbol" in GNU Emacs Lisp is an object with a name.  The symbol name
serves as the printed representation of the symbol.  In ordinary Lisp
use, ... a symbol's name is unique--no two symbols have the same name.

   A symbol can serve as a variable, as a function name, or to hold a
property list.  Or it may serve only to be distinct from all other Lisp
objects, so that its presence in a data structure may be recognized
reliably.  

tl;dr:
Quote-Eval go up and down the 'meta-language' tower
just as Lambda-(function)Apply go up and down the functional tower.

Elaborated further:
http://blog.languager.org/2013/08/applying-si-on-sicp.html

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Pass variable by reference Ned Batchelder <ned@nedbatchelder.com> - 2014-05-06 16:31 -0400
  Re: Pass variable by reference Mark H Harris <harrismh777@gmail.com> - 2014-05-06 16:00 -0500
    Re: Pass variable by reference Ned Batchelder <ned@nedbatchelder.com> - 2014-05-06 17:27 -0400
    Re: Pass variable by reference Chris Angelico <rosuav@gmail.com> - 2014-05-07 09:46 +1000
      Re: Pass variable by reference Rustom Mody <rustompmody@gmail.com> - 2014-05-06 19:18 -0700
        Re: Pass variable by reference Chris Angelico <rosuav@gmail.com> - 2014-05-07 12:39 +1000
          Re: Pass variable by reference Rustom Mody <rustompmody@gmail.com> - 2014-05-06 19:54 -0700
            Re: Pass variable by reference Steven D'Aprano <steve@pearwood.info> - 2014-05-07 04:59 +0000
      Re: Pass variable by reference Mark H Harris <harrismh777@gmail.com> - 2014-05-07 13:11 -0500
        Re: Pass variable by reference Marko Rauhamaa <marko@pacujo.net> - 2014-05-08 00:22 +0300
          Values and objects [was Re: Pass variable by reference] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-08 01:08 +0000
            Re: Values and objects [was Re: Pass variable by reference] Mark H Harris <harrismh777@gmail.com> - 2014-05-09 16:56 -0500
              Re: Values and objects Marko Rauhamaa <marko@pacujo.net> - 2014-05-10 01:34 +0300
                Re: Values and objects Ben Finney <ben@benfinney.id.au> - 2014-05-10 10:24 +1000
                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-10 01:01 +0000
                Re: Values and objects Rustom Mody <rustompmody@gmail.com> - 2014-05-09 19:19 -0700
                Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-10 12:33 +1000
                Re: Values and objects Rustom Mody <rustompmody@gmail.com> - 2014-05-09 20:05 -0700
                Re: Values and objects Mark H Harris <harrismh777@gmail.com> - 2014-05-09 23:15 -0500
                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-10 06:15 +0000
                Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-10 17:21 +1000
                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-10 09:09 +0000
                Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-10 19:32 +1000
                Re: Values and objects Ethan Furman <ethan@stoneleaf.us> - 2014-05-10 12:10 -0700
                Re: Values and objects MRAB <python@mrabarnett.plus.com> - 2014-05-10 20:22 +0100
                Re: Values and objects Ethan Furman <ethan@stoneleaf.us> - 2014-05-10 12:28 -0700
                Re: Values and objects Terry Reedy <tjreedy@udel.edu> - 2014-05-10 16:16 -0400
                Re: Values and objects Terry Reedy <tjreedy@udel.edu> - 2014-05-10 16:24 -0400
                Re: Values and objects Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-05-10 14:03 -0700
                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 03:17 +0000
                Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-11 13:30 +1000
                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 05:11 +0000
                Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-11 15:22 +1000
                Re: Values and objects Rustom Mody <rustompmody@gmail.com> - 2014-05-10 22:31 -0700
                Re: Values and objects Marko Rauhamaa <marko@pacujo.net> - 2014-05-11 09:21 +0300
                Re: Values and objects Rustom Mody <rustompmody@gmail.com> - 2014-05-10 23:48 -0700
                Re: Values and objects Marko Rauhamaa <marko@pacujo.net> - 2014-05-11 18:10 +0300
                Re: Values and objects Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-05-11 11:26 +0300
                Re: Values and objects Rustom Mody <rustompmody@gmail.com> - 2014-05-11 01:48 -0700
                Re: Values and objects Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-05-11 15:22 +0300
                Re: Values and objects Marko Rauhamaa <marko@pacujo.net> - 2014-05-11 18:46 +0300
                Re: Values and objects Marko Rauhamaa <marko@pacujo.net> - 2014-05-11 22:56 +0300
                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 12:51 +0000
                Re: Values and objects Rustom Mody <rustompmody@gmail.com> - 2014-05-11 07:12 -0700
                Re: Values and objects Ethan Furman <ethan@stoneleaf.us> - 2014-05-10 22:42 -0700
                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 06:40 +0000
                Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-11 09:18 +1000
                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 03:11 +0000
                Re: Values and objects Rotwang <sg552@hotmail.co.uk> - 2014-05-11 14:46 +0100
                Re: Values and objects Ned Batchelder <ned@nedbatchelder.com> - 2014-05-11 14:40 -0400
                Re: Values and objects Rotwang <sg552@hotmail.co.uk> - 2014-05-12 00:06 +0100
                Re: Values and objects Ethan Furman <ethan@stoneleaf.us> - 2014-05-10 18:28 -0700
                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 07:24 +0000
                Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-11 11:59 +1000
                Re: Values and objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 07:29 +0000
                Re: Values and objects Ethan Furman <ethan@stoneleaf.us> - 2014-05-10 21:46 -0700
                Re: [Python-Dev] Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-11 16:08 +1000
                Re: Values and objects albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-05-17 14:26 +0000
                Re: Values and objects Chris Angelico <rosuav@gmail.com> - 2014-05-10 11:58 +1000
                Re: Values and objects Marko Rauhamaa <marko@pacujo.net> - 2014-05-10 10:57 +0300
                Re: Values and objects Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-05-10 11:06 +0300
                Re: Values and objects Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-05-10 12:07 -0400
        Re: Pass variable by reference Chris Angelico <rosuav@gmail.com> - 2014-05-08 11:31 +1000
          Re: Pass variable by reference Mark H Harris <harrismh777@gmail.com> - 2014-05-09 17:30 -0500
            Abstractions [was Re: Pass variable by reference] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-10 00:58 +0000
              Re: Abstractions [was Re: Pass variable by reference] Mark H Harris <harrismh777@gmail.com> - 2014-05-09 21:17 -0500
  Re: Pass variable by reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-07 01:14 +0000

csiph-web