caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: skaller@users.sourceforge.net
Cc: warplayer@free.fr, caml-list@inria.fr
Subject: Re: [Caml-list] Why doesn't ocamlopt detect a missing ; after failwith statement?
Date: Fri, 26 Nov 2004 14:25:25 +0900 (JST)	[thread overview]
Message-ID: <20041126.142525.93385094.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <1101438486.9291.138.camel@pelican.wigram>

From: skaller <skaller@users.sourceforge.net>
> > But by definition 'a unifies with everything, including your void
> > type, or you get a noncommutative notion of unification...
> 
> Can you give an example? I presume you mean that 
> the invariant U(t1,t2) == U(t2,t1) would break?

Not exactly, I rather meant that unification steps would not commute.
This happens sometimes when you allow unification between specialized
forms, but not with type variables.
However, I do not understand completely what you mean by void type,
and how they would relate to type variables, so it is not clear
whether this is the problem.

For instance, you say that (void * t) should be void, which suggests
that void is really the type with 0 elements (i.e. not unit.)
However, from a logical point of view (i.e. intuitionistic logic), no
function can be allowed to return such a type. It may accept it as
input, but this just means it is unusable.
Note that void in C is definitely not zero. You cannot have variables
of type void, but you can have non-null pointers to void. If void were
really zero, then a void pointer would necessarily be NULL.
It looks more like an existential type, (\exists a.a), which is
actually equivalent to unit, with special rules to deal with the fact
its physical representation is unknown.

Concerning intersection types in ocaml, int&bool is not a type by
itself.  It may only appear as a variant argument. In that case this
just means that this variant case cannot be used. In the past, [ ] was
a valid variant type, and would have been zero, but I removed it as it
does not make sense, and may delay some type errors. Types with only
one variant may not be conjunctive either. So the closest you can get
to zero now is a polymorphic type like [< `A of int&bool | `B of int&bool].
Even with [ ] there was no problem of commutation, because
unification with 'a was allowed, i.e. ([ ] * int) and [ ] were
different types; which was why it was clumsy to have
zero in the language: there is nothing as stupid as moving provably
non-existing data around, as it means that the code will never be used
anyway.

Jacques Garrigue

P.S.
I believe the problem with failwith is solvable, albeit rather
complicated. The idea is that you want to be warned when you apply a
function of type (\forall 'a. 'a) to something, because no such
function may exist, so that this application will never actually take
place.
This could be done attempting to generalize the type of the function,
once we now it is a type variable.
I'll have a try.


  reply	other threads:[~2004-11-26  5:25 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-25 20:46 Richard Jones
2004-11-25 21:14 ` [Caml-list] " Nicolas Cannasse
2004-11-26  0:11   ` skaller
2004-11-26  0:44     ` Jacques Garrigue
2004-11-26  3:08       ` skaller
2004-11-26  5:25         ` Jacques Garrigue [this message]
2004-11-26  7:08           ` Nicolas Cannasse
2004-11-26 14:42             ` Jacques Garrigue
2004-11-26 17:01               ` Alain Frisch
2004-11-26 19:36             ` Michal Moskal
2004-11-26 17:01           ` Damien Doligez
2004-11-29  0:40             ` Jacques Garrigue
2004-11-29 11:07               ` [Caml-list] Why doesn't ocamlopt detect a missing ; afterfailwith statement? Frederic van der Plancke
2004-11-29 11:43                 ` Jacques Garrigue
2004-11-29 11:27               ` Frederic van der Plancke
2004-11-26 22:24           ` [Caml-list] Why doesn't ocamlopt detect a missing ; after failwith statement? Hendrik Tews
2004-11-27  3:47             ` skaller
2004-11-29  0:01             ` Jacques Garrigue
2004-11-29  7:52               ` Marcin 'Qrczak' Kowalczyk
2004-11-26  3:58       ` skaller
2004-11-26 19:16     ` Brian Hurt
2004-11-26  9:01   ` Richard Jones
2004-11-26  9:56     ` skaller
2004-11-26 13:32     ` Ville-Pertti Keinonen

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=20041126.142525.93385094.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=skaller@users.sourceforge.net \
    --cc=warplayer@free.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).