« first day (3481 days earlier)      last day (1453 days later) » 

12:06 AM
:')
 
12:34 AM
@Danack

-Ensure correct magic methods' signatures when typed
+Ensure correct typing for magic methods

What do you think? Can I change the RFC's title if that helps understanding it?
Happy that during the development of this RFC I could fix/improve "some" other stuff:

- https://github.com/php/php-src/pull/5441/files
- https://github.com/php/php-src/pull/5398/files
- https://github.com/php/php-src/pull/5397/files
- https://github.com/php/php-src/pull/5462/files
 
 
6 hours later…
6:26 AM
@LeviMorrison i finalized my PR introducing reliable error cb outisde of zend_error_cb/php_error_cb: github.com/php/php-src/pull/4555 can you take a look? Wondering if this should be part of the instrumentation API as well
 
 
1 hour later…
7:32 AM
Hi is there any specific group for Symfony ?
 
7:44 AM
@MuhammadHamzaYounas symfony has a slack
 
Wes
8:19 AM
when you try to remember stuff from school and you suddenly feel like you are 80 and going senile...... except you are 30
that's so bad... mornings folks
i can't even start to look it up on google
 
8:45 AM
@NikiC Do you think we could generate opcache func infos from stubs? At least those ones for which have sufficient information (e.g. MAY_BE_ARRAYs would be out of the game). Or would it result in too many function info entries?
 
Wes
9:14 AM
@Girgias haven't read the rfc yet, but would also be nice to get rid of the "precision" ini setting
 
Hum, why? I'm not against it but what's the rationale?
 
