Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Again on pattern matching and strings
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alexander V.Voinov <avv@q...>
Subject: Re: [Caml-list] Again on pattern matching and strings
Hi Alessandro,

From: Alessandro Baretta <alex@baretta.com>
Subject: [Caml-list] Again on pattern matching and strings
Date: Thu, 24 Oct 2002 01:47:33 +0200

> | Some ( "\027(U\001\000\005" ) -> ...
> | Some ( "\027@" ) -> ...
> | Some ( "\012" ) -> ...
> 
> And so on. This is completely unreadable. I think this 
> problem requires a solution like C++ const variables: values 
> which the compiler considers compile time constants and 
> directly substitutes into the code in place of the 
> identifier name. Now, "const" is rather meaningless in a 
> functional language, so I suggest "alias" as a better 
> alternative. For example
> 
> alias printer_set_unit = "\027(U\001\000\005"
> 
> whereby such an identifier cannot be hidden by a new let 
> binding (compile-time error) and is considered a constant in 
> patterns.

You can use camlp4 for this. One of the entry level examples
concern introduction of named constants. 

Alexander
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners