[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: classes
Hi,
I'm wondering if it is not something else in your code. For instance,
with the following simple example, everything works as expected:
machine 1:
# class t () =
method g s =
print_string s;
print_newline();
flush stdout
end ;;
class t (unit) = method g : string -> unit end
# let test = new t () ;;
val test : t = <obj>
# Ns.register "test" test vartype ;;
Warning: VARTYPE replaced by type
<g:( string -> unit) ; > metatype
Querying name server alan-schm1p:20001
- : unit = ()
machine 2:
# let test : <g:( string -> unit) ; > = Ns.lookup "test" vartype ;;
Warning: VARTYPE replaced by type
<g:( string -> unit) ; > metatype
Querying name server alan-schm1p:20001
val test : < g : string -> unit > = <obj>
# test#g "toto" ;;
- : unit = ()
and toto gets printed on machine 1.
Do you have some more code to try to identify where things go wrong ?
Alan Schmitt
>Hi,
>
>
>
>I'm currently experementing JoCaml as a target language for a compiler
>that my team is developping (it is an actor-based functional language).
>
>As I feel more at ease with programming classes and objects than
>automata, I'm designing my system with the OO features of JoCaml.
>
>But, I face a behavior which seems strange to me (or, say, unexpected).
>I've got 2 programs: a server and a client. The server is implement as
>an object, it manages the connections from clients. The client program
>is just an object too, connecting to the server. Of course, there may be
>several clients. The server registers itself to the NS (jocns):
>
>let _ =
> let jserver = new jserver () in
> Ns.register "jserver" jserver vartype;
> Join.server ()
>
>Note that the server contains a method [notify_site] that prints "***
>new container process connected" after each new client connection.
>
>
>Then, each client looks up the server, and tries to connect to it:
>
>let _ =
> let manager = Ns.lookup "jserver" (vartype : jserver metatype) in
> print_string "### connecting to the manager..."; flush stdout;
> manager#notify_site Join.here;
> print_endline "connected"; flush stdout;
> Join.server ()
>
>
>However, after running jocns and my server, here is what happens when
>I'm running a client:
>
>Querying name server shiva:20001
>### connecting to the manager...*** new container process connected
>connected
>
>As you can see, all the printings are done in the client's console,
>while I expected the server's printing to appear in its own console.
>I'm surprised because, as far as I understand, objects are in fact
>implemented as mobile instances of automatas. So they shouldn't migrate,
>unless I explicitely ask for it. The method calls should be kind of RPC.
>But here, it seems that the server migrates to the client, then does its
>job. Well, this is what I understand...
>
>Can anyone explain?
>
>Thanks,
>
>dc
>
>
>--
>David Chemouil [mailto:chemouil@enseeiht.fr] [mobile: 06 84 16 26 65]
>
>Laboratoire d'informatique et de mathématiques appliquées (IRIT-INPT)
--
The hacker: someone who figured things out and made something cool happen.
- References:
- classes
- From: David Chemouil <David.Chemouil@enseeiht.fr>