Wes
it's a global setting, number_format & co should be used instead
basically forces you to ini_set("precision" every time you want to cast float to string just to make sure it is what you expect it is
that has repercussions in many things afaik, like the json ext uses that
 
Huh, I mean that should probably be done via the normal deprecation phase
I don't mind bringing it up, if you can compile a list of things which are affected by it that would be great :D
 
Wes
i am not the right person to do that since i don't quite get float numbers :B but i remember bwoebi and andrea discussing it
 
The easiest way to think about float numbers IMHO is just to think about exponential notation, but in base 2
 
Wes
9:25 AM
that's also hard. i can barely count my fingers you know :B
 
:(
 
Wes
anyway, precision is de facto a fixed value, except when it isn't
people can mess with it and they will
 
I suppose one can bundle that into INI setting which affects Engine behaviour
 
Wes
in fact i had it set to 20 on some host, on the basis that 20 is higher (and thus better) than 14, i suppose
 
Wes
eheh
 
10:06 AM
@MátéKocsis Don't we already only leave those func infos that are more precise than stubs?
Either due to arrays or RC info?
 
that RFC he mentions does have a decimal128 type too, that some database (MongoDB, for example), also support
 
10:30 AM
@NikiC Unfortunately, I don't really understand exactly when a function is FN or F1, but I hoped that we could determine the reference count info based on the return type stored in stubs. :/
but we would have already got rid of this map in this case, I guess
 
@MátéKocsis F0, F1, FN means whether refcount of the return value is 0, <= 1 or any.
This depends on the function implementation
At least F0 can always be dropped if the type is representable in stubs
It looks like the remaining F0 uses are for things like always true or null|false, which are currently forbidden
 
yep, I reviewed unnecessary F0s some months ago, and all are gone :)
I also saw in the comments of MAY_BE_RC1 and MAY_BE_RCN that they store info about refcount number, but didn't know why a return value has a specific refcount :)
 
@MátéKocsis Basically RC1 = returns something new, RCN = can return something existing
 
@NikiC It's much more clear now! Thanks!
 
I'm going to note that on my PHP internals .txt file
 
11:17 AM
Morning
 
Morningggg
 
11:46 AM
Does any of you know a go support channel? I'm baffled by this problem:
0
Q: Why would "!= nil" match an object that is "nil" in Go?

DerickI am baffled by the following behaviour: type CloudInitAccountInfo interface { AsDbgpXmlType() *AccountInfo } func NewCloudInit(accountInfo CloudInitAccountInfo) *CloudInit { var initAccountInfo *AccountInfo = nil fmt.Printf("In NewCloudInit: %#v\n", accountInfo) if accountInfo...

 
@Derick yeah, but she prefers being called Kat...
 
Hah
 
@Derick Get ready to learn one of the many stupid shits that exist in Go
 
Somebody snarkily posted a link to golang.org/doc/faq#nil_error and downvoted the question. sigh
 
@Derick You won't find the Go community anywhere near as supportive as the PHP one
 
11:55 AM
apparently
 
Conferences are entirely different
 
if my first interaction with a community is "abrasive", I'll unlikely spend money at going to a conference ;-)
 
Wes
maybe it's not nice, but.. fills me with joy knowing that even new languages are weird and full of problems
it's like they are all like php, except php is not pretentious
 
oh, I don't mind it being weird (although this one...)
@Jimbo Thanks for that link in the comment though, that was useful
 
12:27 PM
i didn't know this about go, god is this confusing
 
Wait until you read that they try and tell you to allow your code to call nil pointers and
no I'm not going to go any further
Actually my issue with the language revolves more around dogmatism and "what you should and shouldn't do" being evangelised by glorified sysadmins who moved over from Python
 
@Jimbo you mean the insistence on one letter variable names for everthing except "err"? :p
 
Unfortunately, because I wasn't returning an interface, but instead accepting it as an argument, my patch annoyingly had to be
diff --git lib/xml/xml-cloudinit.go lib/xml/xml-cloudinit.go
index 8ca377d..9da2be9 100644
--- lib/xml/xml-cloudinit.go
+++ lib/xml/xml-cloudinit.go
@@ -35,7 +35,7 @@ type CloudInit struct {
        AccountInfo *AccountInfo    `xml:"accountInfo,omitempty"`
 }

-func NewCloudInit(success bool, userID string, initError *CloudInitError, accountInfo CloudInitAccountInfo) *CloudInit {
+func NewCloudInit(success bool, userID string, initError *CloudInitError, accountInfoValid bool, accountInfo CloudInitAccountInfo) *CloudInit {
Unless you can see another way...
 
When I had to use Go for almost half a year, it drove me nuts... with its error handling, with member visibility based on lowercase/uppercase name, and its package management
 
Does anyone mind helping me out on a syntax error on postgresql?
 
12:40 PM
PHP feels a much more sane language :'D (starting from 8.0 :D)
 
@PrashinJeevaganth don't ask to ask......also other people might not be replying to you.
 
@PrashinJeevaganth Sorry, it wasn't an answer to your question, I just continued what I wrote before
 
@MátéKocsis "PHP feels a much more sane language - starting from 8.0" is a quote to repeat for every year, just with the next to be released version
 
https://paste.ofcode.org/WStUE69APnN4syKKXqBev4

Does anyone know why does the compiler says there's a syntax error on the attribute numTotal that it "must appear in the GROUP BY clause or be used in an aggregate function"?
Haha, idk if this group is as unfriendly as the other Java group I've been to
They're really unfriendly towards outside questions
 
I get Argo Tunnel error....but it's almost certainly because of the syntax error in your code. Why can't you do what the error message is telling you to do?
 
12:44 PM
I didn't know how to fix it, to my knowledge if you want to use a variable that is made in a Common Table Expression as a result of an aggregate function it's written like that
 
> the attribute numTotal that it "must appear in the GROUP BY clause or be used in an aggregate function"
how about putting it in the group by clause?
 
That was intended to be calculated using the group by in CTE2's code
I guess it's something to do with not being to order by the elements in each group, after the group by
 
@bwoebi Haha :D By the way, do you have a personal PHPSadness top list? :) I'd be curious what people hate the most
 
I was trying to order the internals of each group, was hoping it was possible
 
3 mins ago, by Danack
how about putting it in the group by clause?
you're ignoring the error message, and you're ignoring me telling you to do what the error message is telling you to do.
maybe you should go for a walk and then try again later.
 
12:54 PM
@Danack Sorry about that, I guess the language doesn't have the functionality I think it has
I will just rewrite it
 
@PrashinJeevaganth fyi, you're being a moron.
The streetlight effect, or the drunkard's search principle, is a type of observational bias that occurs when people only search for something where it is easiest to look. Both names refer to a well-known joke: A policeman sees a drunk man searching for something under a streetlight and asks what the drunk has lost. He says he lost his keys and they both look under the streetlight together. After a few minutes the policeman asks if he is sure he lost them here, and the drunk replies, no, and that he lost them in the park. The policeman asks why he is searching here, and the drunk replies, "this...
The error message is actually quite clear, but you've convinced yourself that it's not possible, so you're re-writing your code, instead of reading the error message.
 
@MátéKocsis that I often have to look up function signatures of trivial functions like in_array
and it's really mostly strpos and in_array
which could be trivially covered by $foo in $arrayOrString, but that RFC had been shot down a few years ago
 
@Danack If I had to group by all 3 attributes that I'm outputted in the previous expression, isn't it as good as not writing it?
 
it's an operation I need quite often, but yeah
 
@PrashinJeevaganth why are you trying to argue with me, when your database is the thing giving you an error?
 
1:00 PM
@MátéKocsis And TBF… I know it's a real unpopular opinion, but I wished to be able to inspect and also alter variables from calling stack frames
(I would like to have some wrapper for extract which does something and then extracts, but PHP doesn't allow me to)
 
@GabrielCaruso i) I hate docuwiki ii) suggestions of small changes - gist.github.com/Danack/aee8c9b6bd87a086b704a5aa6da29530 iii) I'd advise against including error messages as part of an RFC as it might bog down changing them into a non-productive conversation.
 
and inspecting mostly for debugging purposes (e.g. when an error occurred)
 
@bwoebi Yes, true! My observation is that the engine is in a good shape by now, and the standard library is what is usually crazy.
 
I have really too many places calling get_defined_vars() and also extract()
 
ugh
what are you doing bob
 
1:07 PM
the extract() part is not so important, but I really wished to save some get_defined_vars() calls when dumping info alongside exceptions
@NikiC collecting as much debugging information as possible when exceptions happen. Exception messages are nice, but seeing the actual state of variables is typically much more helpful
I mean, the exception message tells me "don't do that" … but why was that value passed to the exception throwing function at all?
seeing the state usually allows me to verfiy assumptions quickly and tracing a lot of the control flow back
Obviously, when I can reproduce an error, then it's all fine, I can just dump things… but to analyze errors appearing in the log files, nah
@NikiC I think this is not entirely unreasonable…
Already thought a couple times about just writing a custom ext to be able to do that… :-/
 
@bwoebi Replying to you from yesterday... I'll take any help I can get. :-) I'm trying to figure out how to get the pipe operator precedence to make sense; IMO, it makes sense that pipe binds lower than coalesce, but for some reason I can't get that to work without oddball compile errors. Depending on where I put the pipe in the list, it ends up either failing my unit test or compile failing in different ways. :-)
 
@Crell It really should not fail anything unrelated (assuming you did that make clean)
 
@Crell should be between = and ?:, right?
 
@bwoebi I... think so?
I was told the other day that the list in zend_language_parser.y is in increasing order of precedence.
 
yeah, the ones at bottom bind first
 
1:22 PM
With a make clean, I just rebuilt it with T_PIPE between ? : and coalesce; that compiled successfully but my test still failed. Haven't looked at why yet; it's still before 9 am here. :-)
 
