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: Edgar Friendly <thelema314@g...>
Subject: Re: [Caml-list] Compiler feature - useful or not?
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

E.