[IronPython] .NET Attributes

Dino Viehland dinov at exchange.microsoft.com
Mon Mar 27 08:45:40 PST 2006


This is a tough problem...  There are two issues here.  But the executive summary here is I'd say the earliest you should *expect* to see this is 1.1, but if (somehow) we end up with some extra time we might have something in the 1.0 timeframe (but don't hold your breath!).

The first issue here is that when your code gets compiled we don't create what are truly .NET classes.  Let's forget about old-style classes for a second (as those are REALLY not .NET classes, and never will be) and instead focus on new-style classes.

When you define a class we'll see if anyone else has inherited from the same set of base-types (including .NET interfaces).  If someone has then we'll use that class instead of creating a new class.  If they haven't we'll derive a new class from your base-class set, overriding all of the virtual methods, and creating some new fields like __dict__ and __class__.  Those fields allow us to both allow you to change the type of your classes at runtime as well as attach new properties to instances.  They also allow us to create a limited number of CLR types (which aren't garbage collected) which means long-running programs creating lots of types don't leak.

In the end there's not really anything good for us to attach the attributes to.  To get that we'd need to move to a more static-compilation model while at the same time retaining the ability to do all the great dynamic stuff with Python.  It's a hard problem and one that we simply haven't solved yet.

The second problem is also just as tough, but it's completely different.  How do you even express an attribute on a class?  There's no Python syntax for this so we'd have to add something new.  It'd be great if we could use decorators here, but they don't apply to classes.  So maybe that's something like __attributes__ = [Serializable, ...] or something along those lines but it's not clear what's the best way to go here...



Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Andrzej Krzywda
Sent: Monday, March 27, 2006 4:55 AM
To: users at lists.ironpython.com
Subject: [IronPython] .NET Attributes

Hi,

When there will be support for .NET Attributes in IronPython?
Is there any way currently to mark my class as Serializable?

--
Andrzej
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


More information about the users mailing list