caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Announcement: automatically resizing arrays
@ 1999-10-14  0:58 Markus Mottl
  1999-11-11 11:39 ` Undefined labels skaller
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Mottl @ 1999-10-14  0:58 UTC (permalink / raw)
  To: OCAML; +Cc: skaller

Hello,

as promised last week, I have just released my implementation of
automatically resizing contiguous memory (= arrays, strings, etc...).

Here a part of the README explaining the advantages of using it:

  * Fast constant-time access to indexed elements (e.g. in arrays and
    strings) is often a prerequisite for short execution times of
    programs.

    Still, operations like adding and/or removing elements to/from the
    end of such datastructures are often needed.  Unfortunately, having
    both properties at the same time sometimes requires reallocating
    this contiguous part of memory.

    This module does not eliminate this problem, but hides the process
    of reallocation from the user, i.e. it happens automatically.

    Thus, the user is liberated from this bug-attracting (e.g. index
    errors) task.

  * This library allows the user to parameterize allocation strategies at
    runtime. This is a very important feature, because it is impossible
    for any allocation algorithm to perform optimally without having
    knowledge about the user program.

    For example, the programmer might know that a consecutive series
    of operations will alternately add and remove large amounts of
    elements. In such a case it would be wise to keep a high reserve
    of available slots in the datastructure, because otherwise it will
    resize very often during this procedure which requires a significant
    amount of time.

    By raising a corresponding threshold in appropriate places at runtime,
    the programmer can fine-tune the behaviour of e.g. his buffers for
    optimal performance and set this parameter back later to save memory.

  * Because reallocation strategies themselves may be quite complicated,
    it was also a design goal to have the user supply his own ones
    (if required).

    By using functors the user can parameterize these datastructures
    with his own reallocation strategies, giving him even more control
    over how and when reallocations are triggered.

  * It is possible that the user wants to add support for additional
    low-level implementations that require reallocations (e.g. bit-strings
    have not yet been added to this distribution). Even in this case it
    is fairly easy to create new modules by using functors.

  * The library implements a large interface of functions, all of which
    are completely independent of the reallocation strategy and the
    low-level implementation.

    All the interfaces of the corresponding low-level implementations
    of datastructures (e.g. array, string) are fully supported and have
    been extended with further functionality. There is even a new buffer
    module which can be used in every context of the standard one.

  * OCaml makes a distinction between unboxed and boxed arrays. If
    the type of an array is "int" or "float", the representation will
    be unboxed in most cases.

    To benefit from these much faster representations there are
    specialized versions of automatically resizing arrays in the
    distribution.

The examples in the distribution are fairly short - the documentation
could surely be better (is there something like a perfect
documentation??). If you have questions, comments, etc., feel free to
contact me...

Best regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl




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

* Undefined labels
  1999-10-14  0:58 Announcement: automatically resizing arrays Markus Mottl
@ 1999-11-11 11:39 ` skaller
  1999-11-12  9:28   ` Jean-Christophe Filliatre
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: skaller @ 1999-11-11 11:39 UTC (permalink / raw)
  To: caml-list

I am getting an undefined label error. 
I know why. I do not know how to fix the problem:

	(Unix.fstat argument).st_kind

Here, the function returns a structure, st_kind
is a label of that structure, but it is not known
in the calling module. Is there a syntax for this?
Using 'open Unix' is unacceptable.

-- 
John Skaller, mailto:skaller@maxtal.com.au
1/10 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
downloads: http://www.triode.net.au/~skaller



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

* Re: Undefined labels
  1999-11-11 11:39 ` Undefined labels skaller
@ 1999-11-12  9:28   ` Jean-Christophe Filliatre
  1999-11-12 23:01     ` skaller
  1999-11-12  9:54   ` William Chesters
  1999-11-12 12:47   ` Christian RINDERKNECHT
  2 siblings, 1 reply; 7+ messages in thread
From: Jean-Christophe Filliatre @ 1999-11-12  9:28 UTC (permalink / raw)
  To: skaller; +Cc: caml-list


> I am getting an undefined label error. 
> I know why. I do not know how to fix the problem:
> 
> 	(Unix.fstat argument).st_kind
> 
> Here, the function returns a structure, st_kind
> is a label of that structure, but it is not known
> in the calling module. Is there a syntax for this?
> Using 'open Unix' is unacceptable.

	(Unix.fstat argument).Unix.st_kind

Best regards,
-- 
Jean-Christophe FILLIATRE
  mailto:Jean-Christophe.Filliatre@lri.fr
  http://www.lri.fr/~filliatr



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

