Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 66937 invoked from network); 6 Dec 2010 15:23:26 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 Dec 2010 15:23:26 -0000 Received: (qmail 90164 invoked by uid 500); 6 Dec 2010 15:23:26 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 90018 invoked by uid 500); 6 Dec 2010 15:23:26 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 90010 invoked by uid 99); 6 Dec 2010 15:23:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Dec 2010 15:23:25 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of paul.joseph.davis@gmail.com designates 209.85.161.172 as permitted sender) Received: from [209.85.161.172] (HELO mail-gx0-f172.google.com) (209.85.161.172) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Dec 2010 15:23:19 +0000 Received: by gxk28 with SMTP id 28so6278182gxk.31 for ; Mon, 06 Dec 2010 07:22:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=d+nqkOhLD/Zy0WxR5NYoev9wYBa0tN0ww+J+YI5xajI=; b=XquNBaLbYnxjiwGFVWPBJfoR1PlVhdq3iv1ZsVpWFMfGAPHCxar3387X3zatZSDAuN CHW/XaVZblsfvoZDlfMzGjPabH5zZgiYKKuVdNJI6TDQJD/HADN+c4xyA9TEuwnzf41c tB/iRKpUVA0sruoIansdFynozmm2KubuCB3SU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=tl2DNCF2L+xhkv6hKvJeRdW+dN7fCpcVNNOgV/xv1sJOduBhfU02TOb9NCHR3p40vs y/bLAIueJ+Z8PaVjzb1VO/Rvhxr9gnW8fnmvC8GMEIMWj09DNgooKP1avXyo8j/t4VOU xXpkHn36qWokSWPOS0mvUmJgsBG6qZvd3AdFo= Received: by 10.231.38.4 with SMTP id z4mr5995161ibd.151.1291648977781; Mon, 06 Dec 2010 07:22:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.39.65 with HTTP; Mon, 6 Dec 2010 07:22:17 -0800 (PST) In-Reply-To: <43AC30C7-11FF-4F65-B9F5-E6637B1A7F52@apache.org> References: <20101204230658.35D6C23889E1@eris.apache.org> <43AC30C7-11FF-4F65-B9F5-E6637B1A7F52@apache.org> From: Paul Davis Date: Mon, 6 Dec 2010 10:22:17 -0500 Message-ID: Subject: Re: svn commit: r1042260 - /couchdb/trunk/src/couchdb/couch_native_process.erl To: dev@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Mon, Dec 6, 2010 at 10:19 AM, Adam Kocoloski wrote= : > On Dec 5, 2010, at 5:34 AM, Paul Davis wrote: > >> On Sun, Dec 5, 2010 at 3:19 AM, Jason Smith wrote: >>> On Sun, Dec 5, 2010 at 6:06 AM, =A0 wrote: >>>> + =A0 =A0 =A0 =A0case catch Fun(Doc, Req) of >>>> + =A0 =A0 =A0 =A0true -> true; >>>> + =A0 =A0 =A0 =A0false -> false; >>>> + =A0 =A0 =A0 =A0{'EXIT', Error} -> ?LOG_ERROR("~p", [Error]) >>>> + =A0 =A0 =A0 =A0end >>> >>> The O'Reilly book _Erlang Programming_ suggests that catch expressions >>> (the older form before try...catch came out) are not as elegant as >>> try...catch. >>> >>> http://books.google.com/books?id=3DQr_WuvfTSpEC&pg=3DPA74&lpg=3DPA74&so= urce=3Dbl&ots=3DaK-DfyxREb&sig=3DLA1Fi-lSKEPJNvMFdp0kXzOxDg8&hl=3Den&ei=3DW= 0T7TJLpMY_QrQffr4HBCA&sa=3DX&oi=3Dbook_result&ct=3Dresult&resnum=3D1&ved=3D= 0CBIQ6AEwAA#v=3Donepage&q&f=3Dfalse >>> >>> Also Joe Armstrong's book states that you lose a lot of precision >>> analyzing the cause of an error. >>> >>> FYI. >>> >>> -- >>> Jason Smith >>> CouchOne Hosting >>> >> >> I'm not sure about the book's definition of elegant, but: >> >> case (catch Fun()) of >> =A0 Val1 -> foo; >> =A0 Val2 -> bar; >> =A0 {Error, Reason} -> other >> end >> >> Seems more readable than: >> >> try >> =A0 =A0case Fun() of >> =A0 =A0 =A0 =A0Val1 -> foo; >> =A0 =A0 =A0 =A0Val2 -> bar >> =A0 =A0end >> catch >> =A0 =A0throw:{Error, Reason} -> other >> end >> >> Its true that you end up collapsing the Error and Response domains >> into a single namespace, but in general, most things don't look like >> errors. > > It can be made simpler: > > try Fun() of > =A0 =A0Val1 -> foo; > =A0 =A0Val2 -> bar > catch > =A0 =A0{Error, Reason} -> other > end > > That's not bad. I've never seen "try F() of" before. Is it new or am I blin= d?