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 DAA03534; Tue, 26 Aug 2003 03:41:03 +0200 (MET DST) 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 DAA07809 for ; Tue, 26 Aug 2003 03:41:02 +0200 (MET DST) Received: from hall.mail.mindspring.net (hall.mail.mindspring.net [207.69.200.60]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7Q1f1f16252 for ; Tue, 26 Aug 2003 03:41:01 +0200 (MET DST) Received: from user-0ccekej.cable.mindspring.com ([24.199.81.211] helo=[192.168.0.3]) by hall.mail.mindspring.net with esmtp (Exim 3.33 #1) id 19rSpQ-0004YE-00 for caml-list@inria.fr; Mon, 25 Aug 2003 21:41:00 -0400 Subject: Re: [Caml-list] hash objectified From: "Yaron M. Minsky" To: Caml List In-Reply-To: <20030825173217.GA24098@cs.brown.edu> References: <20030821165832.GA5890@force.stwing.upenn.edu> <20030825154639.GC2900@mlabdial.hit.bme.hu> <20030825173217.GA24098@cs.brown.edu> Content-Type: text/plain Organization: Cornell University Message-Id: <1061862059.15526.15.camel@dragonfly.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 25 Aug 2003 21:40:59 -0400 Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 hash:01 yaron:01 minsky:01 yminsky:01 cornell:01 hash:01 hashtable:01 obscurity:01 uninitiated:01 hashtbl:01 equivalents:01 32,:01 renieris:01 kontra:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk My take on the same problem was to define infix notation for a few oft-used operations, including some hash table operations. To that end I defined h |> k to lookup key k in hashtable h, and h |< (k,d) to add the key,data pair (k,d) to h. It has the downside of obscurity to the uninitiated, but I find it a lot easier to read code that uses these operators than the rather overlong Hashtbl.* equivalents. y On Mon, 2003-08-25 at 13:32, Manos Renieris wrote: > On Mon, Aug 25, 2003 at 05:46:39PM +0200, KONTRA Gergely wrote: > > > > Hashtbl.add h "foo" "bar" <--> h#add "foo" "bar" > > > > Because it is shorter to type -> less errors, quicker programming > > OO can be cool. (see ruby) > > I'm not OO fan, but lazy :) > > If that's the reason, once you do > module H = Hashtbl > then > H.add h "foo" "bar" > is only two characters longer, and one shift shorter :-) > And the compiler ensures the exact type of h, and you know statically > what function you call -> less to keep in your head -> less errors, > quicker programming. > > -- Manos > > ------------------- > 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 -- |--------/ Yaron M. Minsky \--------| |--------\ http://www.cs.cornell.edu/home/yminsky/ /--------| Open PGP --- KeyID B1FFD916 (new key as of Dec 4th) Fingerprint: 5BF6 83E1 0CE3 1043 95D8 F8D5 9F12 B3A9 B1FF D916 ------------------- 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