From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA11041 for caml-redistribution; Sun, 16 Jan 2000 22:30:08 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA00160 for ; Sat, 15 Jan 2000 20:06:47 +0100 (MET) Received: from miss.wu-wien.ac.at (miss.wu-wien.ac.at [137.208.107.17]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id UAA02716 for ; Sat, 15 Jan 2000 20:06:45 +0100 (MET) Received: (from mottl@localhost) by miss.wu-wien.ac.at (8.9.0/8.9.0) id UAA05127 for caml-list@inria.fr; Sat, 15 Jan 2000 20:06:30 +0100 (MET) From: Markus Mottl Message-Id: <200001151906.UAA05127@miss.wu-wien.ac.at> Subject: Polymorphic variants for basic types? To: caml-list@inria.fr (OCAML) Date: Sat, 15 Jan 2000 20:06:30 +0100 (MET) X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: weis Hello, this idea has probably already been considered: what do you think about translating basic values prefixed by "`" to polymorphic variants automatically during compilation? E.g. match foo with match foo with | `"Some string" -> ... to | `String "Some string" -> ... | `42 -> | `Int 42 -> ... | `[x; y; z] -> | `List [x; y; z] -> ... ... As far as I can see, this would not be a difficult thing to do, because it only seems to require syntactic information. Probably even the preprocessor could be used for this. Some nice things would be possible then, like the one above or conveniently writing down complex datastructures (e.g. trees with arbitrary numbers of subnodes): let tree = `[ `3; `[`4; `5]; `[ `[`6] ] ] in ... which is probably much easier to write than: let tree = `List [ `Int 3; `List [`Int 4; `Int 5]; `List [ `List [`Int 6] ] ] in ... Anyway, this is just a small feature suggestion - I am sure there are more important language properties at the moment to reason about. Regards, Markus Mottl -- Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl