Hi,
Thanks for your reply. I should have been (much) more specific, sorry.
Take for example a main script such as: (with possible syntax errors :+) )
declare
[MyFunc]={Module.link ['/home/mark/functor.ozf']}
MyCell={NewCell nil}
MyCell:="the cell variable"
X="some other variable"
{MyFunc.myFuncProc X}
and in my functor something like:
functor
export
MyFuncProc
define
proc {MyFuncProc X}
{Browse @MyCell#X}
end
end
what I am essentially asking is -
Is there some way I can define and compile a functor which references a
cell object that is defined in the MAIN script?
Imagine that the cell variable is some master global variable that I
want available to a functor procedure without having to pass it back and
forth explicitly.
So, is there any way of advising a functor that a value will be
available once it is linked.
Regards
Mark
Torsten Anders wrote:
Dear Mark,
Obviously at the moment I'm getting the error message that my cell
variables don't exist.
Please send us a code snippet that demonstrates your problem.
s there any way to be able to compile the functor without explicitly
passing the cell variables into the procedure definition?
I don't understand -- how do you want to access a cell without
explicitly passing it? What do you mean by "cell variable", its content?
You can create cells in a functor, export them like any other data,
and also access and change their content within and outside the functor.
There is only one thing to keep in mind. If you link your functor with
this cell multiple times using Module.link then you have multiple
independent copies of your cell. Below is an alternative
definition ModuleLink which makes sure there is always only a single
"instance" of your cell (more specifically, there is only a single
module manager created). IMHO, this should be the default behaviour of
Oz and multiple module managers should be special, because multiple
module managers are more stateful / less declarative. Anyway, after
this mail you find the alternative definition.
Best
Torsten
local
ModMan = {New Module.manager init}
in
/** %% ModuleLink is like Module.link except that multiple calls of
ModuleLink share the same module manager (and don't create new
managers as Module.link does). For instance, when ModuleLink links
multiple functors which refer to a stateful datum in some functor,
then all refer to the same datum instance. By constrast, linking with
Module.link results into multiple stateful datum instances.
%% */
fun {ModuleLink UrlVs}
{Map UrlVs fun {$ Url}
{ModMan link(url:Url $)}
end}
end
/** %% ModuleApply is like Moduel.apply expect that it always uses
the same module manager (cf. ModuleLink).
%% */
fun {ModuleApply UFs}
{Map UFs fun {$ UF}
case UF of U#F then
{ModMan apply(url:U F $)}
else
{ModMan apply(UF $)}
end
end}
end
end
--
Torsten Anders
Interdisciplinary Centre for Computer Music Research
University of Plymouth
Office: +44-1752-586219
Private: +44-1752-558917
http://strasheela.sourceforge.net
http://www.torsten-anders.de
On 23 Jun 2009, at 12:18, mark richardson wrote:
What I would like to do is to have a compiled functor which contains
just one procedure which references cells defined in the 'parent'
program. Ie. they will be present when the functor is loaded.
Is there any way to be able to compile the functor without explicitly
passing the cell variables into the procedure definition?
Obviously at the moment I'm getting the error message that my cell
variables don't exist.
Regards
Mark
--
Mark Richardson
Research Assistant
University of Teesside
[email protected] <mailto:[email protected]>
[email protected] <mailto:[email protected]>
[email protected] <mailto:[email protected]>
_________________________________________________________________________________
mozart-users mailing list
[email protected] <mailto:[email protected]>
http://www.mozart-oz.org/mailman/listinfo/mozart-users
------------------------------------------------------------------------
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users
--
Mark Richardson
Research Assistant
University of Teesside
[email protected]
[email protected]
[email protected]
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users