Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion from future import pass_function
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
rusi  
View profile  
 More options Jul 26 2012, 11:01 am
Newsgroups: comp.lang.python
From: rusi <rustompm...@gmail.com>
Date: Thu, 26 Jul 2012 08:01:56 -0700 (PDT)
Local: Thurs, Jul 26 2012 11:01 am
Subject: Re: from future import pass_function
On Jul 25, 1:40 pm, Ulrich Eckhardt <ulrich.eckha...@dominolaser.com>
wrote:

> Hi!

> I just had an idea, it occurred to me that the pass statement is pretty
> similar to the print statement, and similarly to the print() function,
> there could be a pass() function that does and returns nothing.

> Example:
>     def pass():
>         return

Since many have said NO but I see no good reasons for this no yet,
here's mine:

tl;dr version: Do-nothing statements are easy just do nothing, ie
pass.
Do-nothing expressions are hard. In the fully generic context they are
impossible to implement.

Longer version:

Consider the if expression and the if statement. The if statement can
have its else part elided in which case it defaults to pass.  The if
expression cannot so elide. Why?

Consider the expression: (exp if cond)  # no else
Now in "x + (exp if cond)" if cond is false it should presumably be 0
However in "x * (exp if cond)" it should presumably be 1?
And in the first case if x were a list should it not be [] ?

Now consider your suggestion:
def pass(): return
is identical to
def pass(): return None

So you are saying that None can serve as a "generic zero"?
Of course as you know (no suggestion that you are a noob on my part!!)

Python 2.7.3rc2 (default, Apr 22 2012, 22:35:38)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> 0+3
3
>>> None+3

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
>>> None+[1,2,3]

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'


So now you (may) retort but these have nothing to do with what you
asked.

You see what youve asked for is moving pass from the statement world
to the expression world.
The meaning of a do-nothing statement is easy to give.  The meaning of
a do-nothing expression is hard because we are obliged to specify a
type for expressions and the only value that can possibly belong to
all types is the error-value (what denotational semantics calls bottom
⊥ )

A more laymanish example:
I have a multiplication
I want one of the operands to be a 1, ie the identity
I substitute it with the nearest available value ie 0

And out goes the baby with the bathwater!

So to come back to your proposal:

> there could be a pass() function that does and returns nothing.

does nothing: easy
returns nothing: impossible (None is not "nothing", its more like
"error")

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.