Hello,
I tried both methods and they worked but I just wanted to know if the values
generated by OS.rand are always the same or is there something I'm missing.
OS.rand is supposed to generate random numbers each time but no matter how
many times I run "main" I always get the same values. I tried recompiling
and ran "main" again but I got the same values. Is this normal?

Thanks

2010/9/7 Wolfgang Meyer <[email protected]>

> Hi,
> do you want the OS function to be executed on the site where MyClass
> is running or locally on the original site?
> For OS.rand this does not really matter so much, but if you execute,
> for example, OS.unlink, then it is very important.
>
> If you want to execute the code locally on the original site, you
> could create a kind of "stationary procedure" for OS.rand. There is
> actually a (undocumented?) system module "Service" for  this. Your
> GrandParent class would look this:
>
> functor
> import
>   OS
>   Service
> export
>   grandParent:GrandParent
> define
>   RandService = {Service.synchronous.newFun OS.rand}
>
>   class GrandParent
>   feat
>      a
>      b
>      c
>      d
>
>      meth init(A)
>         self.a=A
>         self.b=78
>         self.d={RandService}
>      end
>      %...
>   end
> end
>
>
> If, on the other hand, the OS function should be executed on the
> remote site, where the object is living, then you need to link the
> functor with the class definition on the remote site such that the
> remote version of OS is used.You  can do this with a modified version
> of CreateRemoteStationaryObject:
> ------
> ...
> fun {CreateRemoteStationaryObject ModuleURL Feat Init RM}
>   ClassModule = {RM link(url:ModuleURL $)}
>   functor RemoteCode
>      export result:Result
>      define
>        Result = try {NewStat ClassModule.Feat Init}
>                 catch E then
>                    {Value.failed E}
>                 end
>      end
>     AppliedFunctor = {RM apply(RemoteCode $)}
>   in
>   AppliedFunctor.result
> end
>
> RM = {New Remote.manager init(host:localhost)}
>
> RemoteObject = {CreateRemoteStationaryObject 'MyClasses.ozf' parent init(7)
> RM}
> RemoteObject1 = {CreateRemoteStationaryObject 'MyClasses.ozf' child init(9)
> RM}
>
> --------
> Instead of a class, the function now takes the URL of a functor
> ('MyClasses.ozf') and the feature of the functor where the class is
> defined (parent or child).
> I have also moved the creation of the Remote.manager out of the
> function because otherwise a new Oz process is created for every
> object.
> To make this version of CreateRemoteStationaryObject work in a real
> distributed application, you have to copy the compiled modules (*.ozf
> files) to the remote site. As long as you only use localhost, that is
> not necessary.
>
> Hope this helps,
>  Wolfgang
>
>
>
> On Mon, Sep 6, 2010 at 10:25 AM, Khadija EL MAHRSI
> <[email protected]> wrote:
> > Hello,
> > using this information I wanted to do the following:
> > Create a stationary instance of a class (let's call it MyClass) on a
> remote
> > site (thanks to the code you've given me earlier in another topic:
> "Sending
> > classes to a remote site"). This is the instance creation code line:
> > T={CreateRemoteStationaryObject MyClass init()}
> > This class' init method uses an init method from another class
> (MySupClass)
> > from which it also inherits its features (class MyClass from MySupClass).
> > In this class' init method (MySupClass) I want to use OS.something
> (OS.rand
> > for example) to fill this class' features. Can I do this?
> >
> > Thanks, I really appreciate the help you're always willing to offer.
> >
> > 2010/9/5 Wolfgang Meyer <[email protected]>
> >>
> >> Hi,
> >>
> >> to use a sited module, you have to make sure that you use a local
> >> module instance, i.e. a version of OS that has been linked on the
> >> running site.
> >> To achieve this, code is packaged in a functor with its dependencies.
> >> An example:
> >> This code won't work because it uses a remote "OS":
> >>
> >> declare
> >> functor RemoteCode
> >> export R
> >> define
> >>   R = {OS.rand}
> >> end
> >>
> >> RM = {New Remote.manager init}
> >> AF = {RM apply(RemoteCode $)}
> >> {RM close}
> >> {Show AF.r}
> >>
> >>
> >> But this code will work, because it uses a locally imported "OS":
> >>
> >> declare
> >> functor RemoteCode
> >> import OS          %% This line is the only difference
> >> export R
> >> define
> >>   R = {OS.rand}
> >> end
> >>
> >> RM = {New Remote.manager init}
> >> AF = {RM apply(RemoteCode $)}
> >> {RM close}
> >> {Show AF.r}
> >>
> >> So you have to package the class in a functor and make sure that this
> >> functor is applied or linked on the remote site where the class
> >> instance is running.
> >>
> >> Hope this helps,
> >>  Wolfgang
> >>
> >>
> >> On Sun, Sep 5, 2010 at 12:58 PM, Khadija EL MAHRSI
> >> <[email protected]> wrote:
> >> > Hello,
> >> > Correct me if I'm wrong, after some research I came to the conclusion
> >> > that
> >> > since OS is sited it is not possible to achieve the idea I had so
> >> > instead I
> >> > will have the result of OS.something passed to this class as parameter
> >> > through a method.
> >> > Thanks.
> >> >
> >> > 2010/9/4 Khadija EL MAHRSI <[email protected]>
> >> >>
> >> >> Hello,
> >> >> I was wondering if it is possible to have a class running on a remote
> >> >> site
> >> >> execute OS.(something) and put the result in a feature of this class
> >> >> (like
> >> >> self.x=OS.rand for example).
> >> >> Thanks
> >> >
> >> >
> >> >
> >> >
> _________________________________________________________________________________
> >> > mozart-users mailing list
> >> > [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
> >
> >
> >
> _________________________________________________________________________________
> > mozart-users mailing list
> > [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
>
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to