1:34 PM
@PrashinJeevaganth the way to think about Group By is that it happens "before" Select and Order By (queries aren't actually procedural, but it's conceptually that way)
so once you've grouped things up, the original values aren't there to Order By any more
the other thing people often overlook is the second half of Postgres's message: "must appear in the GROUP BY clause or be used in an aggregate function"
so you can do this for instance: ```
select CTE2.pizza, Min(CTE2.area)
from CTE2
Group by CTE2.pizza
Order by Sum(CTE2.numTotal) desc
```
most of the time, you'd probably put whatever's in the Order by in the Select as well, if only for debugging
@Danack there's really no need to call someone a moron just because they haven't got the experience you have
or, in fact, ever
reading that transcript, it's pretty clear you were the one who needed to go for a walk and clear your head
 
@Crell which test fails?
 
Right now, mine. Testing that pipe is lower than coalesce.
 
@Crell can you paste?
 
Stand by.
 
# ./sapi/cli/php -r 'var_dump(123 |> null ?? "strlen" |> fn($x) => $x ** 2);'
int(9)
 
1:45 PM
Um. Hm. Well OK then. Looks like the issue was just the make clean problem? I found a different bug in my test itself now that it's building properly, and no wit seems to work as intended.
 
is just as I would expect it
@Crell by the way, I would put precedence also below ?:, not only below ??
 