* Undefined labels
  1999-11-11 11:39 ` Undefined labels skaller
  1999-11-12  9:28   ` Jean-Christophe Filliatre
@ 1999-11-12  9:54   ` William Chesters
  1999-11-12 12:47   ` Christian RINDERKNECHT
  2 siblings, 0 replies; 7+ messages in thread
From: William Chesters @ 1999-11-12  9:54 UTC (permalink / raw)
  To: caml-list

skaller writes:
 > I am getting an undefined label error. 
 > I know why. I do not know how to fix the problem:
 > 
 > 	(Unix.fstat argument).st_kind

You want (Unix.fstat argument).Unix.st_kind

(Is this in the docs?  I found it once when looking at the camlp4 parser.)

This is definitely one of those cases where type inference doesn't
seem such a good idea ... it feels so like K&R C, sometimes having to
fall back on giving labels little prefixes ... I wonder if some kind
of inference would be possible, not going the whole way to the
tag-based system used for classes, but at least something that
maintains a set of hypotheses consistent with the labels used in
connection with a value, which could then be narrowed down
contextually.



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

* Re: Undefined labels
  1999-11-11 11:39 ` Undefined labels skaller
  1999-11-12  9:28   ` Jean-Christophe Filliatre
  1999-11-12  9:54   ` William Chesters
@ 1999-11-12 12:47   ` Christian RINDERKNECHT
  1999-11-12 17:11     ` Jean-Francois Monin
  2 siblings, 1 reply; 7+ messages in thread
From: Christian RINDERKNECHT @ 1999-11-12 12:47 UTC (permalink / raw)
  To: skaller; +Cc: caml-list

Hello,

> 	(Unix.fstat argument).st_kind
> 
> Here, the function returns a structure, st_kind
> is a label of that structure, but it is not known
> in the calling module. Is there a syntax for this?

Yes:

        (Unix.fstat argument).Unix.st_kind
                              ^^^^
because the compiler doesn't know in what module to look-up for label
[st_kind]. 


> Using 'open Unix' is unacceptable.

I also never use the "open" feature, but the consequence is, when using
nested records, I must qualify all the labels (as in your example),
and the code becomes unreadable.

I recently started using classes in order to avoid this practical
problem, since methods are in the scope of their object, not of the
module embedding their class.

But this doesn't work if the library you are using is not
object-oriented, of course:)

Best regards,

-- 

Christian

-----------------------------------------------------------------------
Christian Rinderknecht                     Phone +33 (0)1 60 76 44 43
Institut National des Télécommunications   Fax   +33 (0)1 60 76 47 11
Département Logiciels Réseaux (LOR)        WWW
9, Rue Charles Fourier, F-91011 Évry Cedex



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

* Re: Undefined labels
  1999-11-12 12:47   ` Christian RINDERKNECHT
@ 1999-11-12 17:11     ` Jean-Francois Monin
  0 siblings, 0 replies; 7+ messages in thread
From: Jean-Francois Monin @ 1999-11-12 17:11 UTC (permalink / raw)
  To: Christian RINDERKNECHT; +Cc: skaller, caml-list

>         (Unix.fstat argument).Unix.st_kind
>                               ^^^^
> > Using 'open Unix' is unacceptable.
> 
> I also never use the "open" feature, but the consequence is, when using
> nested records, I must qualify all the labels (as in your example),
> and the code becomes unreadable.

Not so unreadable if you declare

module U=Unix

This can be local to a (group of) function(s), e.g.

let f,g =
   let module U = Unix in
   let f argument = (U.fstat argument).U.st_kind in
   let g = 5
   in f,g;;

  Jean-Francois



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

* Re: Undefined labels
  1999-11-12  9:28   ` Jean-Christophe Filliatre
@ 1999-11-12 23:01     ` skaller
  0 siblings, 0 replies; 7+ messages in thread
From: skaller @ 1999-11-12 23:01 UTC (permalink / raw)
  Cc: caml-list

Thanks to everyone who answered this question for me.
[Quite a lot of replies!]

-- 
John Skaller, mailto:skaller@maxtal.com.au
1/10 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
downloads: http://www.triode.net.au/~skaller



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

end of thread, other threads:[~1999-11-15  7:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-14  0:58 Announcement: automatically resizing arrays Markus Mottl
1999-11-11 11:39 ` Undefined labels skaller
1999-11-12  9:28   ` Jean-Christophe Filliatre
1999-11-12 23:01     ` skaller
1999-11-12  9:54   ` William Chesters
1999-11-12 12:47   ` Christian RINDERKNECHT
1999-11-12 17:11     ` Jean-Francois Monin

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