Dear Mark,

On Tue, Jun 23, 2009 at 3:03 PM, mark richardson <[email protected]>wrote:

> 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?


What you ask for is to access a variable outside of lexical scope.  You want
to access some kind of "global variable".

I see two simple ways to resolve your problem without global variables:
 - create the cell is a module shared by both functors;
 - "initialize" the procedure dynamically in the second functor.

The latter solution consists in making the second functor export the
procedure as an unbound variable that is determined by explicit
initialization.

functor
export
   MyFuncProc
   Init
define
   proc {Init SomeCell}
      %% determine MyFuncProc here
      proc {MyFuncProc X}
         {Browse @MyCell#X}
      end
   end
end

Cheers,
raph
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to