Makes sense to me. Now I have to recompile from scratch again. :-)
 
@MátéKocsis Rasmus voted for the locale independent float behaviour :O
 
@Girgias @MátéKocsis Good work on that RFC. Glad to see it go in without much drama
 
:)
 
1:55 PM
@Crell Don't forget to install ccache ;)
 
I didn't expect it to go that smoothly
 
cmb
the PHP group still might veto ;)
 
lol
 
cmb
What to do with github.com/php/php-src/pull/5423? #ifdef PHP_WIN32 only?
 
@cmb We shall kick them out then >:)
 
2:08 PM
@NikiC What's ccache?
 
@bwoebi I think I got it! New code just pushed. Let me know if there's anything still improper in it.
Hm. Does that require any change to how I compile PHP, or can I just apt-get it and be done with it?
 
@NikiC About github.com/php/php-src/pull/5462#issuecomment-619810009: should we still move with github.com/php/php-src/pull/4177 the way it is implemented, or should we design a new approach, following the dummy suggestion?
@Crell Probably, but idk, I use macOS :p
 
2:26 PM
hm, wouldn't it be better if dtrace was a proper third party extension and not nested into Zend? I removed one part of #ifdef HAVE_DTRACE as an example for error notifications here github.com/php/php-src/pull/4555 - but there are only two others left that would also lend themselves nicely to new callbacks as part of instrumentation API, exception thrown and caught
 
2:38 PM
@NikiC The constructor promotion RFC hasn't been forgotten, has it? This is a feature I miss almost every time I make a value object. I guess the trailing comma item can be removed from future scope once that RFC is accepted.
 
@NikiC substr_count currently throws a ValueError for an OOB offset, should I change that?
And substr_compare throws a warning + FALSE return
 
@beberlei zend_instrument_error_register or zend_instrument_error_install would both be in line with the nomenclature of my new PR.
I'd say yes, definitely can be part of the API.
I think "observer" is a better name for these -- neither the fcall nor the error hooks are designed around mutation.
 
@Girgias Haha, I was bragging with this to my GF yesterday :D :D
@NikiC Yeah, it goes surprisingly well :)
 
2:53 PM
@Crell You can apt-get it, but you do need to re-login to your terminal and do some path fiddling so that /usr/lib/ccache
 
And huge kudos to @cmb regarding the float to string RFC for all the suggestions :)
 
@Crell After apt install, read /usr/share/doc/ccache/README.Debian — I picked the export PATH="/usr/lib/ccache:$PATH" variant, as it requires no other modifications. I put that in my .bash_rc
You check how well it works with "ccache -s"
 
Oh geez. Sounds like something to hold off on until after I upgrade my Ubuntu. :-)
 
@Danack Thanks sir!
 
Is that in the php internals book?
 
2:58 PM
it has nothing to do with php internals specifically
works for pretty much everything you compile
 
I don't compile any other C. :-)
 
hi i have a wordpress error "There has been a critical error on your website." but no error log anywhere .any idea?
 
3:30 PM
@Crell You didn't compile PHP before last week either ;-)
 
Granted...
 
Huh, found a typo/bug in FFI
>>> /home/travis/build/Girgias/php-src/ext/ffi/ffi.c:5106:5: warning: "SIZEOF_OFF_T" is not defined [-Wundef]
#if SIZEOF_OFF_T == 4
 
@Girgias Maybe it needs a #ifdef SIZEOF_OFF_T?
 
Well it's probably a define with value check
 
3:47 PM
In a controller (using Symfony) is there anything bad about setting class properties for variables I use throughout the main and private methods? Currently I set local vars in main method but am passing them around a ton. A lot of the vars are bools to determine course of action later on
 
@MadhawaPriyashantha error log is set in an ini file, if you've access to your PHP installation, it'll be found here: php.net/manual/en/errorfunc.configuration.php#ini.error-log
 
@James Your controllers shouldn't be doing much logic to begin with.
 
@James That general idea sounds wrong. If you are able to share anything, I might be able to suggest a better way of doing that code. Without seeing it, I'd suggest just putting all of the vars inside an object, so that they are easier to track.
 
