caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* arrays and type variables...
@ 1998-11-25 13:57 Don Syme
  1998-11-26 15:33 ` Pierre Weis
  1998-11-26 16:03 ` Andreas Rossberg
  0 siblings, 2 replies; 3+ messages in thread
From: Don Syme @ 1998-11-25 13:57 UTC (permalink / raw)
  To: caml-list


Shouldn't "[| [] |]" count as a value??

bash$ ocaml
        Objective Caml version 2.00

# let x = [| [] |];;
val x : '_a list array = [|[]|]
# let x = [];;
val x : 'a list = []
# let x = [| |];;
val x : 'a array = [||]
#

Cheers,
Don




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

* Re: arrays and type variables...
  1998-11-25 13:57 arrays and type variables Don Syme
@ 1998-11-26 15:33 ` Pierre Weis
  1998-11-26 16:03 ` Andreas Rossberg
  1 sibling, 0 replies; 3+ messages in thread
From: Pierre Weis @ 1998-11-26 15:33 UTC (permalink / raw)
  To: Don Syme; +Cc: caml-list

> Shouldn't "[| [] |]" count as a value??
> 
> bash$ ocaml
>         Objective Caml version 2.00
> 
> # let x = [| [] |];;
> val x : '_a list array = [|[]|]
[...]
> Cheers,
> Don

No, we can't, since it is equivalent to create a polymorphic reference
(you just have to put the value into a list and to assign this list to
the vector). This would break the type system's safety theorem: it
would lead to ``bus errors''.

Best regards,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/





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

* Re: arrays and type variables...
  1998-11-25 13:57 arrays and type variables Don Syme
  1998-11-26 15:33 ` Pierre Weis
@ 1998-11-26 16:03 ` Andreas Rossberg
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Rossberg @ 1998-11-26 16:03 UTC (permalink / raw)
  To: caml-list; +Cc: Don Syme

Don Syme wrote:
> 
> Shouldn't "[| [] |]" count as a value??
> 
> # let x = [| [] |];;
> val x : '_a list array = [|[]|]
> # let x = [];;
> val x : 'a list = []
> # let x = [| |];;
> val x : 'a array = [||]

No, because you can assign to arrays:

# let x = [| [] |];;
val x : '_a list array = [|[]|]
# x.(0) <- [1];;
- : unit = ()
# x;;
- : int list array = [|[1]|]

You cannot assign anything to the empty array [| |], however.

Regards,

	- Andreas

-- 
Andreas Rossberg, rossberg@ps.uni-sb.de

:: be declarative. be functional. just be. ::




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

end of thread, other threads:[~1998-11-26 16:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-25 13:57 arrays and type variables Don Syme
1998-11-26 15:33 ` Pierre Weis
1998-11-26 16:03 ` Andreas Rossberg

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