PEP: Specialization Syntax

Nicolas Fleury nidoizo at yahoo.com
Mon Aug 8 13:22:38 EDT 2005


Kay Schluehr wrote:
> I have to admit that i don't actually understand what you want? The
> problems you try to solve seem trivial to me but it's probably my fault
> and i'm misreading something. You might be correct that your PEP may be
> interesting only if "optional static typing" will be introduced to Py3K
> and then we will suddenly have an immediate need for dealing with
> generic types so that the syntax can be reused for deferred functions (
> the concept of "specialization" is usually coupled with some kind of
> partial evaluation which doesn't take place somewhere in your proposal
> ). But i'm not sure if this makes sense at all. 

Well, the partial evaluation is done when using [].

def getMember[memberName](obj):
     return getattr(obj, memberName)
x = getMember["xyz"]  # specialization
y = x(obj)  # use

I realize the term "specialization" can be confusing, since people might 
think of what is called in C++ "explicit specialization" and "partial 
specialization", while these concepts are not present in the PEP.

The point is that I'm already using static-like typing in frameworks 
interacting with other languages with generic types.  So I would already 
benefit from such a capability, and yes, there's workarounds.  I'm 
clearly in a minority with such a need, but the first point fo the PEP 
is to extend [] syntax, so that it is possible to prototype generic 
types using [] operators.

Regards,
Nicolas




More information about the Python-list mailing list