caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christophe Raffalli <raffalli@cs.chalmers.se>
To: caml-light@pauillac.inria.fr
Cc: caml-list@pauillac.inria.fr
Subject: Suggestions
Date: Wed, 13 Sep 1995 10:15:57 +0200	[thread overview]
Message-ID: <199509130815.KAA21297@waldorf.cs.chalmers.se> (raw)
In-Reply-To: <199509120927.LAA00417@pauillac.inria.fr> (message from Xavier Leroy on Tue, 12 Sep 1995 11:27:13 +0200 (MET DST))


Hi,

After using Caml-Light (a lot), I think I have few suggestions that might be
worst a discussion:

1) find the bug in this piece of code:

  ...;
  if ... then raise Not_found
  f t;
  ...

You get it ! f t is never called !
Conclusion : there should be a warning when raise got more than one argument.

2) A "match" guard would be really useful in pattern matching: take this
exemple: 

a module with :

type A                      (* abstract type *)
and A' = B | C of A * A;;   

value read : A -> A';;

an implementation of a function f

let f x =
  match read x with 
    B -> ...code1...
  | C (x1,x2) -> 
     (match read x1 with 
       B -> ...code1...
     | C _ -> 
        (match read x2 with
          B -> ...code1...
        | C _ -> ...code2...
        )
     )
;;

code1 is there 3 times !

If we use a match guard:

let f x =
  match read x with
    C(x1,x2) where match read x1, read x2 with C _,C _ -> ...code2...
  | _ -> ...code1...
;;

This make it much simpler, and I have plenty of axemple where this would be
usefull ! Moreover, stream pattern matching can be implemented as a syntactic
suggar for the match guard (with a different semantic that the current one).

3) Order of evaluation is unspecified. I have no problem with that except that
some piece of imperative code can behave differently on different
compiler. Such code should not be allowed or at least give a warning. I
propose the following very simple extension of the type system to detect
ambiguities:

Arrows can be marker with a * 
  (this star does not need to be printed to the user) 

The |- in a typing seqent can be marker too.

Then the typing rules are

Gamma , x : A |- t : B
----------------------
  Gamma |- \x t : A -> B

Gamma , x : A |-* t : B
----------------------
  Gamma |- \x t : A ->* B

Gamma |-r t : A1 ->m1 ... -> An ->mn B    Gamma |-p1 u1 : A1 ... Gamma |-pn An
-----------------------------------------------------------------------------
  Gamma |-r' (t u1 .. un) : B

with
 - r' is star if one of the r m1 .. mn p1 ... pn is star
 - if there is more than one argument and if one of the p1 ... pn is star
   then an ambiguities warning is printed.

now the type of the function doing physical manipulation is marked:

print_string : string ->* unit
:= : 'a ref -> 'a ->* unit
raise : exn ->* 'a
etc ....

the other function are unchanged.

I think we need something like that ! and I think it is really simple !

Hope this help to have a better language ....
Christophe Raffalli




  reply	other threads:[~1995-09-13 14:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-09-12  9:27 Release 1.06 of Caml Special Light Xavier Leroy
1995-09-13  8:15 ` Christophe Raffalli [this message]
1995-09-13 15:11   ` Suggestions Pierre Weis
1995-09-13 16:51     ` Suggestions Christophe Raffalli
1995-09-14  9:49       ` Suggestions Pierre Weis
1999-01-27  1:18 Suggestions Miles Egan
1999-01-27 18:48 ` Suggestions Jon Moore
1999-01-28 10:50   ` Suggestions Xavier Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199509130815.KAA21297@waldorf.cs.chalmers.se \
    --to=raffalli@cs.chalmers.se \
    --cc=caml-light@pauillac.inria.fr \
    --cc=caml-list@pauillac.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).