Change -> to dot(.)

  99784
July 6, 2017 06:13 khaweronline@gmail.com ("Khawer .")
In all major programming languages we access object properties and methods
using dot(.).

C#:
Abc Abc = new Abc();
Abc.method();

Java:
Abc Abc = new Abc();
Abc.method();

JavaScript:
var apple = new function() {
    this.name = "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.
  99785
July 6, 2017 06:29 ilija.tovilo@me.com
The dot is already the string concatenation operator. This would be a horrible migration process. The PHP team is never going to upset the developer experience that much for a purely cosmetic change.

Also, C and C++ use the -> symbol, two major languages.

Regards

On 6 Jul 2017, 08:13 +0200, Khawer . <khaweronline@gmail.com>, wrote:
> In all major programming languages we access object properties and methods > using dot(.). > > C#: > Abc Abc = new Abc(); > Abc.method(); > > Java: > Abc Abc = new Abc(); > Abc.method(); > > JavaScript: > var apple = new function() { > this.name = "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.
  99786
July 6, 2017 06:39 ocramius@gmail.com (Marco Pivetta)
What's the point?

Sorry for the snarky response, but it had to be done 😂

On 6 Jul 2017 8:13 AM, "Khawer ." <khaweronline@gmail.com> wrote:

In all major programming languages we access object properties and methods
using dot(.).

C#:
Abc Abc = new Abc();
Abc.method();

Java:
Abc Abc = new Abc();
Abc.method();

JavaScript:
var apple = new function() {
    this.name = "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.
  99788
July 6, 2017 07:04 php-lists@koalephant.com (Stephen Reay)
> On 6 Jul 2017, at 13:13, Khawer . <khaweronline@gmail.com> wrote: > > In all major programming languages we access object properties and methods > using dot(.). > > C#: > Abc Abc = new Abc(); > Abc.method(); > > Java: > Abc Abc = new Abc(); > Abc.method(); > > JavaScript: > var apple = new function() { > this.name = "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 two calls at the end of this block: class Bar { public function baz() {…} public function __toString(): string {...} } function baz(): string {…} $foo = 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()
  99789
July 6, 2017 07:42 me@kelunik.com (Niklas Keller)
Stephen Reay <php-lists@koalephant.com> schrieb am Do., 6. Juli 2017, 09:04:

> > > On 6 Jul 2017, at 13:13, Khawer . <khaweronline@gmail.com> wrote: > > > > In all major programming languages we access object properties and > methods > > using dot(.). > > > > C#: > > Abc Abc = new Abc(); > > Abc.method(); > > > > Java: > > Abc Abc = new Abc(); > > Abc.method(); > > > > JavaScript: > > var apple = new function() { > > this.name = "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 two > calls at the end of this block: > > class Bar { > public function baz() {…} > > public function __toString(): string {...} > } > > function baz(): string {…} > > $foo = 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
>
  99790
July 6, 2017 07:59 michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=)
06.07.2017 09:43 "Niklas Keller" <me@kelunik.com> napisał(a):
> > Stephen Reay <php-lists@koalephant.com> schrieb am Do., 6. Juli 2017, 09:04:
> > > > > > On 6 Jul 2017, at 13:13, Khawer . <khaweronline@gmail.com> wrote: > > > > > > In all major programming languages we access object properties and > > methods > > > using dot(.). > > > > > > C#: > > > Abc Abc = new Abc(); > > > Abc.method(); > > > > > > Java: > > > Abc Abc = new Abc(); > > > Abc.method(); > > > > > > JavaScript: > > > var apple = new function() { > > > this.name = "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 two
> > calls at the end of this block: > > > > class Bar { > > public function baz() {…} > > > > public function __toString(): string {...} > > } > > > > function baz(): string {…} > > > > $foo = 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.
That would be huge BC break because plus on string which ale numerical is adding numbers so result fir now would be sum. Not concatenated string.
> > Regards, Niklas > > >
  99792
July 6, 2017 08:46 lists@rhsoft.net ("lists@rhsoft.net")
Am 06.07.2017 um 08:13 schrieb Khawer.:
> In all major programming languages we access object properties and methods > using dot(.). > > C#: > Abc Abc = new Abc(); > Abc.method(); > > Java: > Abc Abc = new Abc(); > Abc.method(); > > JavaScript: > var apple = new function() { > this.name = "Test"; > } > alert(apple.name()); > > > Why not to make PHP similar to these languages by allowing to access object > properties and methods using dot(.)
to gain what?
> We will still
who is "we"
> keep "->" until PHP 8 to maintain backward compatibility
and then force to rewrite every single piece of code out there? that's a "have a solution and seeking for the problem"