Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95904 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80315 invoked from network); 10 Sep 2016 20:00:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Sep 2016 20:00:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=marijic.silvio@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=marijic.silvio@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.51 as permitted sender) X-PHP-List-Original-Sender: marijic.silvio@gmail.com X-Host-Fingerprint: 209.85.218.51 mail-oi0-f51.google.com Received: from [209.85.218.51] ([209.85.218.51:34977] helo=mail-oi0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C7/14-46544-25664D75 for ; Sat, 10 Sep 2016 16:00:19 -0400 Received: by mail-oi0-f51.google.com with SMTP id d191so3915556oih.2 for ; Sat, 10 Sep 2016 13:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=eSRLKpab+KWJiD0b92sqgFWfgTEU2jaLbOxuyMZlWE4=; b=ALz4NVHMUkLbboSb/DpORMxvMIMRY2I8xnyKXZRMKyoSLdOtyW4b35p/5xMdr4zfyG fSlcFvQofTHIafiurf3RhHr9HBQYRqNyMntbuqFxnZ3t/CgfHVC+PqS9hCduv5mnr1B5 3clh7tjMc/lJLjO/dcwg5B9pBqVSacZJiqr7ziRCkch3giiJDO8VVFqn7Olw/DM2yenf BEUC7QHpW4IOqq9cc2ZqOwc2CNbXMs6t75MgeWCANZ3ILCoKK+gh3JYcppy2wu+HLtzG GJbFLMBh5wiEUsiIf4lH5BFjWA9+QENU3wb10KpBj76zT+mqMb89InUV2NnwDWGhR8m2 dN0w== 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:from:date :message-id:subject:to:cc; bh=eSRLKpab+KWJiD0b92sqgFWfgTEU2jaLbOxuyMZlWE4=; b=AZY/h1iFGMdHtpGb9FTDI17wj3/fKYNaqjpqw0lA+7EoZkPH/z7pg8EU0SDxfPBqaL KCPtZsOB3dp3zKvlKTOSWXae/u/TOoxapYwaY+/C1KBhpzaVAuTjYKSZkhzoMvlw/kV0 jHFQ2SjzeA5SZdxhJteQ5xfsyg74ZCiiZKXXFIpjIEechVc5AN3WlPr8aI+5kjEkFj96 8edm8ZegibNdhlmqE2IZGO7K09Tlh9Eyhkd6kOcuswaN0fqSziIYoNEODTJpbHWIKjt/ 4IBVuycZFx7y9XyfMngvyClqXurvNYG44Myti30PtGlCAq+m3N7U/Am9M+vCEyDKTalp MN4Q== X-Gm-Message-State: AE9vXwPku0FNqlWRR37hnMv9SYN1xmppWEpN4ysUs4nnk9//46GG4hU/kH1+yhQ/tctpkVkDywWRuQ0Kg6oVCA== X-Received: by 10.157.33.133 with SMTP id s5mr12138365otb.209.1473537615919; Sat, 10 Sep 2016 13:00:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.207.134 with HTTP; Sat, 10 Sep 2016 13:00:14 -0700 (PDT) Received: by 10.36.207.134 with HTTP; Sat, 10 Sep 2016 13:00:14 -0700 (PDT) In-Reply-To: References: <642a6e78-90ea-cbf0-ec1c-376c24e568c5@fleshgrinder.com> <0800a5ca-3d14-c541-1a1a-2574ec802b8c@fleshgrinder.com> <83fa661e-2d3d-6548-a506-fb969be31c0e@garfieldtech.com> <56acc1d9-f424-a460-59be-3a9a1a74b198@fleshgrinder.com> <95832b08-ee80-18c1-a3da-202eed51903e@fleshgrinder.com> Date: Sat, 10 Sep 2016 22:00:14 +0200 Message-ID: To: Marco Pivetta Cc: Larry Garfield , Niklas Keller , PHP Internals List Content-Type: multipart/alternative; boundary=001a11494724290009053c2cb6d6 Subject: Re: [PHP-DEV] RFC - Immutable classes From: marijic.silvio@gmail.com (=?UTF-8?Q?Silvio_Mariji=C4=87?=) --001a11494724290009053c2cb6d6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I agree. Will add this feature to RFC also Cheers On Sep 10, 2016 8:02 PM, "Marco Pivetta" wrote: > On Sat, Sep 10, 2016 at 7:49 PM, Niklas Keller wrote: > >> 2016-09-10 19:41 GMT+02:00 Silvio Mariji=C4=87 : >> >> > @Fleshgrinder, >> > >> > While I'm not sure at the moment about CoW, I can agree that we should >> add >> > immutable keyword as a interface modifier to make sure all classes >> > implementing must be immutable. >> >> >> As interfaces can't have member variables, that doesn't make sense to me= . >> > > It still makes sense from a consumer perspective, so having the > restriction in the contract is quite good. > > If you accept a `Number`, you expect to be able to serialize/de-serialize > it, and you expect it to be "locked", immutable. > If you let an implementation of `Number` to have mutable state in, then > you break all the code that relies on `Number`. > Note that it is still possible to break this though, so maybe we'd need > some other modifiers about behavior too (pure function modifier?) > > immutable interface Number > { > public function toFloat() : float; > } > immutable class RandomNumber implements Number > { > public function toFloat() : float { return (float) random_int(1, > 100000); /* yo, look at my global mutable hidden state! */ } > } > > Requiring immutable values in consumers will likely improve code > quality/safety and reduce dangerous assumptions, and it will probably als= o > allow for optimizations in the engine later on. > > Marco Pivetta > > http://twitter.com/Ocramius > > http://ocramius.github.com/ > > --001a11494724290009053c2cb6d6--