Logic belongs in services. Data belongs in defined value objects. Controllers are a thin layer of glue to connect a request to a service pathway.
 
@Crell except maybe if you're using powerful enough framework where they don't need to be a thin layer, and effectively the services can be called directly as the controller...
but yeah....multiple vars need passing around? probably not so much...
 
3:59 PM
Are you talking about controller-services, or something else?
I've never seen a framework that didn't need some controller/action layer
 
cmb
@Girgias that should be a problem on 32bit
 
@cmb Maybe? I don't know much about FFI, I'm just enabling compiler flags :D
 
@Crell oh they will still be there and probably called 'controllers' but the pattern that symfony has of a code layer that transfers between PSR 7 requests and responses to the service layer doesn't need to be part of the 'controller' code.
 
What are they doing these days then? My limited recent Symfony work still has controllers, even if they're minimalist.
 
oh symfony is still like that....sorry, was just pointing out that "controllers being a thin layer of glue" isn't universally true....
 
4:16 PM
in other news, I've an interview on Wednesday, day before my birthday
WordPress/PHP customer support for a WordPress plugin. Not exactly a programming job, but gives me more experience.
 
4:29 PM
@Tiffany Good luck!
 
cmb
+1
 
So I aim to keep controllers thin. especially the main method. Then passing requirements off to private methods if only relevant to this controller, or service if beefy or would be reused (ie it's about something bigger not just this page/route)
 
There's noting wrong with a service being used only by one or two routes.
But without seeing actual code it's hard to give more then generic advice.
 
For example there are 5 scenarios where obtaining or saving data can go wrong (exception thrown) in these 5 places I have to return a Response (render etc). Service cant do that. In these places I need to pass certain data to Twig.
its this data I'm passing around to methods and render a lot
@Crell I don't abstract to service based on how much it's used solely, it's also the context. such as doing something simple (4/5 lines) that is literally only about this page I'll do in a private method in controller
 
Ah. OK, HTTP layer stuff can stay in the controller, generally.
Can you share a gist?
 
4:44 PM
also the app is API driven, so while I use abstraction to get data via service/Repo/Guzzle classes, at some point the controller has to call this data and handle exceptions and call a factory etc
ie "thin" is the aim but what that means is entirely ambiguous and context dependant :)
in essence the controller "does no grunt work" it asks other things, but there's still a lot of code/vars flying around. So wondered if controller class properties to share around is a bad thing
 
Does anyone here use CWP? If so, how to make this configuration? stackoverflow.com/questions/59996060/disk-xfs-quota-setup
 
@TheodoreBrown Not forgotten, needs some updates for attributes
 
Generally, any change of service or controller class properties post-constructor is a bad idea.
Depending on the details, a value object may be better, or just suck it up and pass multiple values, or maybe there's some way to refactor it so that the relevant bits are all in one utility method anyway.
 
hmm a DTO could work I guess, its mostly stuff being passed to view. I could pass the one object in with getters. ok thanks for the prompt :)
 
ViewModel is a legit pattern, and one that should be used more often, frankly.
At that point, you could also just have the controller return a ViewModel object, and use view listeners to render those to appropriate output.
Fabien doesn't like doing that, but I'm a fan of that kind of separation. (There is a small perf hit for it, but I find it generally worth it.)
 
4:54 PM
I use Symfony, small perf hit is already out the window :D
I mean it's great but a ton going on, listeners in security and what not
 
heh.
Still better optimized than Laravel.
 
shot fired
 
:-)
If I understand you correctly, though, a ViewModel/listener approach may give you the cleanest result.
Your controller returns new CouldntSaveBecauseDiskOutOfSpace($foo, $bar, $baz);, and then a view listener detects that return value and does "stuff" to turn that into a 500 Response.
And then it doesn't matter which controller that object came from, they all get to the same listener.
 
sounds pretty slick. just reading more about the VM approach as so far I've been hardcore with basic approaches.
 
As a general rule, "if you have to spend braincells to keep track of your parameters, you should be using a value object" is a good heuristic.
And a view model is a kind of value object.
And the view listener makes it really really easy.
It becomes more of an ADR approach, which is good.
 
