Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99789 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38065 invoked from network); 6 Jul 2017 07:43:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jul 2017 07:43:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.162 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.162 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.162] ([81.169.146.162:19367] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6C/48-15131-70AED595 for ; Thu, 06 Jul 2017 03:43:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1499326980; l=4014; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Date:From:In-Reply-To:References: MIME-Version; bh=zP5V0fn/gjWeaclb6dQ53Y1iGWM4GsG9fIGf+rF8Up0=; b=H9rcUnb111ET0oj5vG8b7BqD/KraGS1vokgW4X79J1F3/7/nVYWsm6xeBRVWWU90Na wrimOmFMDALJBt/HCD2/aOcgl8bOZPL8wwsG528rIYGGmIpnxAR+ZXDi6fdlV2IjQaED uzLcG8tkc7ABqP245DIskQPgJDRLkE8umQQLY= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLDup6E67mzuoNHBqT43Q== X-RZG-CLASS-ID: mo00 Received: by mail-oi0-f50.google.com with SMTP id x187so9702161oig.3 for ; Thu, 06 Jul 2017 00:43:00 -0700 (PDT) X-Gm-Message-State: AKS2vOyllVARkhAP1yYmdmd0axFQ2tBGRzxrKGx86cLAlbsSxSB7Qc6I ovYVekPXz/FzCfrAvXuNCQrMtZK92w== X-Received: by 10.202.7.70 with SMTP id 67mr26073990oih.184.1499326979464; Thu, 06 Jul 2017 00:42:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 06 Jul 2017 07:42:49 +0000 X-Gmail-Original-Message-ID: Message-ID: To: Stephen Reay , "Khawer ." Cc: PHP Internals Content-Type: multipart/alternative; boundary="94eb2c13e51e036a580553a14469" Subject: Re: [PHP-DEV] Change -> to dot(.) From: me@kelunik.com (Niklas Keller) --94eb2c13e51e036a580553a14469 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Stephen Reay schrieb am Do., 6. Juli 2017, 09:04= : > > > On 6 Jul 2017, at 13:13, Khawer . wrote: > > > > In all major programming languages we access object properties and > methods > > using dot(.). > > > > C#: > > Abc Abc =3D new Abc(); > > Abc.method(); > > > > Java: > > Abc Abc =3D new Abc(); > > Abc.method(); > > > > JavaScript: > > var apple =3D new function() { > > this.name =3D "Test"; > > } > > alert(apple.name()); > > > > > > Why not to make PHP similar to these languages by allowing to access > object > > properties and methods using dot(.). We will still keep "->" until PHP = 8 > to > > maintain backward compatibility. > > In each of those languages, the plus operator is used for string > concatenation. > > In PHP the dot operator is used for string concatenation, and objects can > be cast to strings when concatenating, so how do you differentiate the tw= o > calls at the end of this block: > > class Bar { > public function baz() {=E2=80=A6} > > public function __toString(): string {...} > } > > function baz(): string {=E2=80=A6} > > $foo =3D new Bar(); > $foo.baz(); // call method Baz on object $foo > $foo.baz(); // concat the result of casting $foo to string, with the > result of calling baz() > Obviously by using plus for concatenation. Regards, Niklas > --94eb2c13e51e036a580553a14469--