Func/Action delegates are in System.Core assembly and System namespace in CLR4.
So you need to import them conditionally based on current .NET version.

If you use IronPython on .NET 3.5 you'll get 2 different Func/Action delegate 
sets - one in [Microsoft.Scripting]Microsoft.Scripting.Utils and the other in 
[System.Core]System.
It shouldn't matter much which ones do you use. 

Tomas

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Michael Foord
Sent: Monday, September 14, 2009 1:19 PM
To: Discussion of IronPython
Subject: Re: [IronPython] CallTargetX delegates

Tomas Matousek wrote:
>
> We’ve made change recently (last week) on .NET 2.0 you’ll need to use 
> a different namespace and assembly:
>
>  
>
> import clr
>
> clr.AddReference(‘Microsoft.Scripting’)
>
> from Microsoft.Scripting.Utils import Func
>
> Func[object, object](targetCallableHere)
>

Will this work cross-version? (i.e. will it also work on .NET 3 & 4?)

Michael

>  
>
> Tomas
>
>  
>
> *From:* [email protected]
> [mailto:[email protected]] *On Behalf Of *Michael 
> Foord
> *Sent:* Monday, September 14, 2009 11:04 AM
> *To:* Discussion of IronPython
> *Cc:* Discussion of IronPython
> *Subject:* Re: [IronPython] CallTargetX delegates
>
>  
>
>  
>
>  
>
> --
>
> http://www.ironpythoninaction.com
>
>
> On 14 Sep 2009, at 18:59, Dino Viehland <[email protected] 
> <mailto:[email protected]>> wrote:
>
>     To use Func you just need to do:
>
>      
>
>     import clr
>
>     clr.AddReference(‘System.Core’)
>
>     from System import Func
>
>     Func[object, object](targetCallableHere)
>
>      
>
>     This is equivalent to CallTarget1.  You can add more “object, “ or
>     you can replace object with some other type.
>
>  
>
> It is of course dependent on .NET 3.
>
>  
>
> Michael
>
>  
>
>  
>
>
>
>  
>
> *From:* [email protected]
> <mailto:[email protected]>
> [mailto:[email protected]] *On Behalf Of *Brian 
> Curtin
> *Sent:* Monday, September 14, 2009 10:53 AM
> *To:* Discussion of IronPython
> *Subject:* Re: [IronPython] CallTargetX delegates
>
>  
>
> How would someone replace CallTargetX with Func<...> within a script? 
> For example, how would you change the Invoke calls in onChanged and 
> onRenamed here:
> http://www.ironpython.info/index.php/Invoking_onto_the_GUI_%28Control%
> 29_Thread
>
> I've never seen how to use Func within an IP script, just within C#.
>
>
> On Wed, Sep 2, 2009 at 04:59, Davy Mitchell <[email protected] 
> <mailto:[email protected]>> wrote:
>
> Could someone pop an example of this on http://www.ironpython.info?
> Sounds like it could be a common 'gotcha' especially for newbies 
> running old example code.
>
> Cheers,
> Davy
>
>
> On Wed, Sep 2, 2009 at 6:38 AM, David Escobar<[email protected] 
> <mailto:[email protected]>> wrote:
> > Ok cool. I've used Func<> from C# before. That did the trick. Thanks.
> >
> >
> > On Tue, Sep 1, 2009 at 6:19 PM, Dino Viehland <[email protected]
> <mailto:[email protected]>> wrote:
> >>
> >> Yes.  CallTarget’s were really a part of IronPython’s internal 
> >> calling convention for used defined functions.  We kept CallTarget0 
> >> around
> because
> >> we knew lots of users had come to depend on that one when they 
> >> needed a delegate type.  But we removed all the others and switched 
> >> to using
> Func<…>
> >> internally.  Ideally you can switch to using Func<> as well.
> >>
> >>
> >>
> >> From: [email protected]
> <mailto:[email protected]>
> >> [mailto:[email protected]
> <mailto:[email protected]>] On Behalf Of David 
> Escobar
> >> Sent: Tuesday, September 01, 2009 5:41 PM
> >> To: Discussion of IronPython
> >> Subject: [IronPython] CallTargetX delegates
> >>
> >>
> >>
> >> In IronPython 2.6 beta 2, did the CallTargetX delegates get moved 
> >> to another module or were they simply removed altogether? The only
> delegate in
> >> IronPython.Compiler is CallTarget0. I checked IronPython 2.0.2 and
> it has up
> >> to CallTarget16.
> >
>
> > _______________________________________________
> > Users mailing list
> > [email protected] <mailto:[email protected]>
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
> >
>
>
>
> --
> --
>  Davy Stuff  - http://daftspaniel.blogspot.com  Geeky Stuff  - 
> http://daftpython.blogspot.com  Davy's Ironpython Editor - 
> http://code.google.com/p/davysironpythoneditor/
> _______________________________________________
> Users mailing list
> [email protected] <mailto:[email protected]>
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>  
>
>     _______________________________________________
>     Users mailing list
>     [email protected] <mailto:[email protected]>
>     http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
> ----------------------------------------------------------------------
> --
>
> _______________________________________________
> Users mailing list
> [email protected]
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to