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


Groups > comp.lang.python > #86262

Re: list storing variables

From Marko Rauhamaa <marko@pacujo.net>
Newsgroups comp.lang.python
Subject Re: list storing variables
Date 2015-02-23 22:38 +0200
Organization A noiseless patient Spider
Message-ID <87k2z8fjn3.fsf@elektro.pacujo.net> (permalink)
References (1 earlier) <cl16ncF4a8mU1@mid.individual.net> <8761ascwt4.fsf@elektro.pacujo.net> <mailman.19094.1424716896.18130.python-list@python.org> <87385wh2ho.fsf@elektro.pacujo.net> <mailman.19097.1424719816.18130.python-list@python.org>

Show all headers | View raw


Ian Kelly <ian.g.kelly@gmail.com>:

> Obviously one can use any Turing-complete language to emulate features
> of any other Turing-complete language, but I think the point is that
> there is no syntactic support for it.

While my "contribution" was made tongue-in-cheek, there's a grain of
truth in every joke.

First of all, this is not emulating a Turing-complete language. It is
demonstrating differences in the data model. The differences aren't in
the supposed absence of variables or memory slots. Python has variables
that are memory slots, just like C or Java.

You are right that Python doesn't have syntactic support for "&".
However, that has little bearing to the underlying data model.

Python doesn't suffer from the absence of "&" as much as Java does, for
example, because its main use case is returning multiple values. Tuples
handle that just fine -- although, look at this snippet:

    def put_left(self, key, value):
        if self.left is None:
            self.left = Entry(self, key, value)
            self.balance -= 1
            return self, self.right is None, self.left, True
        self.left, grown, entry, fresh = self.left.put(key, value)
        if not grown:
            return self, False, entry, fresh
        self.balance -= 1
        if self.balance != -2:
            return self, self.balance == -1, entry, fresh
        return self.rotate_right(), False, entry, fresh


There are other, rarer use cases where idioms such as my AmpersandA
class need to be employed. But, thanks to the existence of closures, no
tears are shed.


Marko

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


Thread

list storing variables "ast" <nomail@invalid.com> - 2015-02-23 13:55 +0100
  Re: list storing variables Dave Angel <davea@davea.name> - 2015-02-23 08:24 -0500
  Re: list storing variables Marko Rauhamaa <marko@pacujo.net> - 2015-02-23 15:49 +0200
  Re: list storing variables Peter Pearson <pkpearson@nowhere.invalid> - 2015-02-23 17:35 +0000
    Re: list storing variables Marko Rauhamaa <marko@pacujo.net> - 2015-02-23 20:22 +0200
      Re: list storing variables Peter Otten <__peter__@web.de> - 2015-02-23 19:41 +0100
        Re: list storing variables Marko Rauhamaa <marko@pacujo.net> - 2015-02-23 21:06 +0200
          Re: list storing variables Chris Angelico <rosuav@gmail.com> - 2015-02-24 06:17 +1100
            Re: list storing variables Marko Rauhamaa <marko@pacujo.net> - 2015-02-23 22:25 +0200
          Re: list storing variables Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-23 12:29 -0700
            Re: list storing variables Marko Rauhamaa <marko@pacujo.net> - 2015-02-23 22:38 +0200
  Re: list storing variables Ben Finney <ben+python@benfinney.id.au> - 2015-02-24 09:03 +1100
    Re: list storing variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-24 13:24 +1100
      Re: list storing variables Marko Rauhamaa <marko@pacujo.net> - 2015-02-24 10:18 +0200

csiph-web