@LeviMorrison Whats the issue with those? And Hyrums law pretty much says no. But it requires more learning it seems peeking into some of the more recent RFCs.
@hakre These methods basically require the array to be duplicated by the ArrayIterator. It's terrible from a performance perspective to have to clone an array just to iterate over it. Also, most of these methods don't really make sense on an iterator. In PHP, we don't sort iterators... it's not a thing. Sort the array, not the iterator.
^ This is only half-true. The real issue is ArrayIterator and ArrayObject share a lot of internals, and ArrayObject requires the duplication because of these methods. ArrayIterator gets them by proxy.
Nikita gave it a look one time, and didn't commit it so... that's pretty strong signal ^_^
I was quite busy at the time. I wish I had captured everything from him as better justification for writing an RFC to move forward about it.
Not to bikeshed, but if we ever have an official static analyser or spec, you're likely going to wish for ! to be available for a much more common expression. With ? being the nullsafe, ! I would think would be the assert-none-nully (although i'm basing that on TS)
When talking about language-level static analysis, referencing one of the most powerful typing engines that a lot of PHP developers will have first-hand familiarity with is a pretty good starting point :-)
How many repeat property calls would you have to go through before the performance hit was more substantial than the performance improvement from the CoW mechanism?
But PHP doesn't perform static analysis and it's not a pre-processor like TS. TS doesn't actually know if your assert-not-null test is even true, it's just a quick hack to cheat the preprocessor into ignoring a potential violation, which can still be violated at runtime anyway
@MarkR It depends on what you compare it to. This opens up new use-cases, rather than being a faster alternative. Essentially, it's a way to do readonly things without them being readonly
Instead of calling many wither methods, the object will be copied only when necessary and only once, even if you make multiple changes.
If that makes sense. The pr description tries to explain in more detail.
@MarkR Right. But you also may just not know if an object is currently still references somewhere else and this copy it, even if it may be unnecessary.
@QuolonelQuestions I am collecting ideas about improved Date/Time APIs. I am not in favour of your single change therefore. It needs proper thinking out instead of sticky plasters: docs.google.com/document/d/…
What is likely to be the final technical output from this document?
Presumably just extensions to the existing API?
Unless you were planning to completely throw away the existing API, I'm not sure why any (additional) improvement so proposed in this document should preclude the one I've put forward, unless you think they might be in conflict with some other changes?
The only thing I can see that would even come close is the getters/setters you're proposing, but even then, I see that as a welcome additional improvement that neither conflicts with, nor diminishes an improvement to setDate
Nevertheless, I respect your decision to postpone it until things are more ironed out
I was curious about replaying the ops for the property list because I think that's what was mentioned at the time, first pass determines if it's mutating, go back and replay them all in write mode. Although I am curious if replaying could back-fill opcode cache slots to tell them to use write instead next time, as a latch.
@MarkR Replaying is problematic because opcodes normally consume their operands. Replaying them will access released memory. Not releasing the operands means something else has to release them when the operands aren't replayed.
Ah, I see. In that case I'm out of ideas for the moment :P everything else I can think of right now involves $changing->something->like->thiis to a single opcode
I've come to the conclusion that a different syntax is not just a workaround but beneficial, because it indicates that this is more than just a normal method call.
E.g, $vec->sort!() will indicate that the data object itself is mutated, and the method isn't just returning a copy.