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 PAA24172; Tue, 3 Apr 2001 15:58:36 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA24203 for ; Tue, 3 Apr 2001 15:58:35 +0200 (MET DST) Received: from smtpproxy1.mitre.org (mb-20-100.mitre.org [129.83.20.100]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f33DwWf12662 for ; Tue, 3 Apr 2001 15:58:32 +0200 (MET DST) Received: from avsrv1.mitre.org (avsrv1.mitre.org [129.83.20.58]) by smtpproxy1.mitre.org (8.9.3/8.9.3) with ESMTP id JAA05396 for ; Tue, 3 Apr 2001 09:58:30 -0400 (EDT) Received: from linus.mitre.org (linus.mitre.org [129.83.10.1]) by smtpsrv1.mitre.org (8.9.3/8.9.3) with ESMTP id JAA09830; Tue, 3 Apr 2001 09:58:29 -0400 (EDT) Received: from malabar.mitre.org (malabar.mitre.org [129.83.10.30]) by linus.mitre.org (8.9.3/8.9.3) with ESMTP id JAA01887; Tue, 3 Apr 2001 09:58:29 -0400 (EDT) Received: (from guttman@localhost) by malabar.mitre.org (8.9.3/8.9.3) id JAA08031; Tue, 3 Apr 2001 09:58:29 -0400 X-Authentication-Warning: malabar.mitre.org: guttman set sender to guttman@mitre.org using -f To: caml-list@inria.fr Cc: guttman@mitre.org (Joshua D. Guttman) Subject: Re: [Caml-list] Future of labels, and ideas for library labelling Reply-To: guttman@mitre.org (Joshua D. Guttman) References: <20010403093527G.garrigue@kurims.kyoto-u.ac.jp> <20010403125314Q.garrigue@kurims.kyoto-u.ac.jp> <20010403105212.A15700@pauillac.inria.fr> From: guttman@mitre.org (Joshua D. Guttman) Date: 03 Apr 2001 09:58:28 -0400 In-Reply-To: Xavier Leroy's message of "Tue, 3 Apr 2001 10:52:12 +0200" Message-ID: User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I'm very grateful to Xavier Leroy for his posting. I've been listening to the labels discussion with increasing anxiety. I think we should make sure it remains possible to read and write Caml code without added syntactic tangles; those tildes remind me of whiskers. More seriously, I find the syntax of Caml already fairly obtrusive (versus Lisp and Scheme), and labels seem to me to make it a good deal clumsier. Why obstruct the fact that lots of code in a language like OCaml is simply applying functions to arguments? That's the way it should be in a functional language. Jacques Garrigue contrasts > List.fold_right (List.fold_right IntSet.add) lists IntSet.empty with > > List.fold_left lists ~init:IntSet.empty > ~f:(fun set l -> > List.fold_left l ~init:set ~f:(fun set x -> IntSet.add x set)) and > List.fold_left lists ~acc:IntSet.empty > ~f:(List.fold_left ~f:(fun ~acc item -> IntSet.add acc ~item)) To my eye, the original looks clean and compact. The altered versions? They're not appealing to me. What are the arguments in favor of imposing labels on the rest of us? 1. Optional arguments: Well, this is occasionally useful, but I think not that often, at least in the kinds of programs I write. So the thing to achieve, in my opinion, is there should be no additional syntactic complication for writing or calling procedures that don't use them. 2. Default values: The Lisp-style solution to this was dynamic binding. The default is stored in some mutable location; callers that want a different value store a new value and restore the original on return. The language then provides some syntactic sugar (a macro) to make the alteration and restoration appear atomic, and to ensure that the default value is restored even in the case of non-local exit. For instance, in the Yale dialect of Scheme, called T, there was a construct "bind". I remember the manual saying, "Bind is syntactically similar to let but semantically very different." The non-local exits were handled, within the "bind" macro definition, using unwind-protect, which was a primitive that would stipulate code to be run if the stack was unwound past the call site. I don't often need default values, but I expect that the equivalent could be rather easily implemented using exception handlers. This would not affect any other aspect of the language. 3. Documentation. Why force every caller of a procedure to re-document the interface to the procedure? That's what you're enforcing if the user has to write the labels. When it comes to documentation, there's no substitute for using the documentation itself. Consider Emacs, the original self-documenting programming language (and it also contains a handy text editor :-). Here the convention is that you document individual function definitions at a particular place; the "run-time system" then arranges for it to be very easy for users to access the documentation for every function (via C-h f). There's even completion if you type part of the name and want to see what function symbols start that way. The etags program also provides a lot of support for people writing in other programming languages. By the way, whatever happened to the OCaml mletags program? I think it's been defunct since Ocaml 1. We could invent ways that people could get some of the benefit of the Emacs help system for Ocaml definitions documented in the manual. I've been tinkering with an Emacs procedure that calls grep to find occurrences of a name in the manual, and W3 to display the corresponding HTML within Emacs. But the point here is to make documentation easily accessible, or to make it easy to find the site of definition for a procedure. It's wrong in my opinion to make the user repeat the documentation in the form of tilded labels at every use. 4. Commuting arguments. This has to be a pretty specialized need, especially assuming programmers have easy access to documentation to find the intended order. You're going to clutter a whole language to support this peripheral need? This language is complicated already. It's extremely good, and I'm doing my best to convert others to be followers of the cult too. But it's complicated, and we'll fight more losing battles to teach people to use it if it becomes syntactically more cluttered. Whether it's a question of students (as in Benjamin Pierce's case) or colleagues (as in mine), let's not block access to the really good (but subtle) ideas in the language by complicating the way that it's written. So my vote: Please ensure that the programmer will not have to use labels, except perhaps when using specialized libraries (e.g. for GUIs). But to all participants, I'd like to say once more: It's a splendid language, the product of enormous intelligence and hard work, and I appreciate being able to use it. Joshua -- Joshua D. Guttman MITRE, Mail Stop S119 202 Burlington Rd. Tel: +1 781 271 2654 Bedford, MA 01730-1420 USA Fax: +1 781 271 3816 ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr