Version française
Home     About     Download     Resources     Contact us    
Browse thread
ambitious proposal: polymorphic arithmetics
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Marcin 'Qrczak' Kowalczyk <qrczak@k...>
Subject: Re: [Caml-list] ambitious proposal: polymorphic arithmetics
Eijiro Sumii <eijiro_sumii@anet.ne.jp> writes:

> # let d = (Obj.magic (Obj.magic B + Obj.magic B) : t) ;;
> val d : t = <unknown constructor>
> # (function A -> 78 | B -> 90) d ;;
> - : int = 90
> # 
> ----------------------------------------------------------------------
>
> So, it indeed leads to "unknown" values and behaviors, but doesn't
> seem to break memory safety (in this case, at least).

# type t = A | B | C;;
type t = A | B | C
# match (Obj.magic (Obj.magic C + Obj.magic C)) with A -> 0 | B -> 1 | C -> 2;;
zsh: segmentation fault  ocaml

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak@knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/