What about some sort of switcher to enable ironpython specific features?<br><br>import allow_builtin_type_extensions<br><br><div class="gmail_quote">2010/8/9 Dino Viehland <span dir="ltr">&lt;<a href="mailto:dinov@microsoft.com">dinov@microsoft.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">





<div link="blue" vlink="purple" lang="EN-US">
<div>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Because you can’t do that in CPython.  If we enabled that we’d certainly instantly start failing a number of tests and we might subtly break compatibility
 of libraries that might try do assign, catch a TypeError/AttributeError, and then do something else (even if that sounds like a terrible idea).</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">I also think it’s nicer to be explicit here that you’re doing something which requires IronPython by forcing the “import clr” so that it’s clearer this code
 won’t work on CPython.</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<div style="border-width: medium medium medium 1.5pt; border-style: none none none solid; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color blue; padding: 0in 0in 0in 4pt;">
<div>
<div style="border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; padding: 3pt 0in 0in;">
<p class="MsoNormal"><b><span style="font-size: 10pt;">From:</span></b><span style="font-size: 10pt;"> <a href="mailto:users-bounces@lists.ironpython.com" target="_self">users-bounces@lists.ironpython.com</a> [mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_self">users-bounces@lists.ironpython.com</a>]
<b>On Behalf Of </b>mlkjih mlkjih<br>
<b>Sent:</b> Monday, August 09, 2010 10:58 AM<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> Re: [IronPython] Similarity with builtin types</span></p>
</div>
</div><div><div></div><div class="h5">
<p class="MsoNormal"> </p>
<p class="MsoNormal" style="margin-bottom: 12pt;">&gt;<span style="font-size: 11pt; color: rgb(31, 73, 125);">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.</span><br>

<span style="font-size: 11pt; color: rgb(31, 73, 125);"><br>
With clr.LoadClrExtensions using C# extension methods we can extend builtin types,<br>
public string DoSomething(this string str) ...<br>
so why not just allow use ironpython for this?<br>
String.DoSomething = ...<br>
<br>
</span></p>
<div>
<p class="MsoNormal">2010/8/9 Dino Viehland &lt;<a href="mailto:dinov@microsoft.com" target="_self">dinov@microsoft.com</a>&gt;</p>
<div>
<div>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">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.</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">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.</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">I suspect what we’ll end up doing is something like:</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">clr.LoadClrExtensions(namespace)</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">So it’d end up looking like:</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">import System</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Import clr</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">clr.AddReference(System.Linq)</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">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.</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">So I guess the question now would be does that look like a reasonable way to load extension methods?
</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<div style="border-width: medium medium medium 1.5pt; border-style: none none none solid; padding: 0in 0in 0in 4pt; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color blue;">
<div>
<div style="border-width: 1pt medium medium; border-style: solid none none; padding: 3pt 0in 0in; border-color: -moz-use-text-color;">
<p class="MsoNormal"><b><span style="font-size: 10pt;">From:</span></b><span style="font-size: 10pt;">
<a href="mailto:users-bounces@lists.ironpython.com" target="_self">users-bounces@lists.ironpython.com</a> [mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_self">users-bounces@lists.ironpython.com</a>]
<b>On Behalf Of </b>mlkjih mlkjih<br>
<b>Sent:</b> Monday, August 09, 2010 9:10 AM<br>
<b>To:</b> <a href="mailto:users@lists.ironpython.com" target="_self">users@lists.ironpython.com</a><br>
<b>Subject:</b> [IronPython] Similarity with builtin types</span></p>
</div>
</div>
<div>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><a href="http://ironpython.net/documentation/dotnet/dotnet.html#similarity-with-builtin-types" target="_self">http://ironpython.net/documentation/dotnet/dotnet.html#similarity-with-builtin-types</a><br>

What&#39;s the point? Is there any plans to support extension methods, something like IronRuby&#39;s
<i>using_clr_extensions? With immutable types it cannot be done, am I right?</i></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom: 12pt;"><br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_self">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_self">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a></p>
</div>
<p class="MsoNormal"> </p>
</div></div></div>
</div>
</div>

<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_self">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br></blockquote></div><br>