Re: Map is not tail recursive

From: David McClain (dmcclain@azstarnet.com)
Date: Thu Jan 14 1999 - 04:49:00 MET


From: "David McClain" <dmcclain@azstarnet.com>
To: <caml-list@pauillac.inria.fr>,
Subject: Re: Map is not tail recursive
Date: Wed, 13 Jan 1999 20:49:00 -0700

>(particularly if you inline it).

Is there a way to explicitly inline functions, other than cut and paste?

- DM

-----Original Message-----
From: Jacques GARRIGUE <garrigue@kurims.kyoto-u.ac.jp>
To: caml-list@pauillac.inria.fr <caml-list@pauillac.inria.fr>
Date: Wednesday, January 13, 1999 04:27
Subject: Re: Map is not tail recursive

>From: "David McClain" <dmcclain@azstarnet.com>
>
>> Juan got me thinking about this problem... So here is a solution:
>>
>> external rplacd : 'a list -> 'a list -> unit = "rplacd"
>>
>> -- and the external C code is
>>
>> value rplacd(value cell, value item)
>> {
>> Store_field(cell,1,item);
>> return Val_unit;
>> }
>
>While this is undocumented, there is a slightly simpler way to define
>rplacd, wihout using C. This should be faster in most cases
>(particularly if you inline it).
>
>let rplacd (cell : 'a list) (item : 'a) =
> Obj.set_field (Obj.repr cell) 1 (Obj.repr item)
>
>As for using the null pointer to have more efficient representations
>in data-structures, this is theoretically possible (and I believe that
>Xavier Leroy had an implementation with it), but this is not in the
>current version of ocaml.
>
> Jacques
>
>---------------------------------------------------------------------------
>Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp
> <A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A>
>



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:17 MET