Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82364 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74905 invoked from network); 10 Feb 2015 10:28:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Feb 2015 10:28:19 -0000 Authentication-Results: pb1.pair.com header.from=pthreads@pthreads.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=pthreads@pthreads.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pthreads.org from 209.85.192.182 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 209.85.192.182 mail-pd0-f182.google.com Received: from [209.85.192.182] ([209.85.192.182:43141] helo=mail-pd0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EA/33-47508-24DD9D45 for ; Tue, 10 Feb 2015 05:28:19 -0500 Received: by pdev10 with SMTP id v10so15676315pde.10 for ; Tue, 10 Feb 2015 02:28:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=o5Kkpr6rlAKOU/6d08GCRg6vR+HffZj2i+mhoDqAhMI=; b=cYg+fUrJazIm3jG/kg1nufK9U7Yft0n2POHSOj/M/QfanJOlU5W4/wnyfDBV8YPlpH sUyywyb4VWoNJbu+HU4u6+fa4Ni/0da8hbjYwg3D5ptdnUr0WseX1io1tFzWxbmrcBsO V1C4JyPZ+NbpWf9/lNuD6f09E883dvM0ue3YajoOsahiFINoF+7wy/h6ywGuFPUOQ/+5 EEU9xV5jhC0yuw9Ohhin5koH51rGNO7AGhfJkEHwgX+8+/Rm8IblY5ZnEWaD4KlBy/J7 AbhIjSP1/5aqM57c8JZUfeMTVw8CQtqFflEBYt4ag4im3XTSbNzWndNl54VPoFUIA54U +Y5w== X-Gm-Message-State: ALoCoQmpRDzeTJ9RTC0toqkGjXaGUKb0m6SNKpTAvfj7a3+Q4S890QskZ2wuA8AHPl+FMrOvQkxq MIME-Version: 1.0 X-Received: by 10.66.146.168 with SMTP id td8mr36252474pab.20.1423564096156; Tue, 10 Feb 2015 02:28:16 -0800 (PST) Received: by 10.70.49.100 with HTTP; Tue, 10 Feb 2015 02:28:16 -0800 (PST) X-Originating-IP: [109.145.22.92] In-Reply-To: References: <54D7ED22.3080001@gmail.com> Date: Tue, 10 Feb 2015 10:28:16 +0000 Message-ID: To: Dmitry Stogov Cc: Patrick Schaaf , internals , Yasuo Ohgaki Content-Type: multipart/alternative; boundary=047d7b677884444e0d050eb95832 Subject: Re: [PHP-DEV] Design by Contract From: pthreads@pthreads.org (Joe Watkins) --047d7b677884444e0d050eb95832 Content-Type: text/plain; charset=UTF-8 > may be something similar to Smaltalk block syntax: return(, [, ]) That's a good approximation of perfect, I think ... looks okay to me. Cheers Joe On Tue, Feb 10, 2015 at 10:21 AM, Dmitry Stogov wrote: > D uses block syntax: > > ensure(ret) { > } > > In this case, passing 'ret' as a 'parameter' looks more or less natural. > > In our case, two sets of brackets looks weird. > Predefined variable or constant looks better. > A agree, __RETURN__ is longer than $ret, but it also won't conflict with > other variables. > I don't see a perfect solution yet. > > may be something similar to Smaltalk block syntax: return(, > [, ]) > > function add($a, $b) > return($ret, $ret > 0) > { > return $a + $b; > } > > Thanks. Dmitry. > > On Tue, Feb 10, 2015 at 1:03 PM, Joe Watkins > wrote: > >> The solution D uses is allowing the programmer to declare the name of the >> return value like, we could do something like: >> >> public function method() >> return ($result) ($result <= 10 && $result >= 0) { >> return 5; >> } >> >> If you didn't need the result, were working with a scope variable, or >> maybe even a param taken by reference: >> >> public function method() >> return ($expr) { >> /* ... */ >> } >> >> I'm not keen on __CONSTANTS__, it's long, and if you have the choice to >> name the variable you have the option of making the expression ... >> expressive ... >> >> Cheers >> Joe >> >> On Tue, Feb 10, 2015 at 9:48 AM, Dmitry Stogov wrote: >> >>> I think __RETURN__ is better than $ret. >>> >>> Dmitry. >>> >>> On Tue, Feb 10, 2015 at 12:43 PM, Patrick Schaaf wrote: >>> >>>> Am 10.02.2015 09:29 schrieb "Dmitry Stogov" : >>>> > >>>> > I cnahged $> into $ret, because $> just won't work. Some better >>>> solution is welcome. >>>> >>>> Also think $> would be awful. Don't like $ret either. What about a >>>> magic constant __RETURN__ or __RESULT__? This would stand out very well >>>> when glancing at the expression, would fit in with naming of other magic >>>> constants, and might even be made to work in finally blocks, where the same >>>> need for access to the returned value exists. >>>> >>>> best regards >>>> Patrick >>>> >>> >>> >> > --047d7b677884444e0d050eb95832--