Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
toplevel with pre-installed printers
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] toplevel with pre-installed printers
On Thu, 2006-01-19 at 20:18 +0000, Richard Jones wrote:
> On Thu, Jan 19, 2006 at 02:12:59PM -0500, Eric Cooper wrote:
> > In a single "master" .ocamlinit, you could dispatch on
> > Sys.executable_name, and perhaps Sys.getcwd.  Still a hack, but it
> > might avoid (non-OCaml) wrapper scripts.
> This is a clever idea. 

It's an old one too. gcc does it. The problem is portability.

You simply look at argv[0] which on some Unix systems
is the full path name of the invoked executable.

In particular, its the path name of the symlink to the
executable, not the binary. Thus, you can find the
directory containing the symlink, and thus the resources
associated with that particular symlink.

All you need is a unique symlink for every context,
and a fixed way of finding files relative to the
location of the symlink.

The problem is that there is no guarantee argv[0] is
in fact the full pathname of the symlink on all Unix
systems .. it works on Linux though.

The two other techniques commonly used to solve this problem are

(a) a wrapper script passing a command line argument
(b) an environment variable

./ocamlinit script can certainly read an environment variable.
It can also read the command line arguments .. so all you
really need is to ask for a patch to the toplevel which
allows you to pass it an argument it totally ignores!

John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: