caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Changing implementations of standard libraries...
@ 2005-10-29  3:47 Jonathan Roewen
  2005-10-29 11:36 ` Gerd Stolpmann
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Roewen @ 2005-10-29  3:47 UTC (permalink / raw)
  To: caml-list

Hi,

What changes does -vmthread make to the compiler when generating code?
I see vmthreads provides it's own version of pervasives for starters.

Also, as long as the .cmi files don't change, one would be free to
replace the implementation with any thing they see fit, correct?

For example, for my OS project, I would probably want to change the
implementation for the stdlib such that in_channel & out_channel would
be implemented on top of my OCaml-based VFS layer, rather than relying
on C code. I would assume, for example, that since in_channel is
considered abstract in the .cmi file, I could change the actual
implementation of the type to a custom record type -- is that correct?

Another example would be modifying vmthreads package to work inside an
OCaml-based process. This would then extend to pervasives and
stdin/out/err, so that they work correctly (from the ocaml process
data structure's file handles, rather than some global C variables).

Apart from Unix module, which I'd like to do away with, the rest of
stdlib seems to be quite useful, just not compatible in the current
implementation for building a kernel without requiring doing lots of
stuff in C.

I'm just not sure what to do with things like select(), and whether I
could implement some sort of replacement in ocaml, but that's a
separate issue entirely.

Kindest Regards,

Jonathan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Changing implementations of standard libraries...
  2005-10-29  3:47 [Caml-list] Changing implementations of standard libraries Jonathan Roewen
@ 2005-10-29 11:36 ` Gerd Stolpmann
  2005-10-30  0:45   ` Jonathan Roewen
  0 siblings, 1 reply; 4+ messages in thread
From: Gerd Stolpmann @ 2005-10-29 11:36 UTC (permalink / raw)
  To: Jonathan Roewen; +Cc: caml-list

Am Samstag, den 29.10.2005, 16:47 +1300 schrieb Jonathan Roewen:
> Hi,
> 
> What changes does -vmthread make to the compiler when generating code?

AFAIK, the generated code is the same.

> I see vmthreads provides it's own version of pervasives for starters.

A different version of the stdlib is linked.

> Also, as long as the .cmi files don't change, one would be free to
> replace the implementation with any thing they see fit, correct?

Yes. But you cannot implement in O'Caml when the function is external
because this is part of the interface, at least if you need binary
compatibility.

> For example, for my OS project, I would probably want to change the
> implementation for the stdlib such that in_channel & out_channel would
> be implemented on top of my OCaml-based VFS layer, rather than relying
> on C code. I would assume, for example, that since in_channel is
> considered abstract in the .cmi file, I could change the actual
> implementation of the type to a custom record type -- is that correct?

Yes.

> Another example would be modifying vmthreads package to work inside an
> OCaml-based process. This would then extend to pervasives and
> stdin/out/err, so that they work correctly (from the ocaml process
> data structure's file handles, rather than some global C variables).
> 
> Apart from Unix module, which I'd like to do away with, the rest of
> stdlib seems to be quite useful, just not compatible in the current
> implementation for building a kernel without requiring doing lots of
> stuff in C.
> 
> I'm just not sure what to do with things like select(), and whether I
> could implement some sort of replacement in ocaml, but that's a
> separate issue entirely.

I suppose select is quite hard for an OS implementor.

Gerd

> 
> Kindest Regards,
> 
> Jonathan
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Telefon: 06151/153855                  Telefax: 06151/997714
------------------------------------------------------------


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Changing implementations of standard libraries...
  2005-10-29 11:36 ` Gerd Stolpmann
@ 2005-10-30  0:45   ` Jonathan Roewen
  2005-10-30  1:12     ` Jonathan Roewen
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Roewen @ 2005-10-30  0:45 UTC (permalink / raw)
  To: Gerd Stolpmann; +Cc: caml-list

> > What changes does -vmthread make to the compiler when generating code?
>
> AFAIK, the generated code is the same.

It must change -something- somewhere, else what's the point of it?

> A different version of the stdlib is linked.

Okay, I can understand that. Would the effect be the same as -nostdlib
and -nopervasives, and providing own includes & implementations?

What effect does -nopervasives have? Can I still provide my own
implementation? What's the way to go here?

> Yes. But you cannot implement in O'Caml when the function is external
> because this is part of the interface, at least if you need binary
> compatibility.

Yes, but in most cases, the external keyword can be hidden from the
.cmi, and only specified in .ml/.cmo -- I see examples of this in
OCaml standard lib, and do this myself in most cases.

Jonathan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Changing implementations of standard libraries...
  2005-10-30  0:45   ` Jonathan Roewen
@ 2005-10-30  1:12     ` Jonathan Roewen
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Roewen @ 2005-10-30  1:12 UTC (permalink / raw)
  Cc: caml-list

Include paths.

I see from the compiler sources, that when specifying -vmthreads, it
adds +vmthreads to the HEAD of the include paths.

When someone does -I on the command line, I assume these go at the
TAIL of the include paths?

And, because +vmthreads is at the head of the include path, it finds
stdlib.cma in +vmthreads directory BEFORE the standard include
directory, hence choosing the correct alternative implementation.

Is this how it works?

Sooo.... to make life simple for building apps targeting DST, I could
make a customised version of the compiler, adding say a "dst" flag
that specifies a different directory for a specialised implementation
of the standard libraries, and threads, etc?

And then, if DST ever takes off, could get integrated into the main
ocaml suite? ;D Heh heh heh....

Jonathan


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-10-30  1:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-29  3:47 [Caml-list] Changing implementations of standard libraries Jonathan Roewen
2005-10-29 11:36 ` Gerd Stolpmann
2005-10-30  0:45   ` Jonathan Roewen
2005-10-30  1:12     ` Jonathan Roewen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).