Hi Lyle, I don't know about the problems on the Mac, but the exception on calling RemoteProc.getPID is expected behavior. This is what happens:
When the functor is remotely applied, - OS.getPID is called on the remote site to initialize "Pid". No problem here. - GetPID is defined, but not called. It is exported as a normal function value. When calling RemoteProc.getPID, the function value is copied and the system tries to execute the function on the caller site. (Functions are stateless entities, and "Their distributed semantics is very efficient: they are * copied* across the net in a single message.", http://www.mozart-oz.org/documentation/dstutorial/node2.html#stateless.entities). Because the function uses the "sited module" OS, it will throw an exception when executed locally. (Functions that only use unsited entities would not cause such problems.) On older Mozart versions the solution would be to wrap the function in a "stationary object" or to write a server (using a stream and a port) and distribute the port. In Mozart 1.4.0 there is a simpler solution: just annotate the function as "stationary". It will then be executed on the remote site: functor RemoteProc import OS DP %% additional import export Pid GetPID define fun {GetPID} {OS.getPID} end {DP.annotate GetPID stationary} %% added this line Pid={OS.getPID} end RP1={New Remote.manager init} RS1={RP1 apply(RemoteProc $)} {Browse myPID({OS.getPID})} {Browse otherPID({RS1.getPID})} {Browse otherPID(RS1.pid)} The semantics of distributed programs in Oz can be surprising at first, especially since distribution is so transparent. In my experience it is often useful to stick to a relatively conservative client-server pattern (which is very easy to implement in Oz). Cheers, Wolfgang On Fri, Mar 11, 2011 at 7:44 AM, Lyle Kopnicky <[email protected]> wrote: > Hi folks, > I'm studying the Remote module and am getting some unexpected errors. I've > produced this tiny example to illustrate: > functor RemoteProc > import > OS > export > Pid > GetPID > define > fun {GetPID} > {OS.getPID} > end > Pid={OS.getPID} > end > RP1={New Remote.manager init} > RS1={RP1 apply(RemoteProc $)} > {Browse myPID({OS.getPID})} > %{Browse otherPID({RS1.getPID})} > {Browse otherPID(RS1.pid)} > This works, showing my PID followed by the remote process PID. But if I > uncomment the second-to-last line, it fails: > %********************** error in application ******************** > %** > %** Application of non-procedure and non-object > %** > %** In statement: {<Resource> _<optimized>} > %** > %** Call Stack: > %** procedure 'GetPID' in file > "c:/Users/Lyle/devel/oz/ch11/remote_func_test.oz", line 29, column 3, PC = > 45748908 > %**-------------------------------------------------------------- > Maybe I'm not understanding something about 'export', but I thought I should > be able to call this function from the remote functor. Can only values be > exported? > Thanks, > Lyle > _________________________________________________________________________________ > 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
