Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you bring this to PHP RFC? #20

Open
HallofFamer opened this issue Jan 26, 2015 · 58 comments
Open

Can you bring this to PHP RFC? #20

HallofFamer opened this issue Jan 26, 2015 · 58 comments

Comments

@HallofFamer
Copy link

I took a look at it and I very like what is being implemented. In my own framework I use classes for Int, Float, String and Array, but sometimes it can be a bit tedious(like having to write new String("abc") than just "abc"). This library will fix a lot of issues in my codebase, and make coding 10x more enjoyable. Also if its implemented at the PHP core, there's a chance to suggest a way to make even more elegant syntax work, such as "abc"->toUpper() which does not happen yet. So, will you consider moving this to RFC and possibly have PHP internals implement it in PHP 7?

@terah
Copy link

terah commented Feb 5, 2015

I think there are a lot of PHP devs that would love to see this in the core...

@HallofFamer
Copy link
Author

yeah of course, for developers who want to use strongly typed PHP scalars, this will help tremendously. Please do consider bringing it to PHP RFC.

@nikic
Copy link
Owner

nikic commented Feb 12, 2015

I won't have the time to propose this for inclusion in PHP 7. Adding this to core would require quite a lot of work and feature freeze is not far away.

By the way, I already added support for syntax like "abc"->toUpper() and [1, 2, 3]->reverse() to PHP 7 (it will just throw a runtime error). So once this extension is ported to PHP 7, you'll be able to use that syntax in conjunction with the ext.

@HallofFamer
Copy link
Author

I see, thats a pity, I really hope to see this on PHP 7.0, but guess it wont be there at least till 7.1... Still, you can start an RFC to prepare for the future, even if it will not be going to voting phase anytime soon, right?

And its very good news, I very love the syntax like "mystring"->length() and [2, 5, 4, 6]->sort(). It will be very useful, cant wait for the new Scalar object for PHP 7!

@TRPB
Copy link

TRPB commented Mar 19, 2015

Shame, I'd have also loved to have seen this in PHP7. As I mentioned in one of the other issues, this is a perfect opportunity to fix the inconsistent function naming and parameter orders... $str->replace(), $array->combine() etc.

@alanwillms
Copy link

@nikic what about modifying $self within the handlers? It will be possible in PHP 7?

@nikic
Copy link
Owner

nikic commented Apr 17, 2015

@alanwillms Nope, the current VM implementation doesn't allow this. With enough effort it might be possible, but would probably have negative performance impact for all other method calls (which is pretty much a no-go).

@alanwillms
Copy link

@nikic not modifying $self may be a good thing since it enforces immutability.

Now that PHP 7.0 is frozen and won't have any new features, will you open a RFC targeting 7.1?

@c9s
Copy link

c9s commented Aug 31, 2015

+1, this looks really great and I am looking forward to see this in PHP 7!

@Strate
Copy link

Strate commented Sep 2, 2015

👍 for this in php core

@TheXardas
Copy link

Yep, +1.

@alexkvak
Copy link

alexkvak commented Sep 2, 2015

+1

1 similar comment
@sirsnyder
Copy link

+1

@kandy
Copy link

kandy commented Sep 2, 2015

Also will be good to split to two RFC. One about engine level ability. And one about user space registration.

@dominikzogg
Copy link

+1

@robob4him
Copy link

@nikic "once this extension is ported to PHP 7"

Any progress on this?

@vbsessa
Copy link

vbsessa commented Nov 13, 2015

+1

10 similar comments
@brzuchal
Copy link

👍

@dgafka
Copy link

dgafka commented Nov 18, 2015

+1

@ghost
Copy link

ghost commented Nov 18, 2015

+1

@jkonefal
Copy link

👍

@event15
Copy link

event15 commented Nov 18, 2015

+1

@KennetPL
Copy link

+1

@danizord
Copy link

👍

@lgabeskiria
Copy link

+1

@ctrl-f5
Copy link

ctrl-f5 commented Feb 17, 2016

+1

@marcelgsantos
Copy link

👍

@brzuchal
Copy link

brzuchal commented Mar 4, 2016

@nikic are there any chances to bring this to RFC into the core of PHP? This feature is awesome and there are plenty of people looking forward for this.

@devypt
Copy link

devypt commented Apr 17, 2016

+1

@nilportugues
Copy link

+1

@ciscoo
Copy link

ciscoo commented Apr 17, 2016

Just a reminder everyone that you can add a reaction to comments rather than cluttering the comments with +1.

