Re: Subsequence references or substrings in OCaml

From: Michael Hicks (
Date: Mon Dec 21 1998 - 16:49:16 MET

Message-Id: <l03010d04b2a41ba6f85b@[]>
In-Reply-To: <>
Date: Mon, 21 Dec 1998 10:49:16 -0500
To: Brian Rogoff <>,
From: Michael Hicks <>
Subject: Re: Subsequence references or substrings in OCaml

At 11:27 AM -0800 12/18/98, Brian Rogoff wrote:
>Its simple enough to implement subsequence references as a user defined
>type in OCaml, as I've done, but I am curious about whether anyone else
>who has used similar libraries would find a built-in substring or
>subsequence ref library useful.

We've done this in our active network implementation to efficiently
implement packet switching. The idea is that when the packet comes in, it
has an Ethernet header that is stripped off before the packet is processed
by the next level in the protocol stack. After doing this, it may turn out
that the packet should be forwarded, in which case a new Ethernet header
needs to be prepended to the currently headerless packet. By using the
substring abstraction, we are able to the prepend efficiently because the
space of the old header may be overwritten. The alternative would have us
allocate a new buffer with the correct header and then copy the old payload
into it. Using substrings is more efficient: there is no wasted copying of
data; this is a time-savings in itself, but it also reduces the frequency
of GC.


Michael Hicks
Ph.D. candidate, the University of Pennsylvania
"I'm looking over
 A three-leaf clover,
 That I overlooked be-three ..." -- Bugs Bunny

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