5:01 PM
well this is some reading for tonight :) thanks for the pointers. two searches and already been sent to Maxell's blog :D
 
Lots of good stuff there.
 
yeah he seems to know a bit about stuff
tho I learned a lot from your youtube a few years back so thanks for that too ;)
 
:-) Glad it was helpful. The cookies one?
pmjones.io/adr - This is the ADR stuff. I disagree with the author about many things, but ADR itself is not one of them.
 
actually the one I recall and watched the most was about design patterns, which also was on Anthony's you tube. the guy's taking over :D
 
Yes, the only one I did with him was cookies as an example of design patterns. :-)
 
5:07 PM
so ADR reduces re-usability I presume? only skim read atm
 
I don't think so.
 
ok I need to delve deeper :) thanks again always good to advance
 
It mainly means splitting the controller into two parts: Do stuff and Return stuff. Return stuff is closely coupled with the template layer and content type, but... it always was.
MVC simply doesn't exist in the server-side web, and anyone who claims otherwise is simply wrong and has been for 20 years. :-)
 
yeah it's clearly not perfect but at least it being popular got some widespread structure (tho I bet most cases it's just procedural crap in mvc/classes lol)
 
Frequently.
 
5:39 PM
What's the best/easiest way to get a zend_string from a zend_long?
 
@Girgias you want to convert it to a string?
pretty sure convert_to_string
 
Yeah but that takes a zval
And yes to a string
 
5:57 PM
spprintf
i bet there is a zend_string version of it
 
6:11 PM
@Girgias So stick it in a zval? ZVAL_STRING?
 
Erf I got something working with sprintf
I'll let Nikita look at it during the code review
 
7:04 PM
@Girgias It may surprise you, but ... zend_long_to_str
 
7:34 PM
jellow
 
Does anyone here use CWP? If so, how to make this configuration? stackoverflow.com/questions/59996060/disk-xfs-quota-setup
 
@NikiC >_< I tried looking it up on heap.space but I was only using long*convert ...
 
8:04 PM
Hi :) I have a question to those who are opposed to match blocks. When do you intend to use match? Is it only when the match returns a value or would you also call functions with side effects?
match ($x) {
0 => foo(),
1 => bar(),
};
If it's the former what would you use instead?
 
@IluTov It's about simple expr
(I'm not opposed, but as far as I talked to others)
so function calls are obviously allowed
even (function() { op1(); op2(); }))()
 
@bwoebi Yes but I think most are of the opinion that closures should be used as a last resort.
 
yeah, I'm just saying it should be unrestricted expr.
Not promoting the usage of closures there :-)
 
@bwoebi Got you. :) Let me rephrase, what would you personally want to use it for? So, would you use it to execute functions with side effects without using the return value?
Or would you just revert back to the switch or if statements.
 
@IluTov I would use it as a drop in for switch without risking to forget break; statements etc.
At least in statement form
when match is used in expr form, not sure
 
8:18 PM
This is something I wanted to check, but haven't gotten around to it: Go through a sample of existing switch uses in projects, and check whether they can be converted to / benefit from match
I think the people calling only for match in expression form are way way off base about actual need
It would make a lot more sense to only do match in statement form, because the expression form is then handled through some slightly ugly, but nonetheless trivial, tail duplication
 
Ah you made it ilutov. Cool
 
@MarkR Yes :) Thanks for letting me know about this chat room!
 
@NikiC what do you mean with handled through some slightly ugly, but nonetheless trivial, tail duplication? Example?
 
np, I thought you'd get more insight here than you would from the mailing lists.
 
@NikiC My guess would be 60-70% statements, 30-40% expressions
 
8:22 PM
@bwoebi I mean that return match () { x => y, a => b }; can be transformed to match () { x => { return y; }, a => { return b; } }. If you have statement form, you can easily convert the expression form into it. If you only have expression form, then you're screwed
 
ah
yeah true
 
@NikiC Absolutely, the RFC exclusively uses dummy examples which is a pretty bad decision in hindsight.
 
Oh hello there
 
@Girgias hi 👋🙂
@bwoebi That's exactly my concern. The whole premise of the RFC is to offer an alternative to the switch that resolves the issues presented. If you can't use it in 60-70% of cases, that's a pretty bad argument.
Of course, some people would disagree that the switch is broken and that's fine. But nonetheless the whole case against the switch doesn't make sense this way.
 