@whatsupdan
Copy link

+1

3 similar comments
@SerafimArts
Copy link

+1

@eduardor2k
Copy link

+1

@exts
Copy link

exts commented Apr 18, 2016

+1

@ctrl-f5
Copy link

ctrl-f5 commented Apr 18, 2016

please stop replying "+1", to vote just add reaction to the original comment.
You are spamming all participants' mailboxes.

@jens1o
Copy link

jens1o commented Apr 14, 2017

Will this be possible in PHP 7.2?

@ctrl-f5
Copy link

ctrl-f5 commented Apr 14, 2017

no, there hasn't even been an RFC for this, so it can not possibly be scheduled to be in a future release.

@jclyons52
Copy link

What can we do to bring this closer to an RFC?

@Rastusik
Copy link

+1

1 similar comment
@mustafatoker
Copy link

+1

@mpyw
Copy link

mpyw commented Feb 8, 2018

Hope for PHP 8.x or 9.x

@qwerty199369
Copy link

This feature is awesome! 👍 Please do consider bringing it to PHP RFC. @laruence @nikic 👍

@alanwillms
Copy link

PHP core developers are discussing about tagging the next release after 7.3 as 8.0. Maybe now is the time.

@q2dg
Copy link

q2dg commented Jun 23, 2019

An entire year has passed already...do you know any news on this? Thanks!

@mpyw
Copy link

mpyw commented Jun 23, 2019

So interesting but handlers should be applied in a specific scope.

@HRADigital
Copy link

An entire year has passed already...do you know any news on this? Thanks!

It doesn't seam to be planned for v8!

@mpyw
Copy link

mpyw commented Jun 24, 2019

C# Extension Method

Definitively I think C#'s Extension Method is our goal.

@Atulin
Copy link

Atulin commented Jul 17, 2019

So it hasn't gone to an RFC for... four years now? What's stopping it?

@HallofFamer
Copy link
Author

@mpyw yup this one has the potential to allow any types to be extended instead of just primitive types, though unlike C# which is compiled, in PHP you will have to manually include the files that contain extension methods.

Anyway, I think, its about time to bring this to PHP RFC. It will be a neat feature for PHP 8, a good chance to introduce OO API for scalar types, as well as fixing the messy function names that cannot be touched due to backward compatibility issue.

@vbsessa
Copy link

vbsessa commented Jul 19, 2019

"fixing the messy function names that cannot be touched due to backward compatibility issue".

Great point.

@avierr
Copy link

avierr commented Aug 7, 2019

+1000

@mvorisek
Copy link

@alanwillms Nope, the current VM implementation doesn't allow this. With enough effort it might be possible, but would probably have negative performance impact for all other method calls (which is pretty much a no-go).

What is the limitation, why the scalar value can not be passed as a variable by reference?

@nikic
Copy link
Owner

nikic commented Dec 29, 2019

@mvorisek Consider something like $a[$b][$c]->push($d). We need to know that $a[$b][$c] is an array in order to determine that the call should be performed by-reference. However, we already need to convert $a, $a[$b] and $a[$b][$c] into references before we know about that. The only way to make this work is to always fetch by reference, which would both result in a semantic change for existing object accesses, and in a large performance regression.

Supporting something like $a->push($b) is simple, but supporting the general case is, I believe, semantically impossible.

@mvorisek
Copy link

@nikic $a[$b][$c]->push($d) is good example.

As $a[$b][$c] can be an instance (and the push can be a regular method then), PHP must still wait until the expression is executed and then it can pass the resulting element ($a[$b][$c]) by reference.

On the other side something like 1 ? $a[$b][$c] : 0` (result from expression) should never be allowed to be modified by reference.

So this should be possible with methods that modified the original scalar object:

$a = [['x']];
$a->push('y');
$a[0]->push('y');
($a)->push('y'); // reset(($a)) works, so this should work too
(['x'])->push('y'); // it should work too, as the value is newly initialized and it is not a result from expression (i.e. not `1 ? ['x'] : 0`)

What do you think?

@mvorisek
Copy link

@nikic Also what do you think about a registration only for some namespace prefix(es)? This would widen the possibility of using the scalar objects in larger projects/packages a lot.

@brunoggdev
Copy link

Hi! Just found this repo and it looks amazing. Any chance it gets on a RFC now? Maybe for PHP 9?

@adrolter
Copy link

@brunoggdev See @nikic's last comment from 2019. I doubt much has changed in that regard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests