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 VAA15654; Fri, 14 Mar 2003 21:02:03 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 VAA15024 for ; Fri, 14 Mar 2003 21:02:01 +0100 (MET) Received: from ijael.cql.com (jael.cql.com [216.19.209.133]) by concorde.inria.fr (8.11.1/8.11.1) with SMTP id h2EK20f01776 for ; Fri, 14 Mar 2003 21:02:00 +0100 (MET) Received: (qmail 15563 invoked from network); 14 Mar 2003 21:08:38 -0000 Received: from unknown (HELO debian.cql.com) (192.168.1.14) by ijael.cql.com with SMTP; 14 Mar 2003 21:08:38 -0000 From: Seth Kurtzberg Organization: M. I. S. To: Max Kirillov Subject: Re: [Caml-list] Re: Haskell-like syntax Date: Fri, 14 Mar 2003 13:01:59 -0700 User-Agent: KMail/1.5 References: <005d01c2e76f$92d0f8b0$2713f9ca@WARP> <20030314003336.D748@max.home> <20030315013056.C5826@max.home> In-Reply-To: <20030315013056.C5826@max.home> Cc: caml-list@pauillac.inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200303141301.59458.seth@cql.com> X-Spam: no; 0.00; caml-list:01 haskell-like:01 kirillov:01 0600,:01 camlp:01 hacks:01 demonstrate:01 'where':99 expr:01 reorder:01 binded:01 gui:01 infer:01 struct:01 661:99 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I find this syntax (with WHERE) much more intuitive than the alternatives. I strongly support the effort to integrate this into OCaml. While it seems like a small thing in practice it makes it much easier to see what is actually going on, which is of course very desirable. On Friday 14 March 2003 12:30 pm, Max Kirillov wrote: > On Fri, Mar 14, 2003 at 12:33:36AM +0600, Max Kirillov wrote: > > Talking about the single thigs: at the beginning of my way into ocaml, I > > did some camlp4 hacks. For example, that was "where" keyword support > > (much more powerful than in revised syntax) and some support for "from > > top to bottom" style of sources. If you interested, I could post them. > > I'm sending the changes. Note that, though they are quite stable, I > picked them from an environment, so something may broke. > > A little comment what is it. > > file test_where.ml -- obvious. Very little, more to demonstrate, than to > cover all possible (and really seen) dangers. > > file lazyX.ml -- misc functions to handle lazy values (see later) > note that it is already uses the extension > > file where.ml -- the main thing > > There are several things: > > 1) 'where' notation: > > ::= where { [rec] } > > | where [begin] [rec] end > > the two version are the same (some like {..}, some begin..end). > there are some unresolved quastions with prioriries, so, in practice, I > often had to use brackets. However, I think that the level I choose is > quite reasonable. > > 2) reorder srt_items > > there are keyword 'WHERE' (uppercase) in place of structure item. At the > point, the structure (or the whole file if at toplevel) is cut, then > pieces swapped and concated again. this allows writing: > > ------- file.ml > main ();; > WHERE > let main () = > do_this (); > do_that ();; > WHERE > let do_this () = > <.......> > and do_that () = > <........> > ------ > > 3) lazy values predeclaration > > ::= [let] [lazy] [rec] > > this allows define lazy value, which is seen to the whole structure, and > not only to the following items. Every value that is binded is lazy > value, that, when forced, computes the definition. It uses the LazyX > module: nondef () produces the value, set dest src replaces the > unforced lazy value dest by the unforced lazy expression src, if any of > then is already forced (it is at module initialization time, so it's > easy to catch), the exception is raised. > > I used it in plays with "functional GUI", where needed to declare many > inter-depended values and, for various reasons, didn't want to use "let > rec <...> and <...>" chain. > > There is one trouble. When you define a type, and then a lazy value of > the type, the compiler complains "the type xxx would escape its scope". > this berore it comes to need to infer the type for the initial > declaration "let x = LazyX.nondef ()", where it is not yet defined. > To solve the problem, I added "HEADER" keyword. It explicitly says that > the forward declataions must be placed here instead of beginning of the > file. You place it after the type declaration. Of course the lazy values > definitions must itself follow the type declarations. > > The lazy stuff is intended to work only in toplevel, it is not for > "struct..end". > > I used the (1) very much, and would say it quite workable. The (2) is > also quite stable, but, now, I would say the realization needs to be > changed. The (3) are more a toy than real thing. There could be problems > with that. -- Seth Kurtzberg M. I. S. Corp. 480-661-1849 seth@cql.com ------------------- 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