[IronPython] lambda form

Travis Watkins alleykat at gmail.com
Sat May 7 16:33:55 CEST 2005


On 5/7/05, PhiHo Hoang <phiho.hoang at rogers.com> wrote:
> Greetings,
> 
>     Does IronPython support lambda form ?
> 
>     Is this make_inc correct ?
> 
>     Thanks,
> 
>     PhiHo
> 
> >>> def make_inc(n):
> ...     return lambda x : x + n
> ...
> >>> f = make_inc(100)
> >>> f(1)
> IronPython.Objects.PythonNameError: name 'n' is not defined
>    at IronPython.Objects.Frame.GetGlobal(String name)
>    at input_98.lamda$0$f10(Object x)
>    at IronPython.Objects.Function1.Call(Object arg0)
>    at IronPython.Objects.Ops.Call(Object func, Object arg0)
>    at input_100.Run(Frame frame)
>    at IronPython.Hosting.PythonEngine.DoOneInteractive(Frame topFrame)
>    at IronPython.Hosting.PythonEngine.RunInteractive()
> >>>
> _______________________________________________
> users-ironpython.com mailing list
> users-ironpython.com at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> 

That works on CPython so I'd say it's a bug.

-- 
Travis Watkins
http://www.realistanew.com



More information about the Ironpython-users mailing list