Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Steven D'Aprano
Roy Smith wrote: > In article <54ba5a25$0$12991$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> Whitespace is significant in nearly all programming languages, and so it >> should be. Whitespace separates tokens, and lines, and is a natural way >> of writing (at least for peop

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Gregory Ewing
Jussi Piitulainen wrote: I prefer parentheses. They are not nearly as fragile. So do I, but the other day I had occasion to write a small piece of VBScript, and I discovered that it actually *forbids* parens around the arguments to procedure calls (but not function calls). Fortunately, it requ

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Chris Angelico
On Sun, Jan 18, 2015 at 8:56 AM, Gregory Ewing wrote: > Ruby doesn't have that problem because it doesn't > have functions, only methods, and the only thing you > can do with a method in Ruby is call it. So functions aren't first-class objects in Ruby? Bleh. I've become quite accustomed to passin

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Gregory Ewing
Chris Angelico wrote: Every once in a while, someone looks at Py2's print statement and Py3's print function and says, "why not allow function calls without parentheses". This right here is why not. There's also the fact that the parens are needed to distinguish between calling a function and u

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Gregory Ewing
Steven D'Aprano wrote: def a(x=4) x+2 end a + b => 7 a+b => 7 a+ b => 7 a +b => 3 A shiny new penny for any non-Ruby coder who can explain that! Seems pretty obvious to me: the Ruby interpreter is infested with demons. DWIM = Demonic Whim Infers Meaning -- Greg -- https://mail.pyth

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread alister
On Sat, 17 Jan 2015 19:08:21 +, Dan Sommers wrote: > On Sat, 17 Jan 2015 18:44:42 +, Grant Edwards wrote: > >> ... somebody who only knows how to write C++ [though he can do it in >> several different languages]. > > +1 QOTW (brilliant phrases in other threads are off topic and are > dis

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Dan Sommers
On Sat, 17 Jan 2015 18:44:42 +, Grant Edwards wrote: > ... somebody who only knows how to write C++ [though he can do it in > several different languages]. +1 QOTW (brilliant phrases in other threads are off topic and are disqualified) I have also suffered through such maintenance, but I hav

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Grant Edwards
On 2015-01-17, Roy Smith wrote: > In article <54ba39e0$0$13008$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> Every time I think I would like to learn a new language, I quite quickly run >> into some obvious feature that Python has but the newer language lacks, and >> I think

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Grant Edwards
On 2015-01-16, Gregory Ewing wrote: > We're really quite spoiled in Python-land. It's easy > to forget just *how* spoiled we are until you go back > and try to do something in one of the more primitive > languages... I had to do some work in PHP yesterday -- fixing up some code that was written

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread alister
On Sat, 17 Jan 2015 21:33:19 +1100, Steven D'Aprano wrote: > Gregory Ewing wrote: > >> Marko Rauhamaa wrote: >>> Gregory Ewing : >>> If those are 24-bit RGB pixels, you could encode 3 characters in each pixel. >>> >>> Not since Python3. Characters are Unicode now so you'll need to >>> d

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Roy Smith
In article <54ba5a25$0$12991$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Whitespace is significant in nearly all programming languages, and so it > should be. Whitespace separates tokens, and lines, and is a natural way of > writing (at least for people using Western languages)

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Roy Smith
In article , Skip Montanaro wrote: > On Sat, Jan 17, 2015 at 5:59 AM, Jussi Piitulainen > wrote: > > How far do you want to go? Is "a b + c" the same as "a(b) + c" or the > > same as "a(b + c)"? > > I think there is only one practical interpretation, the one that all > shells I'm familiar wit

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Roy Smith
In article <54ba39e0$0$13008$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Every time I think I would like to learn a new language, I quite quickly run > into some obvious feature that Python has but the newer language lacks, and > I think "bugger this for a game of soldiers" and

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Danilo Coccia
Il 17/01/2015 12.07, Marko Rauhamaa ha scritto: > Jussi Piitulainen : > >> a+ b => 7 # a() + b >> a +b => 3 # a(+b) => a(b) => a(1) = 1 + 2 >> >> I'm not quite fond of such surprise in programming language syntax. > > Yes, whoever came up with the idea of whitespace having syntactic > sig

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Chris Angelico
On Sat, Jan 17, 2015 at 9:49 PM, Jussi Piitulainen wrote: > I've only seen small amounts of Ruby code on the net. The only way I > can make some sense of that is if it gets analyzed as follows, using > parentheses for calls: > > a + b => 7 # a() + b => a(4) + b => 4 + 2 + 1 > a+b => 7 # a()

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Jussi Piitulainen
Skip Montanaro writes: > On Sat, Jan 17, 2015 at 5:59 AM, Jussi Piitulainen wrote: > > How far do you want to go? Is "a b + c" the same as "a(b) + c" or > > the same as "a(b + c)"? > > I think there is only one practical interpretation, the one that all > shells I'm familiar with have adopted: >

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Jussi Piitulainen
Marko Rauhamaa writes: > Seriously, though, I hate the optional semicolon rules of JavaScript > and Go. I dread the day when GvR gets it in his head to allow this > syntax in Python: > >average_drop_rate = cumulative_drop_count / >observation_period > > (although, it could be defined

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Steven D'Aprano
Jussi Piitulainen wrote: > I've only seen small amounts of Ruby code on the net. The only way I > can make some sense of that is if it gets analyzed as follows, using > parentheses for calls: > > a + b => 7 # a() + b => a(4) + b => 4 + 2 + 1 > a+b => 7 # a() + b > a+ b => 7 # a() + b >

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Jussi Piitulainen : > >> a+ b => 7 # a() + b >> a +b => 3 # a(+b) => a(b) => a(1) = 1 + 2 >> >> I'm not quite fond of such surprise in programming language syntax. > > Yes, whoever came up with the idea of whitespace having syntactic > significance! Yes, we shoul

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Marko Rauhamaa
Jussi Piitulainen : > Marko Rauhamaa writes: >> Yes, whoever came up with the idea of whitespace having syntactic >> significance! > > How far do you want to go? [...] > > I prefer parentheses. They are not nearly as fragile. *cough* braces *cough* Seriously, though, I hate the optional semicolo

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Skip Montanaro
On Sat, Jan 17, 2015 at 5:59 AM, Jussi Piitulainen wrote: > How far do you want to go? Is "a b + c" the same as "a(b) + c" or the > same as "a(b + c)"? I think there is only one practical interpretation, the one that all shells I'm familiar with have adopted: a(b, +, c) > And I don't reall

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Jussi Piitulainen
Marko Rauhamaa writes: > Jussi Piitulainen: > > > a+ b => 7 # a() + b > > a +b => 3 # a(+b) => a(b) => a(1) = 1 + 2 > > > > I'm not quite fond of such surprise in programming language > > syntax. > > Yes, whoever came up with the idea of whitespace having syntactic > significance! How fa

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Marko Rauhamaa
Jussi Piitulainen : > a+ b => 7 # a() + b > a +b => 3 # a(+b) => a(b) => a(1) = 1 + 2 > > I'm not quite fond of such surprise in programming language syntax. Yes, whoever came up with the idea of whitespace having syntactic significance! Marko -- https://mail.python.org/mailman/listinf

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Jussi Piitulainen
Steven D'Aprano writes: > Ah, wait, I forgot Ruby's brilliant "feature" that whitespace > *between* expressions is significant: > > [steve@ando ~]$ cat ~/coding/ruby/ws-example.rb > #!/usr/bin/ruby > > def a(x=4) > x+2 > end > > b = 1 > print "a + b => ", (a + b), "\n" > print "a+b => ",

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Steven D'Aprano
Gregory Ewing wrote: > We're really quite spoiled in Python-land. It's easy > to forget just how spoiled we are until you go back > and try to do something in one of the more primitive > languages... Every time I think I would like to learn a new language, I quite quickly run into some obvious fe

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Steven D'Aprano
Gregory Ewing wrote: > Marko Rauhamaa wrote: >> Gregory Ewing : >> >>>If those are 24-bit RGB pixels, you could encode >>>3 characters in each pixel. >> >> Not since Python3. Characters are Unicode now so you'll need to dedicate >> a pixel for each character. > > Depends on which characters you

Re: lambdak: multi-line lambda implementation in native Python

2015-01-16 Thread Gregory Ewing
Chris Angelico wrote: Is this to get around style guides that reject this kind of model: x = Foo( opt1=True, opt2=True, color=Yellow, ) It's to get around the fact that you *can't* do that in Java, because it doesn't have keyword arguments. This is a source of a lot of the complex

Re: lambdak: multi-line lambda implementation in native Python

2015-01-16 Thread Gregory Ewing
Marko Rauhamaa wrote: Gregory Ewing : If those are 24-bit RGB pixels, you could encode 3 characters in each pixel. Not since Python3. Characters are Unicode now so you'll need to dedicate a pixel for each character. Depends on which characters you want. With the Flexible Chromatic Represent

Re: lambdak: multi-line lambda implementation in native Python

2015-01-16 Thread Michael Torrie
On 01/15/2015 10:29 PM, Ian Kelly wrote: > On Thu, Jan 15, 2015 at 9:00 PM, Chris Angelico wrote: >> My first response was going to be "Well, you can always add another >> layer of indirection to try to solve your problem", but then I went >> and looked up builders on Wikipedia. Now I'm confused.

Re: lambdak: multi-line lambda implementation in native Python

2015-01-16 Thread Marko Rauhamaa
Gregory Ewing : > Dennis Lee Bieber wrote: >> On Fri, 16 Jan 2015 01:50:00 +1100, Chris Angelico >> declaimed the following: >> >>>Problem: You have a smartphone with a 4x4 pixel screen. >> >> BIG problem, considering that a late 70s DECWriter needed 5x7 >> pixels for glyphs in an 8x10 pixel

Re: lambdak: multi-line lambda implementation in native Python

2015-01-16 Thread Gregory Ewing
Dennis Lee Bieber wrote: On Fri, 16 Jan 2015 01:50:00 +1100, Chris Angelico declaimed the following: > Problem: You have a smartphone with a 4x4 pixel screen. BIG problem, considering that a late 70s DECWriter needed 5x7 pixels for glyphs in an 8x10 pixel character cell {as I recall.

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Ethan Furman
On 01/15/2015 09:29 PM, Ian Kelly wrote: > > In Python you just have one initializer with defaults for the optional > arguments, so it's not an issue. What, Python makes it easy? That must be a mistake somewhere! ;) -- ~Ethan~ signature.asc Description: OpenPGP digital signature -- https:/

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Ian Kelly
On Thu, Jan 15, 2015 at 9:00 PM, Chris Angelico wrote: > My first response was going to be "Well, you can always add another > layer of indirection to try to solve your problem", but then I went > and looked up builders on Wikipedia. Now I'm confused. What can you do > with a builder that you can'

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Rustom Mody
On Friday, January 16, 2015 at 9:46:30 AM UTC+5:30, Steven D'Aprano wrote: > Rustom Mody wrote: > > > Let there be a hundred different versions, then people will > > begin to clamor against the non-necessity of the penury-of-ASCII: > > > > http://blog.languager.org/2015/01/unicode-and-universe.ht

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Steven D'Aprano
Yawar Amin wrote: > To the responders in the 'beauty of the code' subthread: yes, I realise > that lambdak is not Pythonic, and it will make angels cry, and all that. > My view is you should actually be happy that it looks like this. If > anyone ever asks about multi-line lambdas again, you can po

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Steven D'Aprano
Rustom Mody wrote: > Let there be a hundred different versions, then people will > begin to clamor against the non-necessity of the penury-of-ASCII: > > http://blog.languager.org/2015/01/unicode-and-universe.html Almost 30 years ago, Apple's Hypertalk language allowed, and encouraged, the use of

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Chris Angelico
On Fri, Jan 16, 2015 at 12:44 PM, Michael Torrie wrote: > On 01/15/2015 06:34 PM, Roy Smith wrote: >> The ebb and flow of technology has recently brought me someplace I never >> thought I'd be. Java-land. And what I've discovered is that factories >> are so last year. Apparently builders are th

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Yawar Amin
On Thursday, January 15, 2015 at 10:06:34 PM UTC-5, Rick Johnson wrote: > [...] > Well i'm not religious in that way, but i can tell you that > you'd be hard pressed to find a subject that did *NOT* > annoy someone in this group. Heck, it might even be > something like finding a "holy grail" if we

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Rustom Mody
On Friday, January 16, 2015 at 8:33:14 AM UTC+5:30, Mark Lawrence wrote: > On 16/01/2015 02:48, Rustom Mody wrote: > > > > The more forks the merrier! > > > > When counting them, or more specifically handles, thou shalt not stop > counting at three, but thou shalt continue to four, and thou shalt

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Rick Johnson
On Wednesday, January 14, 2015 at 11:55:11 PM UTC-6, Yawar Amin wrote: > First off, to each reader--if you believe that 'multi- > line' lambdas are no good and we can just use functions, > decorators, &c. to accomplish everything in Python, > advance warning: this post will annoy you. Well i'm not

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Mark Lawrence
On 16/01/2015 02:48, Rustom Mody wrote: The more forks the merrier! When counting them, or more specifically handles, thou shalt not stop counting at three, but thou shalt continue to four, and thou shalt not continue on to five https://www.youtube.com/watch?v=Cz2-ukrd2VQ -- My fellow Pyt

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Rustom Mody
On Friday, January 16, 2015 at 7:48:20 AM UTC+5:30, Yawar Amin wrote: > Hi, > > On Thursday, January 15, 2015 at 12:19:31 PM UTC-5, Rustom Mody wrote: > > [...] > > Looked at your suggestions... > > And then got distracted by your other project > > https://github.com/yawaramin/vim-cute-python > >

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Yawar Amin
Hi, On Thursday, January 15, 2015 at 12:19:31 PM UTC-5, Rustom Mody wrote: > [...] > Looked at your suggestions... > And then got distracted by your other project > https://github.com/yawaramin/vim-cute-python > > Reminded me of what I had written some months ago along similar lines > http://blog

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Mark Lawrence
On 16/01/2015 01:44, Michael Torrie wrote: On 01/15/2015 06:34 PM, Roy Smith wrote: The ebb and flow of technology has recently brought me someplace I never thought I'd be. Java-land. And what I've discovered is that factories are so last year. Apparently builders are the new thing. It's ne

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Yawar Amin
On Thursday, January 15, 2015 at 1:40:09 AM UTC-5, Ian wrote: > On Wed, Jan 14, 2015 at 11:06 PM, Steven D'Aprano > wrote: > [...] > > def func(a, b=None): > > global spam > > import math > > spam = [a, b]*3 > > print spam > > del spam > > > > value = [1, "hello", int, func] >

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Michael Torrie
On 01/15/2015 06:34 PM, Roy Smith wrote: > The ebb and flow of technology has recently brought me someplace I never > thought I'd be. Java-land. And what I've discovered is that factories > are so last year. Apparently builders are the new thing. It's never clear to me whether all these fancy

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Roy Smith
In article <87zj9kb2j0@elektro.pacujo.net>, Marko Rauhamaa wrote: > Skip Montanaro : > > > Beautiful is better than ugly. > > Yes, our job is to increase the Harmony of the Universe. Useful > applications are happy side effects. > > > Explicit is better than implicit. > > Corollary: Cons

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Mark Lawrence
On 15/01/2015 06:39, Ian Kelly wrote: On Wed, Jan 14, 2015 at 11:06 PM, Steven D'Aprano wrote: I have a function, which I put into an expression like this: def func(a, b=None): global spam import math spam = [a, b]*3 print spam del spam value = [1, "hello", int, func

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Rustom Mody
On Thursday, January 15, 2015 at 11:25:11 AM UTC+5:30, Yawar Amin wrote: > Hi all, > > First off, to each reader--if you believe that 'multi-line' lambdas are > no good and we can just use functions, decorators, &c. to accomplish > everything in Python, advance warning: this post will annoy you. >

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Chris Angelico
On Fri, Jan 16, 2015 at 1:24 AM, Steven D'Aprano wrote: > Marko Rauhamaa wrote: > >> Corollary: Make sure the complete definition of every function can be >> seen at once without scrolling. > > Problem: I like to view code on a smartphone with a 4x4 pixel screen, and > the scroll bars obscure the

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Skip Montanaro
On Thu, Jan 15, 2015 at 8:29 AM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > Now I shall try very hard to forget I ever saw it. There are some things, no matter how hard you try, which cannot be "unseen". :-) Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Steven D'Aprano
Ian Kelly wrote: > On Wed, Jan 14, 2015 at 11:06 PM, Steven D'Aprano > wrote: >> I have a function, which I put into an expression like this: >> >> def func(a, b=None): >> global spam >> import math >> spam = [a, b]*3 >> print spam >> del spam >> >> >> value = [1, "hello", int

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Corollary: Make sure the complete definition of every function can be > seen at once without scrolling. Problem: I like to view code on a smartphone with a 4x4 pixel screen, and the scroll bars obscure the text. Solution: Change the editor to a 1pt font. -- Steven --

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Marko Rauhamaa
Skip Montanaro : > Beautiful is better than ugly. Yes, our job is to increase the Harmony of the Universe. Useful applications are happy side effects. > Explicit is better than implicit. Corollary: Constructors are usually preferable to factories. > Simple is better than complex. Corollary: M

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Skip Montanaro
On Thu, Jan 15, 2015 at 7:04 AM, Roy Smith wrote: > I don't know which zen this is, but "Beauty is important". Kinda near the front: % python -m this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. ... :-) Skip

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Chris Angelico
On Fri, Jan 16, 2015 at 12:04 AM, Roy Smith wrote: > I don't know which zen this is, but "Beauty is important". How about: Beautiful is better than ugly. Readability counts. If the implementation is hard to explain, it's a bad idea. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Roy Smith
yawar.a...@gmail.com wrote: > I have implemented what I believe is a > fairly robust, if ugly-looking, native Python module I don't know which zen this is, but "Beauty is important". -- https://mail.python.org/mailman/listinfo/python-list

Re: lambdak: multi-line lambda implementation in native Python

2015-01-14 Thread Ian Kelly
On Wed, Jan 14, 2015 at 11:06 PM, Steven D'Aprano wrote: > I have a function, which I put into an expression like this: > > def func(a, b=None): > global spam > import math > spam = [a, b]*3 > print spam > del spam > > > value = [1, "hello", int, func] > del func > > How would

Re: lambdak: multi-line lambda implementation in native Python

2015-01-14 Thread Steven D'Aprano
On Wed, 14 Jan 2015 21:54:52 -0800, yawar.amin wrote: > Now, the crux of my message. I have implemented what I believe is a > fairly robust, if ugly-looking, native Python module made up of > combinator functions which compose together to form function expressions > (well, callable expressions).

lambdak: multi-line lambda implementation in native Python

2015-01-14 Thread yawar . amin
Hi all, First off, to each reader--if you believe that 'multi-line' lambdas are no good and we can just use functions, decorators, &c. to accomplish everything in Python, advance warning: this post will annoy you. Now, the crux of my message. I have implemented what I believe is a fairly robust,