PEP: Specialization Syntax

Kay Schluehr kay.schluehr at gmx.net
Mon Aug 8 05:26:40 EDT 2005


Nicolas Fleury schrieb:

> Kay Schluehr wrote:
> > def makeClass(cls_name, **kw):
> >     return type(cls_name,(), kw)
> >
> >>>>MyObject = makeClass("MyObject",a=8)
> >>>>MyObject
>
> As said to Bengt, a place is needed to write the class definition.
> There's no need for metaclass in that case:
>
> def makeType(a, b, c=someDefault):
>      arguments = locals()
>      class MyObject:
>          pass # Complete definition here
>      MyObject.__dict__.update(arguments)
>      return MyObject
>
> Regards,
> Nicolas

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. 

Kay




More information about the Python-list mailing list