[Python-Dev] PEP 340 -- loose ends

holger krekel hpk at trillke.net
Tue May 3 23:26:36 CEST 2005


[Guido]
> [Holger]
> > However, i would find it much clearer if *defining* blocktemplates
> > used a new keyword, like:
> > 
> >     blocktemplate opening(filename, mode="r"):
> >         ...
> > 
> > because this immediately tells me what the purpose and semantics
> > of the folowing definition is.   The original overloading of 'def' to
> > mean generators if the body contains a yield statement was already a
> > matter of discussion (ASFAIK).  When i came to Python it was at 2.2
> > and i remember wondering about this "def" oddity.
> > 
> > Extending poor old 'def' functions now to possibly mean block
> > templates gives me semantical overload even if it is justified
> > from an implementation point of view.  I am talking purely
> > about (my sense of) code readability here not about implementation.
> 
> Hm... Maybe you also want to have separate function and procedure
> keywords? Or static typing? 'def' can be used to define all sorts of
> things, that is Python's beauty!

Sure, 'def' is nice and i certainly wouldn't introduce 
a new keyword for adding e.g. static typing to function 'defs'.  

But for my taste, blocktemplates derive enough from the
old-style function/sub-routine notion that many people still
think of when seing a 'def'.   When (new) people would see
something like 'blocktemplate ...:' they know they have to
look it up in the language documentation or in some book under
'blocktemplate' instead of trying to figure out (what the
hell) this "function" or "generator" does and how they can 
use it.  Or they might simply think they can invoke it from a 
for-loop which - as far as i understand - could lead to 
silent errors, no? 

Let me add that with the growing number of Python programmers
(as stated in your Pycon2005 keynote) it seems to make sense to
increase  emphasis on how new syntax/concepts will be viewed/used
by possibly 100'dreds of thousands of programmers already
familiar with (some version of) Python. 

But i also see your point of confronting people with
the fact that Python has a nice unified 'def' statement 
so i guess it's a balancing act.  

cheers, 

    holger


More information about the Python-Dev mailing list