> Given the attached functions anonfcn.m and nestfcn.m, What does a
> current version of Matlab do for the following code?
> afh = anonfcn (13)
> afh ('a')
> afh ('b')
> nfh = nestfcn (42)
> nfh ('a')
> nfh ('b')
> Could someone please run this test and post the results here?
So even though anonymous functions can capture values from the
surrounding context, they are not equivalent to nested functions, which
apparently have full access to the parent workspaces even when the
variables are not explicitly referenced. I was hoping they would be
equivalent (then the internal representation could be essentially
identical; the only difference would be the syntax for parsing) but half
expecting that they would be different because anonymous functions came
well before nested functions. I believe Octave gets this behavior right
but there is room for improvement in thm implementation.