[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Help



Hi,

>	(*SERVER*)
>	let def print s = { print_string s; reply};;
>       Ns.register "Printer" print vartype;;
>
>	(*CLIENT*)
>	let printer = Ns.lookup "Printer" vartype;;
>	printer "Hello ";;
>	printer "I'm the client";;
>
>  I've tried to compile the two files (server.ml and client.ml) but the
>server compilation with jocamlc returned the following message: "Error
>while linking server.cmo: Reference to undefined global 'Join'". 

You should use the compilation command "joc" instead of "jocamlc". It
automatically includes the libraries for the Join primitives.

>The client
>compilation returned another message: "The type of this expression, string
>-> '_a, contains type variables that cannot be generalized". Have I
>forgotten anything? Is there any other special thing to do?

The problem is that you cannot lookup some value in the name server
whose type is not fully specified. Since your printer object is of the
type "string -> unit", simply replace the lookup line with:

let printer : string -> unit = Ns.lookup "Printer" vartype;;

(the problem here is that the type inference algorithm sees that you
are using printer with a string argument, but since you do nothing
with the results, it cannot infer that it is unit).

A couple other points you should not forget:
- you will need to start the name server to use it (typing "jocns" in
some shell).
- if you are using two different machines, you only need to start one
name server, and specify in a shell on the other machine where is the
name using, using the environment variable JNSNAME (name or IP address
of the machine where the name server is running), and JNSPORT (if you
started it with a different port than the default one)
- if you are using two different machines with two different
hostnames, you might have some trouble finding back the resource you
registered. This is because when registering and looking up something
in the name server, the hostname is automatically appended to the name
of the resource (in you case "Printer"). In that case, you can specify
what is appended by setting the reference string in your jocaml
program, before doing the lookup or the register:
Ns.user := "toto";;
Ns.register ...

A couple last points: there is a very beta tutorial that you might be
interested in. It is not really officially distributed yet (we do not
feel it's ready for prime time), but if it is of use to you, it is
available at
http://pauillac.inria.fr/jocaml/ftp/tutorial_very_beta.ps.gz

Also, for these kinds of question, it would be better to send them to
the user mailing list (jocaml@inria.fr) instead of this list. If you
want to register to the user mailing list, there is more info on the
jocaml homepage: http://pauillac.inria.fr/jocaml/ 

Alan Schmitt

--
The hacker: someone who figured things out and made something cool happen.