8:28 PM
o/
 
@GabrielCaruso I for one would be much more happy if magic methods would be validated like regular methods, following regular inheritance rules :)
 
@MátéKocsis Probably tricky to actually do :)
 
@NikiC Hmm, then I would also be happy if at least the messages would resemble to the regular ones (with incompatible signature) ^^
(But surely, the error message shouldn't be part of the RFC)
 
8:55 PM
Bah, I really want vec<T> and dict<Key, Value>. @NikiC, do you think implementation wise generics would be easier if we initially only supported them in extensions?
(plus reflection and whatever other implications that has)
 
@LeviMorrison no
 
Oh well.
Maybe in a few weeks I can take a few weeks off work and try to land something.
 
@LeviMorrison There's a starting point at github.com/nikic/php-src/pull/3. But only a starting point.
 
9:11 PM
@NikiC are you planning on continuing that work?
Or are there non-technical reasons why you don't?
 
I'm wondering if there's some restricted form we can get in literally to support vec and dict and nothing else -- initially.
No inheritance.
No opcode support for $a instanceof T, etc.
The need for generics goes drastically down if we had those, frankly...
Even still it would be quite a large surface, so maybe not easier or really restricted.
And maybe too poor of an experience given you couldn't write something like:
function vec_append<T>(vec<T> $vec, T ... $values): vec<T> {
  foreach ($values as $value)
    $vec[] = $value;
  return $vec;
}
 
@LeviMorrison It's where it intersects with other iterables and iterable-related operations that it gets messy.
 
@Crell I don't consider those bits to be the messy ones, personally :)
 
From a design perspective, yes. From an implementation perspective, there are likely far messier bits. :-)
@IluTov Greetings.

I still think match is much better understood as "a more powerful ternary" than "a less powerful switch". When viewed that way, it's pretty sweet.
 
precisely
 
9:27 PM
@Crell Would you say the match is more powerful than the switch? We're so close to making it a full replacement for the switch it feels like sabotaging ourselves to me.
 
I guess I don't see a reason to fully replace switch. That's not a thing I'm looking for in my life.
switch is a way to branch logic flow based on some condition. It branches a statement into a series of statement sequence options. It's a very procedural construct.
 
@Crell I can understand that. So I guess the fundamental disagreement here are the switch issues listed in the RFC.
 
expression-only match is a more functional construct; it branches evaluation, not statements.

And if we ever get enums it's a natural place to also enforce exhaustive options, like Rust does. (Future scope.)
 
@IluTov I've only occasionally needed a switch as expression, but I'd be happy with a replacement that can also be used in an expression + has all the safety nets you proposed :)
 
The no-return-value is, IMO, only an issue in expression-land. As a sequence of statements, those don't have return values anyway. Expressions return values.
Fallthrough is a problem, but... I guess I've been writing C family languages long enough that I have gotten into the habit of adding break. And type coercion is always a tricksy subject in PHP anyway.
Inexhaustiveness, the solution there would be to make it an error to not have a default case, but that's an even bigger BC break. match requiring exhaustiveness and an expression is honestly fine with me, and closer to how I'd want to write my code anyway.
 
9:34 PM
@Crell Don't you think it's unfortunate that you'll be stuck with switch for those cases then? I rarely ever use switch for these reasons, unless the switch is the last thing in the function where I can just use return in each case.
@MátéKocsis Yeah I see it the same way. The main use case to me isn't returning values but just a switch alternative with saner semantics.
 
Not really? My switch bodies, on the rare occasion I use switch at all, are short enough that match() can and should replace them. Switch bodies that are longer than that... should be their own functions anyway and then I can call them individually in a match.
When I see code that has very long switch statements, I usually cringe and refactor.
 
@Crell Haha I think you're just way more disciplined than me :)
 
/shrug
Bah, no /shrug command? SO chat sucks!
 
@Crell I think matching is actually extremely common but we've gotten so used to using if/else chains that we don't really think about it this way. Nikitas suggestion to use real world examples would have been way better for demonstrating that...
 
