Version franēaise
Home     About     Download     Resources     Contact us    
Browse thread
Compiler feature - useful or not?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin.jambon@e...>
Subject: Re: [Caml-list] Compiler feature - useful or not?
On Fri, 16 Nov 2007, Edgar Friendly wrote:

> Martin Jambon wrote:
>> Please don't take my suggestions too seriously, but it could be cool to
>> define types such as:
>>
>> type bit = [ 0 | 1 ]
>>
>>
>> Martin
>
> How about this:
>
> type permission =
>  User_read -> 0o400 | User_write -> 0o200 | User_execute -> 0o100
> | Group_read -> 0o40 | Group_write -> 0o20 | Group_execute -> 0o10
> | World_read ->  0o4 | World_write ->  0o2 | World_execute ->  0o1
>
> let combine (pl: permission list) =
> 	List.fold_left (fun a b -> a lor (b :> int)) 0 pl

I'm afraid of losing the following basic feature ("your first 
OCaml program"):

# 0;;
- : int

and instead get:

# 0;;
- : [< int > 0 ]

Perhaps polymorphism should not be the default, i.e. we would have to use 
a special keyword:

# poly 0;;
- : [< int > 0 ]
# 0;;
- : int




Martin

--
http://wink.com/profile/mjambon
http://martin.jambon.free.fr