[IronPython] Similarity with builtin types

mlkjih mlkjih mlkjih at gmail.com
Mon Aug 9 19:58:11 CEST 2010


>We won’t ever support Ruby’s mutation of everything under the sun including
built-in types simply because that’s not something CPython supports.

With clr.LoadClrExtensions using C# extension methods we can extend builtin
types,
public string DoSomething(this string str) ...
so why not just allow use ironpython for this?
String.DoSomething = ...


2010/8/9 Dino Viehland <dinov at microsoft.com>

>  As far as extension methods go – and just extension methods – we may at
> some point in time support them.  We won’t ever support Ruby’s mutation of
> everything under the sun including built-in types simply because that’s not
> something CPython supports.
>
>
>
> The tricky part w/ the extension methods is doing it in a way which is
> per-module instead of at a global scope.  In Ruby so much code mutates
> object that it’s not really a big deal to add in some more mutation of types
> across the system.  But w/ Python these sort of changes have always been
> more closely scoped – for example look at from __future__ import … which
> effects only the current module.  Another example is our own “import clr”
> which makes .NET attributes available on the built-in types.
>
>
>
> I suspect what we’ll end up doing is something like:
>
>
>
> clr.LoadClrExtensions(namespace)
>
>
>
> So it’d end up looking like:
>
>
>
> import System
>
> Import clr
>
> clr.AddReference(System.Linq)
>
>
>
>
>
> I do want to do something to continue to push LINQ forward for 2.7 and
> maybe this will be it if I can get it in…  Tomas added the metadata reader
> which we can use to efficiently get the extension methods and I think I
> might have an idea on how to efficiently share the extension methods across
> modules.
>
>
>
> So I guess the question now would be does that look like a reasonable way
> to load extension methods?
>
>
>
>
>
> *From:* users-bounces at lists.ironpython.com [mailto:
> users-bounces at lists.ironpython.com] *On Behalf Of *mlkjih mlkjih
> *Sent:* Monday, August 09, 2010 9:10 AM
> *To:* users at lists.ironpython.com
> *Subject:* [IronPython] Similarity with builtin types
>
>
>
>
> http://ironpython.net/documentation/dotnet/dotnet.html#similarity-with-builtin-types
> What's the point? Is there any plans to support extension methods,
> something like IronRuby's *using_clr_extensions? With immutable types it
> cannot be done, am I right?*
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100809/64e29bb1/attachment.html>


More information about the Ironpython-users mailing list