From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA12985; Thu, 22 Aug 2002 15:15:23 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 PAA13017 for ; Thu, 22 Aug 2002 15:15:22 +0200 (MET DST) Received: from fichte.ai.univie.ac.at (fichte.ai.univie.ac.at [131.130.174.156]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g7MDFLX21144 for ; Thu, 22 Aug 2002 15:15:21 +0200 (MET DST) Received: from bach.ai.univie.ac.at (markus@bach.ai.univie.ac.at [131.130.174.139]) by fichte.ai.univie.ac.at (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id PAA27093; Thu, 22 Aug 2002 15:15:20 +0200 Received: (from markus@localhost) by bach.ai.univie.ac.at (8.12.3/8.12.3/Debian -4) id g7MDFKaN006014; Thu, 22 Aug 2002 15:15:20 +0200 Date: Thu, 22 Aug 2002 15:15:20 +0200 From: Markus Mottl To: Oliver Bandel Cc: Oleg , caml-list@inria.fr Subject: Re: [Caml-list] Calling a function with a self-defined type as argument Message-ID: <20020822131519.GA32496@bach.ai.univie.ac.at> Mail-Followup-To: Oliver Bandel , Oleg , caml-list@inria.fr References: <200208220149.VAA14728@dewberry.cc.columbia.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i Organization: Austrian Research Institute for Artificial Intelligence Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Oliver Bandel schrieb am Thursday, den 22. August 2002: > But the Line ("text")-argument is only complete as a Line(), > if Line() has a higher priority than the function-call. > I have *one* argument, which is complete if given EMPTY, > and complete if given Line ("argument"). The parser attempts to parse arguments of a function call, all of which must be expressions. "Line" is not an expression, it's just a data constructor. To disambiguate things, you have to use parentheses. Note that your proposal that the compiler should use type definitions to see how many arguments constructors take would make sources really unreadable for humans. Things are perfect as they are. > Shouldn't be types have a higher priority than calls > in this case? "Line" is not a type but a data constructor. It just allows you to discriminate between values. > Is Line() in this example handled like an ordinary function? Even if it were a function, you'd still need parentheses, otherwise you'd get into troubles with partial function applications, which sometimes need disambiguation, because the semantics wouldn't be necessarily clear. > But I want here a complete picture, and I thought > the compiler would put the parts together: How to > put them together is clear: I have said it him in the > type-declaration. It may be clear here but not always. Even if things can be tractably analyzed by an intelligent compiler, you still need to enforce readability of sources. It would be absolute hell to let people parse such programs, because they'd constantly have to look up type definitions in other places to parse things correctly. Not a problem for a compiler - huge problem for humans! LG, Markus -- Markus Mottl markus@oefai.at Austrian Research Institute for Artificial Intelligence http://www.oefai.at/~markus ------------------- 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