Just FYI - I added a way to access sites which are local to the functions 
caller this morning.  There's a new type SiteLocalStorage<T> which you can 
declare as a parameter on any built-in function. Then when calling it you get 
an instance of this class which is allocated from the calling dynamic site.

Therefore if you have different callers passing different types you'll get 
different instances of the storage.  That will enable functions like map to be 
implemented as:

          public static List map(CodeContext/*!*/ context, 
SiteLocalStorage<DynamicSite<object, object, object>>/*!*/ storage, object 
func, IEnumerable enumerator) {
            if (enumerator == null) {
                throw PythonOps.TypeError("NoneType is not iterable");
            }

            if (func != null && !storage.Data.IsInitialized) {
                  storage.Data.EnsureInitialized(...);
            }

            List ret = new List();
            foreach (object o in enumerator) {
                if (func == null) {
                    ret.AddNoLock(o);
                } else {
                    ret.AddNoLock(storage.Data.Invoke(context, func, o));
                }
            }
            return ret;
        }

And therefore we won't have to create a new dynamic site and figure out what to 
do each time through map - while at the same time usually having a monomorphic 
call site.  If you need more than one site you can declare 
SiteLocalStorage<object[]> or SLS<Tuple<...>>.  That should work w/ any DLR 
language which uses the default method binder.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Douglas S. Blank
Sent: Tuesday, May 27, 2008 1:52 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Hosting IP2 Beta2 in Mono?

Sanghyeon Seo wrote:
> 2008/5/20 Douglas S. Blank <[EMAIL PROTECTED]>:
>> Seo at al.,
>>
>> If you want to grab the patches for an IPCEr8 which will build and run IP2B2:
>>
>> svn export
>> http://svn.cs.brynmawr.edu/Myro/trunk/fepy/IPCE/fepy/patches/2.0b2/
>
> Sorry for a long delay. This is a great work! Thank you. These changes
> are now incorporated in FePy SVN:
> http://fepy.svn.sourceforge.net/viewvc/fepy?view=rev&revision=588
>
> However, your patch-builtin-mapsite is incorrect. A function to map
> can be null (Python None) in valid Python code. Try "map(None, [])"
> for an example.
>
> My workaround involves moving local DynamicSite varaibles to static
> and using EnsureInitialized to initialize them. See:
> http://fepy.svn.sourceforge.net/svnroot/fepy/trunk/patches/latest/patch-builtin-mapsite
>

Excellent; thanks a bunch!

I didn't know that you could map None... interesting. That explains that
code.

-Doug
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to