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


Groups > comp.lang.python > #72961

Re: Uniform Function Call Syntax (UFCS)

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <pmiscml@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.037
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'conventions': 0.07; 'builtin': 0.09; 'len(x)': 0.09; 'subject:Function': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'mean,': 0.16; 'notation': 0.16; 'readability': 0.16; 'subclass': 0.16; 'types,': 0.16; 'well-known': 0.16; 'wrote:': 0.18; "python's": 0.19; 'putting': 0.22; 'cc:addr:python.org': 0.22; 'adds': 0.24; 'mathematical': 0.24; 'math': 0.24; 'paul': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'order.': 0.26; '(for': 0.26; 'primary': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'bigger': 0.30; 'getting': 0.31; 'usually': 0.31; 'follows': 0.31; 'another': 0.32; 'sense': 0.34; 'subject: (': 0.35; 'basic': 0.35; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'like,': 0.36; 'method': 0.36; 'charset:us- ascii': 0.36; 'similar': 0.36; 'easily': 0.37; 'performance': 0.37; 'sure': 0.39; 'new': 0.61; "you'll": 0.62; 'email addr:gmail.com': 0.63; 'such': 0.63; 'to:addr:gmail.com': 0.65; 'improvements': 0.68; 'obvious': 0.74; '"not': 0.84; '"one': 0.84; 'calls,': 0.84; 'it"': 0.84; 'technique.': 0.84; '(pdt)': 0.91; 'serious': 0.97
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=HbwmOU31NrUdrVAUT1ZDOOCzSVjYVth4CsgNH2cTMfs=; b=oBY7UgU8BSn71yvT6r4uklIRU8f/Y920CS0WXPzidgyPeBgI5X3yS070fkFQ1v0//T 0gk56uqkq+O5IR7hkmQqOOj7w78HhXgcClYWDxYxQ8vpVQlmjyvbWg/UjqhodZnW1iqN lqVfcf+S+D4Cdfo+Rbumnnq1AokjBNRSPM2ho0cRC2UQeKsvPeZOcZiR9xBGYDh5/iZY MR9PlCM4TGWn6ZIeVnp7WMnIME92twGoQT40wOUPkqqft5X3ZhXz3hDUi/RFRs+mvbPA gWGbvm6jxtOrrzalBeJSxdaxyN8vGrjEs4egoqpBTDsEak1uHBV4bdlsxId2jMS3wNaO A97g==
X-Received by 10.15.74.130 with SMTP id j2mr2379124eey.5.1402229169945; Sun, 08 Jun 2014 05:06:09 -0700 (PDT)
Date Sun, 8 Jun 2014 15:06:08 +0300
From Paul Sokolovsky <pmiscml@gmail.com>
To jongiddy <jongiddy@gmail.com>
Subject Re: Uniform Function Call Syntax (UFCS)
In-Reply-To <38058e64-0113-457c-ae63-cc66e8b569cd@googlegroups.com>
References <8b96ae27-20fa-4df9-807e-c806fed983c0@googlegroups.com> <mailman.10859.1402169265.18130.python-list@python.org> <bvhsgeF2on9U2@mid.individual.net> <38058e64-0113-457c-ae63-cc66e8b569cd@googlegroups.com>
X-Mailer Claws Mail 3.10.0 (GTK+ 2.24.10; i686-pc-linux-gnu)
MIME-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.10876.1402229177.18130.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1402229177 news.xs4all.nl 2869 [2001:888:2000:d::a6]:52660
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:72961

Show key headers only | View raw


Hello,

On Sun, 8 Jun 2014 01:26:04 -0700 (PDT)
jongiddy <jongiddy@gmail.com> wrote:

> On Sunday, 8 June 2014 02:27:42 UTC+1, Gregory Ewing  wrote:
> > 
> > Also it doesn't sit well with Python's "one obvious
> > way to do it" guideline, because it means there are
> > *two* equally obvious ways to call a function.
> 
> This provides a way to do something new (add class-optimized
> implementations for existing general-purpose functions). 

Python already has that - like, len(x) calls x.__len__() if it's
defined (for objects where it makes sense for it to be defined). Many
builtin functions have such behavior. For your custom functions, you
can add similar conventions and functionality very easily (if you'll
want to apply it to "not your" types, you'll need to subclass them,
as expected).

Getting x.foo() to call foo(x) is what's bigger problem, which has
serious performance and scoping confusion implications, as discussed in
other mails.

> It also adds
> significant readability improvements by putting function-call chains
> in order.


Not sure what exactly you mean, but the order is usually pretty obvious
- Python follows mathematical notation for function calls, and OO
standard notation for method calls, one known from primary school,
another from secondary (hopefully). They can be reordered with
parentheses, which is also well-known basic math technique.




-- 
Best regards,
 Paul                          mailto:pmiscml@gmail.com

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


Thread

Uniform Function Call Syntax (UFCS) jongiddy <jongiddy@gmail.com> - 2014-06-06 23:45 -0700
  Re: Uniform Function Call Syntax (UFCS) Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-07 13:20 -0600
    Re: Uniform Function Call Syntax (UFCS) Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-06-08 13:27 +1200
      Re: Uniform Function Call Syntax (UFCS) jongiddy <jongiddy@gmail.com> - 2014-06-08 01:26 -0700
        Re: Uniform Function Call Syntax (UFCS) Paul Sokolovsky <pmiscml@gmail.com> - 2014-06-08 15:06 +0300
          Re: Uniform Function Call Syntax (UFCS) Marko Rauhamaa <marko@pacujo.net> - 2014-06-08 18:56 +0300
            Re: Uniform Function Call Syntax (UFCS) Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-08 10:38 -0600
            Re: Uniform Function Call Syntax (UFCS) Paul Sokolovsky <pmiscml@gmail.com> - 2014-06-08 19:40 +0300
            Re: Uniform Function Call Syntax (UFCS) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-09 04:33 +0000
              Re: Uniform Function Call Syntax (UFCS) Marko Rauhamaa <marko@pacujo.net> - 2014-06-09 09:25 +0300
                Re: Uniform Function Call Syntax (UFCS) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-09 09:09 +0000
                Re: Uniform Function Call Syntax (UFCS) Chris Angelico <rosuav@gmail.com> - 2014-06-09 19:13 +1000
                Re: Uniform Function Call Syntax (UFCS) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-09 13:37 +0000
                Re: Uniform Function Call Syntax (UFCS) Chris Angelico <rosuav@gmail.com> - 2014-06-10 01:08 +1000
          Re: Uniform Function Call Syntax (UFCS) jongiddy <jongiddy@gmail.com> - 2014-06-08 09:24 -0700
            Re: Uniform Function Call Syntax (UFCS) jongiddy <jongiddy@gmail.com> - 2014-06-08 09:34 -0700
            Re: Uniform Function Call Syntax (UFCS) Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-08 10:54 -0600
            Re: Uniform Function Call Syntax (UFCS) Chris Angelico <rosuav@gmail.com> - 2014-06-09 03:10 +1000
              Re: Uniform Function Call Syntax (UFCS) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-09 03:20 +0000
                Re: Uniform Function Call Syntax (UFCS) Chris Angelico <rosuav@gmail.com> - 2014-06-09 13:44 +1000
                Re: Uniform Function Call Syntax (UFCS) jongiddy <jongiddy@gmail.com> - 2014-06-08 23:38 -0700
                Re: Uniform Function Call Syntax (UFCS) Roy Smith <roy@panix.com> - 2014-06-08 23:45 -0400
      Re: Uniform Function Call Syntax (UFCS) jongiddy <jongiddy@gmail.com> - 2014-06-08 02:25 -0700
        Re: Uniform Function Call Syntax (UFCS) Roy Smith <roy@panix.com> - 2014-06-08 10:59 -0400
          Re: Uniform Function Call Syntax (UFCS) jongiddy <jongiddy@gmail.com> - 2014-06-08 08:39 -0700
            Re: Uniform Function Call Syntax (UFCS) Chris Angelico <rosuav@gmail.com> - 2014-06-09 02:48 +1000
              Re: Uniform Function Call Syntax (UFCS) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-09 03:53 +0000
                Re: Uniform Function Call Syntax (UFCS) Chris Angelico <rosuav@gmail.com> - 2014-06-09 14:53 +1000
                Re: Uniform Function Call Syntax (UFCS) Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-09 08:24 -0600
                Re: Uniform Function Call Syntax (UFCS) jongiddy <jongiddy@gmail.com> - 2014-06-09 23:43 -0700
            Re: Uniform Function Call Syntax (UFCS) Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-08 11:08 -0600
            Re: Uniform Function Call Syntax (UFCS) Chris Angelico <rosuav@gmail.com> - 2014-06-09 03:13 +1000
            Re: Uniform Function Call Syntax (UFCS) Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-08 11:24 -0600
              Re: Uniform Function Call Syntax (UFCS) jongiddy <jongiddy@gmail.com> - 2014-06-08 13:35 -0700
    Re: Uniform Function Call Syntax (UFCS) jongiddy <jongiddy@gmail.com> - 2014-06-08 01:15 -0700
      Re: Uniform Function Call Syntax (UFCS) Paul Sokolovsky <pmiscml@gmail.com> - 2014-06-08 14:52 +0300
      Re: Uniform Function Call Syntax (UFCS) Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-08 11:00 -0600

csiph-web