[Python-Dev] A solution to the evils of static typing and interfaces?

Simon Belak simon.belak at hruska.si
Fri Oct 21 04:34:02 CEST 2005


Hi,

I was thinking why not have a separate file for all the proposed 
optional meta-information (in particular interfaces, static types)? 
Something along the lines of IDLs in CORBA (with pythonic syntax, of 
curse). This way most of the benefits are retained without 
"contaminating" the actual syntax (dare I be so pretentious to even hope 
making both sides happy?).

For the sole purpose of illustration, let meta-files have extension .pym 
and linking to source-files be name based:

parrot.py
parrot.pym
(parrot.pyc)

With some utilities like a prototype generator (to and from meta-files) 
and a synchronization tool, time penalty on development for having two 
separate files could be kept within reason.

We could even go as far as introducing a syntax allowing custom 
meta-information to be added.

For example something akin to decorators.

parrot.pym:

@sharedinstance
class Parrot:
	
	# Methods
	# note this are only prototypes so no semicolon or suite is needed
	
	@cache
	def playDead(a : int, b : int) -> None
	
	# Attributes
	
	@const
	name : str

where sharedinstance, cache and const are custom meta-information.

This opens up countless possibilities for third-party interpreter 
enchantments and/or optimisations by providing a fully portable (as all 
meta-information are optional) language extensions.


P.S. my sincerest apologies if I am reopening a can of worms here


More information about the Python-Dev mailing list