Version française
Home     About     Download     Resources     Contact us    
Browse thread
Ocaml compiler features
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Tom <tom.primozic@g...>
Subject: Re: [Caml-list] Ocaml compiler features
>
>
> Second, I have some ideas of things to do with Atomic Variants (sounds
> like they could be a monster in a sci-fi movie).  First thing is to
> somehow allow the use of a type composed of all Atomic (non-polymorphic)
> Variants as an integer type.  One thing I want to do is index arrays
> with them.
>

Hm... instead of having

  type food = Carrot | Apple | Pizza | Coke | Sushi

  let in_supply = Array.create 5 0

  in_supply.(Coke) <- 20

you could do it like this instead

  let carrot, apple, pizza, coke, sushi = 0, 1, 2, 3, 4

  let in_supple = Array.create 5 0

  in_supply.(coke) <- 20

. What do you think?

- Tom