Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60282 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20172 invoked from network); 24 Apr 2012 15:40:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Apr 2012 15:40:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qa0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:44060] helo=mail-qa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0D/BF-34190-169C69F4 for ; Tue, 24 Apr 2012 11:40:17 -0400 Received: by qafi31 with SMTP id i31so2744404qaf.8 for ; Tue, 24 Apr 2012 08:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=LS99o1AcIG7nB8wRcbM2+zDmt97TUERwxHmRADy4ieM=; b=Dck6xGBLSQADUTmItMjaQrbgdbwPtzhaU5E8iCiooK4YRG2SyU+xwINDfMReHUOOwR o851yLONaJ3hwGC4DAkuHJm1UeGisD6EVsnQ7Ybrn3GSilh8H7j2SwssYEjQwRL9GGbw fWuuOv0gI6wJBWeuYqSTMTeKycfGkB3qjVXec+uJtA0x5X9eiut44FDJE+3gaXq1DmuL jWS9PWKia2dKgmEJvOzvyD4qLyGMD8VoVZ6bQBes1ZkPimmXmpDDq4aVOKe4GmOvqu9K otiGEF43eHXrJqmqBn/hR2/JSJgdAjDv+BqYrO3VPZsGbcjhSv14LpMk0EGJ9p30DdAN 2ZCg== MIME-Version: 1.0 Received: by 10.224.179.77 with SMTP id bp13mr16696561qab.85.1335282014434; Tue, 24 Apr 2012 08:40:14 -0700 (PDT) Received: by 10.229.251.212 with HTTP; Tue, 24 Apr 2012 08:40:14 -0700 (PDT) In-Reply-To: <9570D903A3BECE4092E924C2985CE48555BEC3C2@MBX202.domain.local> References: <9570D903A3BECE4092E924C2985CE48555BEC3C2@MBX202.domain.local> Date: Tue, 24 Apr 2012 11:40:14 -0400 Message-ID: To: Clint M Priest Cc: "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC: Property get/set syntax (added isset/unset and references) From: ircmaxell@gmail.com (Anthony Ferrara) Clint, Additionally, one more comment related to the read-only and write-only. I noticed that you're using E_ERROR for improper access. Obviously you don't want this to be a warning, as the execution shouldn't continue because that would be undefined. However, what about setting it to E_RECOVERABLE_ERROR, so that it can be captured and recovered from...? The engine wouldn't be in an unstable state, so if we install an error_handler that throws an exception, there's no reason to force-terminate the application... I guess I'm just adverse to using E_ERROR except for cases where it's literally not safe to continue (usually because the engine is put in an inconsistent state)... Anthony On Tue, Apr 24, 2012 at 8:31 AM, Clint M Priest wrote= : > I've updated the RFC to include details on adding isset/unset as well as = references, detailed below: > > isset/unset: > > class TimePeriod { > =A0 =A0private $Seconds =3D 3600; > > =A0 =A0public $Hours { > =A0 =A0 =A0 =A0get { return $this->Seconds / 3600; } > =A0 =A0 =A0 =A0set { $this->Seconds =3D $value; } > =A0 =A0 =A0 =A0isset { return !is_null($this->Seconds); } > =A0 =A0 =A0 =A0unset { $this->Seconds =3D NULL; } > =A0 =A0} > } > > References: > > > class SampleClass { > > =A0 =A0private $_dataArray =3D array(1,2,5,3); > > > > =A0 =A0public $dataArray { > > =A0 =A0 =A0 =A0&get { return &$this->_dataArray; } > > =A0 =A0} > > } > > > > $o =3D new SampleClass(); > > sort($o->dataArray); > > /* $o->dataArray =3D=3D array(1,2,3,5); */ > > Comments? > > These would also include automatic implementations which call the respect= ive functions on the backing field. =A0I could see only allowing isset/unse= t automatic implementations if get/set were also specified as automatic imp= lementations. > > Default implementations of isset/unset > > I'm also fielding comments/ideas on a way to always provide automatic imp= lementations of isset/unset for any accessor that didn't define one automat= ically. =A0One idea was for the isset (unspecified implementation) which wo= uld return true if the getter provided any value which evaluated to true, s= uch as this: > > class TimePeriod { > =A0 =A0private $Seconds =3D 3600; > > =A0 =A0public $Hours { > =A0 =A0 =A0 =A0get { return $this->Seconds / 3600; } > =A0 =A0 =A0 =A0set { $this->Seconds =3D $value; } > =A0 =A0} > } > /* Default Implementation Concept */ > > =A0 =A0 =A0 =A0isset { return (int)$this->Hours; } > =A0 =A0 =A0 =A0unset { $this->Hours =3D NULL; } > > Note that the automatic implementation of unset is not strictly the same = as an unset() but without any sort of unset implementation a call to unset(= ) would do nothing. =A0Alternatively we could throw an error to a call on i= sset and/or unset against a property which didn't define an implementation. > > Thoughts? > > -Clint