Browse thread
(int * int) <> int*int ?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2006-02-24 (13:08) |
From: | Alain Frisch <Alain.Frisch@i...> |
Subject: | Re: [Caml-list] (int * int) <> int*int ? |
Jacques Garrigue wrote: > The tuple based syntax for constructors is ambiguous: there is no way > to know syntactically whether a constructor takes as argument a tuple > or separate arguments. This is the reason for this whole discussion. In a sense, the same applies to functions. When a function is called, there is no way to know statically whether it expects more arguments (the call creates a closure) or not (the body of the function can be evaluated now). As you know, this is solved dynamically. One could imagine the same for variants. Applying a constructor with several syntactical arguments `A(arg1,arg2) would create a block [| `A; arg1; arg2 |] whereas "let x = (arg1,arg2) in `A x" would create a block [| `A; [| arg1; arg2 |] |]. Then it is up to pattern matching to be more clever and deal with the two possible cases at runtime (maybe one wants to use a non-zero tag for the block [| `A; arg1; arg2 |]), possibly creating new tuples as in "match `A(arg1,arg2) with `A x -> x". I'm not claiming that it is worth the extra complexity nor that it would really improve anything, though... -- Alain