Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73001
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'syntax': 0.04; 'importing': 0.05; 'attribute': 0.07; 'practice,': 0.07; 'string': 0.09; 'ambiguity': 0.09; 'parameter': 0.09; 'sake': 0.09; 'subject:Function': 0.09; 'used.': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; '2),': 0.16; 'argument.': 0.16; 'bitwise': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'least.': 0.16; 'massively': 0.16; 'namespace.': 0.16; 'notation': 0.16; 'partly': 0.16; 'positional': 0.16; 'syntactic': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'equivalent': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'point': 0.28; 'function': 0.29; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; "d'aprano": 0.31; 'pipe': 0.31; 'skip:r 60': 0.31; 'steven': 0.31; 'though.': 0.31; '"the': 0.34; 'maybe': 0.34; 'could': 0.34; 'subject: (': 0.35; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'really': 0.36; 'skip:s 60': 0.36; 'useful': 0.36; 'clear': 0.37; 'needed': 0.38; 'pm,': 0.38; 'bad': 0.39; 'itself': 0.39; 'though,': 0.39; 'sure': 0.39; 'how': 0.40; 'even': 0.60; 'middle': 0.60; 'solve': 0.60; 'first': 0.61; 'name': 0.63; 'such': 0.63; 'become': 0.64; 'different': 0.65; 'talking': 0.65; 'here': 0.66; "it'd": 0.84; 'pike': 0.84; 'absolutely': 0.87; 'pipeline': 0.91; 'to:none': 0.92; 'imagine': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=haUtsWR4W17BIRL3vL15wVOcfHB00WDnd6ktzd2MGhQ=; b=burAXLteaC5zbXXnQ+0SP2uElmfzdiofwxN/mbj3bvNOSlNN9Qrl9I2kJeL3mmgdCy ATy+BNbyPObsSgBN84PRZ9s7bNheWwKrlyvU+P8FNZv8Y0BrQ4M8f5XjTToMyTEkFwAa ZasCcly+tq/pCkWwu6gaFtRX8/PLJTp4WY7eCYHpHprEzzTeqr8Lz41ZGC+fF4EmInzL gaDZcRIeV+nrvmBJrcoSxIG9bt2RLPtC963760PyrHK6HTbutm3b42HaJyTlHWqgn1LY w3U6NF8VabDpQDSPhmOoVM9i3l8vrY1HmhnTCe4q7XovRY149CyAEVuquJicYrXesTXy +r3w== |
| MIME-Version | 1.0 |
| X-Received | by 10.58.229.101 with SMTP id sp5mr21492427vec.42.1402285463074; Sun, 08 Jun 2014 20:44:23 -0700 (PDT) |
| In-Reply-To | <53952807$0$29988$c3e8da3$5496439d@news.astraweb.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> <mailman.10876.1402229177.18130.python-list@python.org> <12d31393-3598-4304-8ce9-ac847ac21c64@googlegroups.com> <mailman.10886.1402247406.18130.python-list@python.org> <53952807$0$29988$c3e8da3$5496439d@news.astraweb.com> |
| Date | Mon, 9 Jun 2014 13:44:22 +1000 |
| Subject | Re: Uniform Function Call Syntax (UFCS) |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.10903.1402285465.18130.python-list@python.org> (permalink) |
| Lines | 55 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1402285465 news.xs4all.nl 2890 [2001:888:2000:d::a6]:51732 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:73001 |
Show key headers only | View raw
On Mon, Jun 9, 2014 at 1:20 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Mon, 09 Jun 2014 03:10:03 +1000, Chris Angelico wrote:
> [...]
>> Stdio.write_file("foo.png",Image.PNG.encode(Image.JPEG.decode(
>> Stdio.read_file("foo.jpg")).autocrop().rotate(0.5).grey()));
>>
>> With UFCS, that could become perfect data flow:
>>
>> read_file("foo.jpg").JPEG_decode().autocrop().rotate(0.5).grey()
>> .PNG_encode().write_file("foo.png");
>>
>> I had to solve the syntactic ambiguity here by importing all the
>> appropriate names
>
> I'm not sure how this is *syntactic* ambiguity.
The ambiguity I'm talking about here is with the dot. The original
version has "Stdio.read_file" as the first function called; for a
Python equivalent, imagine a string processing pipeline and having
"re.sub" in the middle of it. You can't take "re.sub" as the name of
an attribute on a string without some fiddling around that completely
destroys the point of data-flow syntax. So I cheated, and turned
everything into local (imported) names (adorning the ones that needed
it). This is a bad idea in Pike for the same reason it's a bad idea in
Python - you end up with a massively polluted global namespace.
This could be solved, though, by having a completely different symbol
that means "the thing on my left is actually the first positional
parameter in the function call on my right", such as in your example:
> plus(1, 2) | divide(2)
This would be absolutely identical to:
divide(plus(1, 2), 2)
Maybe you could even make it so that:
plus(1, 2) x=| divide(y=2)
is equivalent to
divide(x=plus(1, 2), y=2)
for the sake of consistency, and to allow the pipeline to inject
something someplace other than the first argument.
I'm not sure whether it'd be as useful in practice, though. It would
depend partly on the exact syntax used. Obviously the pipe itself
can't be used as it already means bitwise or, and this needs to be
really REALLY clear about what's going on. But a data-flow notation
would be of value in theory, at least.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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