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

On Fri, 2004-11-26 at 11:44, Jacques Garrigue wrote:

> But by definition 'a unifies with everything, including your void
> type, or you get a noncommutative notion of unification...

BTW: I still don't have a clear understanding of exactly
how problems arise with void with intensional polymorphism.
The typing with a distributive category is clearly sound.
AFAIK this extends to a cartesion closed category.

One might think that extra checks would be needed
which would have to be done at run time with intensional
polymorphism. For example:

let snd (x,y) = y

Here, 'a * 'b is isomorphic to void if 'a or 'b is void.
The definition of snd then doesn't make sense.
The actual problem, however, isn't void, but the incorrect
assumption that a pair can represent a polymorphic tuple:
it isn't the typing that is unsound, but the
choice of canonical representation of product.

The problem would go away if the pointer to the heap
block was NULL for void, but this would require
extra NULL checks at run time.

However, this particular example cannot ever lead
to a problem, since you can't actually create a variable
of void type (there's no value to put in it) so no
possible instantiation of 'snd' can fail.

[There is a clearly related issue with unit: the
types 'a and 1 * 'a are isomorphic, but the definition
of numbered projections prevents the useless unit
being optimised away -- the language guarrantees
not to apply this isormorphism simply because it
would break the run time representation.]

However I don't know if this argument can be extended
in the presence of function types. It would seem that
without a primitive function returning void, there's
no way to encode one that returns void either.

However if you have a primitive f:'a-> void you can
obviously create new functions returning void, for
example:

let g f x = f x
let h x = g f x

However I still don't see how you can ever call such a function
in a way that actually tries to pass a value of type void.
That value has to come from somewhere and there is no way
to make one: a call 

   f x

is manifestly of type void, and so, for example,

	(f x, 99)

is manifestly of type void.

My thinking is that if you can't catch an improper use
of void at compile time, then there can't be one
at run time either (in other words its quite sound).

I would like to see an example where this is not the case.
I'm suspicious, because void is the categorical initial,
and a fundamental part of many of the models for computing
I've seen based on category theory -- and my understanding
is that the CT approach is just an alternative to lambda calculus
(i.e. they're equivalent).

So it looks to me that not providing an algebraic void
is a way to simplify the representation -- not a matter
of unsoundness.

BTW: Ocaml unification must already handle void: it supports
intersection types internally, and int & float is void.
How is it that this also doesn't lead to non-commutative unification?

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net




  parent reply	other threads:[~2004-11-26  3:58 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
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 [this message]
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=1101441498.9291.182.camel@pelican.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    --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).