In any case, I don't disagree with the list of switch problems in the RFC; I just feel that a good expression-based match eliminates so many switch use cases for me with something substantially better that I don't really care that much about the few cases that are left.
Good examples are always hard, yes.
FWIW, I feel the same about big-bodied if-else chains, too. :-) If the body is that big, it should be a function instead.
$val = $foo
? bar()
: baz();

I've written something like that a zillion times.
 
9:49 PM
@Crell I agree that this would be optimal. However, I don't think most people work like that (me included). And sometimes moving two lines into a function can actually make things less readable as you'll have to jump around a lot just to get the full picture.
 
Sometimes, yes.
Though based on the current voting results, it looks like the voter preference is for expression-only match. (I'm not a voter currently. Working at it. :-) )
 
Haha yes, I'm just having a hard time understanding why 😅
> I'm not a voter currently. Working at it. :-)
Same here ^^
 
My guess is the current voters prefer simple and predictable rules over many different variations.
The polls right now show 1) Don't make bits optional; 2) Don't give it multiple modes; 3) But making something obvious simply omitable is OK, because that's self-documenting.
(At least that's my read on it.)
 
@Crell That might just be it. Bummer for me for investing all the time and then not actually using it that much :/
 
@Crell do you usually have if / elseif chains instead?
@IluTov tbf, there are features which are best introduced step by step - first match expression only, then we can possibly add block expressions as a general feature
 
10:01 PM
@bwoebi Honestly... between polymorphism, ternaries, and early returns I rarely have need of more complex branching. Although to be fair I write a lot less production code than I used to, as I'm in DevRel now.
Block expressions as a general feature I'm undecided on, but it's definitely worth discussing on its own merits. And if they happen, they'd apply to match automatically. Another case of the sum being more than its individual parts, which is good design.
Also why I don't have expression placeholders in the pipe operator RFC: They're better off as a generic feature than something pipe-specific.
 
>they'd apply to match automatically
That's actually not entirely true. That's one of the reasons I decided not to move them into a separate RFC. See https://github.com/php/php-src/pull/5403 and https://github.com/php/php-src/pull/5407
The main problem is that for blocks to make sense as expressions they'd always have to return a value. But if you're using match as a statement that shouldn't be necessary. The same goes for arrow functions where no return value means null. I don' think there's a way around these special cases
 
@IluTov To expand on what @bwoebi has just said: But be warned, there are other features that are best to introduce in their completeness ^^ For example, many people didn't like the fact that cloning wouldn't work as before in case of my write-once property stuff.
 
welcome to php internals
 
I guess it's not easy to find exactly the right scope to tackle at once
 
@Girgias Hey, thanks :)
 
10:08 PM
@NikiC are there some Opcache optimizations going on in: github.com/php/php-src/blob/master/ext/standard/tests/strings/… because it's failling on non-debug builds as the notice seems to be emitted earlier in github.com/php/php-src/pull/5476
 
I... can't imagine using an arrow function without a return. :-)
 
@MátéKocsis That's true. Some people have even suggested introducing even more things (like pattern matching) in the same RFC. There are as many opinions as people involved I guess :)
 
@IluTov honnestly it can be frustrating/weird as it tends to bikeshed a bunch :|
 
@Crell That's because our array functions are limited
:-)
 
All 80 of 'em? :-P
 
10:13 PM
You get an array function! You get an array function! Every single one of you gets an array function! ... and I've still not worked out if there's something like array_map that lets you return a key/value tuple.
 
@Girgias I also have a problem with JIT in an error message improvement PR of mine. :D (the first job in Travis is also JITed, if you are like me and haven't realized before)
 
Oh...
Will need to check with Azure Pipelines if it's only the JITed ones
 
@MarkR There isn't, not built in. dict_map is a subtly different behavior than array_map. Or rather, should be.
 
@Girgias Yep. But if you have to fix something, at least you can say that you made fixes to the JIT XD
 
I already did one small one because of a compiler flag thing :')
 
10:33 PM
Welp it's not JIT related, because it happens on any build with OpCache
 
 
1 hour later…
11:55 PM
@Crell We should talk about platform.sh and Xdebug usage :-)
!!rfcs
 
@Crell it depends on what you're doing, sometimes polymorphism is just overkill for what two simple switches can also do
 

« first day (3481 days earlier)      last day (1453 days later) »