Raph,

 

Thanks so much again. Actually, the following one I did kind of realize
that I am reassigning the logic variable and hence not working. But how
can I make that variable dynamic so that takes the name of the Functor
file? However, I can live with that and not have the line that I
highlight in italics. 

 

{ForAll Mods

    proc{$ File} 

        ConstraintFileName = {FirstN {LastRemain File DirName} 4}

       {Browse 'do nothing'#{String.toAtom ConstraintFileName}}

       [ConstraintFileName] = {Module.link [File]}  

 

 

But how can I call a function from that module where the function name
came from Pdc below (second part of my question)?

 

{ForAll ProblemDescription.problemDomainConstraints

                 proc{$ Pdc} Constr SpecificConstraints in

                        if{HasFeature Pdc name} then

                           %Constr = {Append "ConstraintFileName."
Pdc.name}

                           Constr = {VirtualString.toString
"ConstraintFileName."#Pdc.name} 

                           {Browse  Constr}    <--- I build the Constr
okay

                           SpecificConstraints = {Constr
ProblemDescription}  

 

hangs at the last line  though works when I hard-code the Module and
function name e.g, {ConstraintFileName.testFunc ProblemDescription}

 

Ashis

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Raphael Collet
Sent: Tuesday, October 21, 2008 1:25 PM
To: Mozart users
Subject: Re: "import" ing ozf dynamically

 

Dear Ashis,

About Module.load: you're right, I made a mistake, it's Module.link that
you should use.  Read carefully its documentation, you will understand
why nothing happens when you call that function: it loads modules *on
demand*.  So

Mods = {Module.link {ImportFiles DirName}}

binds Mods to a list of variables, but does not load modules yet.  You
can check that by running {Browse Mods}.  The variables in Mods will be
determined (and the corresponding modules loaded) once the program will
need their value.  A simple way to force the loading is to Wait on all
variables:

{ForAll Mods Wait}

Now, there are several mistakes in your code...

        local Mods  in

           Mods = {ImportFiles DirName}

           {ForAll Mods

            proc{$ File} 

                ConstraintFileName = {FirstN {LastRemain File DirName}
4}

               {Browse 'do nothing'#{String.toAtom ConstraintFileName}}

               [ConstraintFileName] = {Module.link [File]}
<-------------- Program appears to hang here / however works okay if I
remove the line above Browse

            end    

           }

        End

The program must fail after browsing the first filename.
ConstraintFileName is declared as a *global* variable, and you bind it
twice in the loop!  You cannot reassign logic variables; here you are
trying to assign it 2N values, where N is the number of files you load.
The first assignment (the result of FirstN) succeeds, but the second one
(the result of Module.link) fails, because it loads the module, and
tries to assign it to ConstraintFileName.  At that point, the program
should stop.


Cheers,
raph

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

Reply via email to