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 Default arguments in Python - the return - running out of ideas but...
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
 
spir  
View profile  
 More options May 13 2009, 11:54 am
From: spir <denis.s...@free.fr>
Date: Wed, 13 May 2009 17:54:37 +0200
Local: Wed, May 13 2009 11:54 am
Subject: Re: [Python-ideas] Default arguments in Python - the return - running out of ideas but...
Le Wed, 13 May 2009 11:52:57 -0300,
Jeremy Banks <jer...@jeremybanks.ca> s'exprima ainsi:

> To someone who's a novice to this, could someone explain to me why it
> has to be an existing keyword at all? Since not identifiers are valid
> in that context anyway, why couldn't it be a new keyword that can
> still be used as an identifier in valid contexts? For example (not
> that I advocate this choice of keyword at all):

>     def foo(bar reinitialize_default []): # <-- it's a keyword here
>         reinitialize_default = "It's an identifier here!"

> That would be a syntax error now and if it were defined as a keyword
> only in that context it wouldn't introduce backwards compatibility
> problems and wouldn't force us to reuse an existing keyword in a
> context that may be a bit of a stretch.

> Is there a reason that this wouldn't be a viable approach?

My opinion on this is you're basically right. Even 'print' (for py<3.0) could be an identifier you could use in an assignment (or in any value expression), I guess, for parse patterns are different:
   print_statement : "print" expression
   assignment      : name '=' expression
So you can safely have "print" as name, or inside an expression. Even "print print" should work !

But traditionnally grammars are not built as a single & total definition of the whole language (like is often done using e.g. PEG, see http://en.wikipedia.org/wiki/Parsing_Expression_Grammar) but as a 2-layer definition: one for tokens (lexicon & morphology) and one for higher-level patterns (syntax & structure).
The token layer is performed by a lexer that will not take the context into account to recognize tokens, so that it could not distinguish several, syntactically & semantically different, occurrences of "print"  like above.
As a consequence, in most languages,
  key word = reserved word

There may be other reasons I'm not aware of.

Denis
------
la vita e estrany
_______________________________________________
Python-ideas mailing list
Python-id...@python.org
http://mail.python.org/mailman/listinfo/python-ideas


 
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.