caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Retyping module to a new signature
@ 2006-06-28 10:49 Piotr Wieczorek
  2006-06-28 15:45 ` [Caml-list] " Jean-Marie Gaillourdet
  0 siblings, 1 reply; 4+ messages in thread
From: Piotr Wieczorek @ 2006-06-28 10:49 UTC (permalink / raw)
  To: caml-list

Hi!
I'm trying for quite a time, to make patch to Ocaml compiler which makes possible taking a bytecompiled module and producing identical module but conforming to a new signature.
I've used some code from bytepackager to calculate coercion and copy bytecode from original module to target one.
It works ok. But if order of functions in target signature is different then in source signature, calling a function may cause not running right one, but another.
Can you tell me what may I be doing wrong, or wether what i'm trying to accomplish is possible.

Greetings,
Piotr Wieczorek

------------------------------------------------------------------------
CIEPŁE KRAJE - CIEPŁE MORZA. Szukasz atrakcyjnego wypoczynku w przystępnej cenie, zapoznaj się z naszą ofertą.
ZAPRASZAMY

www.skarpatravel.pl


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

* Re: [Caml-list] Retyping module to a new signature
  2006-06-28 10:49 Retyping module to a new signature Piotr Wieczorek
@ 2006-06-28 15:45 ` Jean-Marie Gaillourdet
  2006-06-29  9:19   ` Piotr Wieczorek
  0 siblings, 1 reply; 4+ messages in thread
From: Jean-Marie Gaillourdet @ 2006-06-28 15:45 UTC (permalink / raw)
  To: Piotr Wieczorek; +Cc: caml-list

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

On 28.06.2006, at 12:49, Piotr Wieczorek wrote:

> Hi!
> I'm trying for quite a time, to make patch to Ocaml compiler which  
> makes possible taking a bytecompiled module and producing identical  
> module but conforming to a new signature.
> I've used some code from bytepackager to calculate coercion and  
> copy bytecode from original module to target one.
> It works ok. But if order of functions in target signature is  
> different then in source signature, calling a function may cause  
> not running right one, but another.
> Can you tell me what may I be doing wrong, or wether what i'm  
> trying to accomplish is possible.
>

Why do you try do that in the first place? Let us assume you have a  
module Foo which is stored in byte code file foo.cmo, which was  
compiled frome the file foo.ml
- -- foo.ml --
let foo x y= x + y

let bar x = x
- ------------

If you want to constraint Foo to a module Bar which includes only the  
first function you could use the following source:
- -- bar.mli ----
val foo : int -> int -> int
- ---------------
- -- bar.ml -----
include Foo
- ---------------

I compiled everything with:

$ ocamlc foo.ml
$ ocamlc bar.mli
$ ocamlc foo.cmo  bar.ml

The first step is in your step eventually not necessary, because you  
wanted to start with a binary module.
Hope this helps.

Best regards,
   Jean-Marie

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFEoqQJNIUNP/I5YOgRAg5EAJ9TEP3e+8MlNxqx1jhBV3uAicjuHQCglSLw
JBc3ol9wBQ0ivgcrlbw3K0I=
=wQlS
-----END PGP SIGNATURE-----


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

* Re: [Caml-list] Retyping module to a new signature
  2006-06-28 15:45 ` [Caml-list] " Jean-Marie Gaillourdet
@ 2006-06-29  9:19   ` Piotr Wieczorek
  2006-06-29  9:20     ` Jean-Marie Gaillourdet
  0 siblings, 1 reply; 4+ messages in thread
From: Piotr Wieczorek @ 2006-06-29  9:19 UTC (permalink / raw)
  To: Jean-Marie Gaillourdet; +Cc: caml-list

> Hi,
>
> On 28.06.2006, at 12:49, Piotr Wieczorek wrote:
>
>> Hi!
>> I'm trying for quite a time, to make patch to Ocaml compiler which  makes 
>> possible taking a bytecompiled module and producing identical  module but 
>> conforming to a new signature.
>> I've used some code from bytepackager to calculate coercion and  copy 
>> bytecode from original module to target one.
>> It works ok. But if order of functions in target signature is  different 
>> then in source signature, calling a function may cause  not running right 
>> one, but another.
>> Can you tell me what may I be doing wrong, or wether what i'm  trying to 
>> accomplish is possible.
>>
>
> Why do you try do that in the first place? Let us assume you have a 
> module Foo which is stored in byte code file foo.cmo, which was  compiled 
> frome the file foo.ml
> - -- foo.ml --
> let foo x y= x + y
>
> let bar x = x
> - ------------
>
> If you want to constraint Foo to a module Bar which includes only the 
> first function you could use the following source:
> - -- bar.mli ----
> val foo : int -> int -> int
> - ---------------
> - -- bar.ml -----
> include Foo
> - ---------------
>
> I compiled everything with:
>
> $ ocamlc foo.ml
> $ ocamlc bar.mli
> $ ocamlc foo.cmo  bar.ml
>
> The first step is in your step eventually not necessary, because you 
> wanted to start with a binary module.
> Hope this helps.
>
> Best regards,
>   Jean-Marie

Well, imagine following situation I got program as bunch of bytecompiled 
modules. Some of them are third-party libraries. Thereis new version of 
library released with compatible but not necessary identical signatures.
I want now to have module with identical name as source module but 
consistent with new signature.
Using Your method, I think, I cannot use the name name of new module as of 
the source module.

Piotr Wieczorek


------------------------------------------------------------------------
CIEP?E KRAJE - CIEP?E MORZA. Szukasz atrakcyjnego wypoczynku w przyst?pnej cenie, zapoznaj si? z nasz? ofert?.
ZAPRASZAMY

www.skarpatravel.pl


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

* Re: [Caml-list] Retyping module to a new signature
  2006-06-29  9:19   ` Piotr Wieczorek
@ 2006-06-29  9:20     ` Jean-Marie Gaillourdet
  0 siblings, 0 replies; 4+ messages in thread
From: Jean-Marie Gaillourdet @ 2006-06-29  9:20 UTC (permalink / raw)
  To: Piotr Wieczorek; +Cc: caml-list

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

On 29.06.2006, at 11:19, Piotr Wieczorek wrote:
> Well, imagine following situation I got program as bunch of  
> bytecompiled modules. Some of them are third-party libraries.  
> Thereis new version of library released with compatible but not  
> necessary identical signatures.
> I want now to have module with identical name as source module but  
> consistent with new signature.
> Using Your method, I think, I cannot use the name name of new  
> module as of the source module.

It might be easier to rename the bytecompiled modules and combine it  
with my method. Just my 0,02€.

Regards,
   Jean-Marie


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFEo5tfNIUNP/I5YOgRAvqiAJ9Q/zYMIOra6VeMAU80DQGYox4KVQCgg/qs
XjPahe+Un/tYuH8aIMFGlHI=
=mjyC
-----END PGP SIGNATURE-----


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

end of thread, other threads:[~2006-06-29  9:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-28 10:49 Retyping module to a new signature Piotr Wieczorek
2006-06-28 15:45 ` [Caml-list] " Jean-Marie Gaillourdet
2006-06-29  9:19   ` Piotr Wieczorek
2006-06-29  9:20     ` Jean-Marie Gaillourdet

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).