English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Snd question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-08-16 (16:37)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Snd question
On Tuesday 16 August 2005 14:17, skaller wrote:
> 	match e with (h,t,...) ->

My understanding is that the types of those expressions cannot expressed in 
the OCaml type system. So that would require quite a fundamental change.

> because a tuple of all the same type is an array,
> but as yet I haven't found a way to make ... work in
> pattern matches.

My only ellipses-related gripe is that ML patterns are designed to be linear 
but it would be nice if they could perform all linear pattern matches. 
Currently, you cannot match [|1; ...|] in OCaml.

I believe the less-elegant solution "a when Array.length a > 1 && a.(0) = 1" 
will incur a significant performance penalty when used in the middle of a 
large set of unguarded patterns.

> It would actually be nice to have more general support
> for polyadic tuple management: for example thinking about
> obtaining a slice of a tuple, or concatenating two tuples,
> suggests that just getting the n'th component is special case.

From my limited experience of SML, it is more of a pain than a benefit.

Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists