« first day (4367 days earlier)      last day (567 days later) » 

JRL
1:42 AM
so, for my math library documentation, i provide the performance of the various algorithms in two metrics: Ops/sec (number of times you could call this calculation per second in testing), and EINOs (Equivalent Inline Native Operations, or how many times you'd have to call the default PHP equivalent calculation to slow down to the same speed)
i figure the EINOs is a pretty useful gauge, and should be fairly test platform independent
 
 
2 hours later…
3:22 AM
so 8.1 crashes randomly...
 
Pfft. 8.1.... millennial trash. EIGHT POINT OH IS THE SUPERIOR BRANCH
 
JRL
3:45 AM
if anyone could give me some feedback on questions you might have in this situation, I'd much appreciate it: jordanrl.github.io/Fermat/getting-started/…
 
 
3 hours later…
6:59 AM
@Derick I've narrowed it down to PHP builds compiled with --enable-debug - non-debug versions don't exhibit that behaviour. It makes it a little easier to work around, but still. I wonder what the source of this is
 
7:29 AM
@alcaeus Still makes no sense... have you strace'd it?
 
7:53 AM
posted on September 30, 2022

 
8:10 AM
@Derick Not yet - I'll admit I'm not very proficient with strace. What I know so far is that adding a blank line somewhere in the file triggers the error, removing that line fixes the issue again. Adding a blank line at the end doesn't trigger it at all (which is what gave me the idea to check if it appears in non-debug versions of PHP)
 
 
1 hour later…
9:24 AM
@alcaeus is this with opcache enabled? stracing is easy, put strace -ftto file in front of what you would normally execute (eg. strace -ftto file make test) and upload the file somewhere so we can look at it
 
 
1 hour later…
10:34 AM
morns
 
11:13 AM
o/
 
If I receive an array structure in an extension method, is there a way to check if it's a list (sequential, numeric indexes starting with 0) or any other PHP array?
 
array_is_list()
FWIW, there should be a method in the MongoDB extension that checks for that already
 
Ah, zend_array_is_list is what I was looking for - just need to get the zend_array structure
@Derick We have that method in the PHP library, I need it in the extension though. We're finally working on a raw BSON class, and I'm trying to make sure BSON instances can store arrays when created from fromPHP
 
right... what changed with regards to needing a raw BSON class? I can't imagine that be customer driven?
 
No, we want to improve BSON deserialisation. To that extent, a raw BSON class (along with a BSONIterator) lets users be more flexible in what they want to receive from the driver
 
11:24 AM
@alcaeus look at what that function calls internally and you'll be able to call it from the extension?
 
@Danack I found it - array_is_list is the PHP user land function, zend_array_is_list is what I can use in the extension. Didn't think it would be this obvious :)
 
 
3 hours later…
2:54 PM
@alcaeus Keep in mind the implementation details: heap.space/xref/PHP-8.2/Zend/zend_hash.h?r=faa83f2f#1571
Note that it returns true if it could be repacked, even if it's not.
 
3:15 PM
@TimWolla @IluTov Regarding this PR, I don't understand why it only supports internal attributes. Is there a reason we can't support userland attributes on promoted properties, too? github.com/php/php-src/pull/9484
 
@ramsey That's already possible, because userland attributes are not validated at "compile time".
Internal attributes are and they don't currently work on promoted properties, because an attribute on a promoted property is attempted to be set for both the property and the parameter.
#[\SensitiveParameter] is valid for parameters only – not for properties. Thus it is erroneously rejected.
What this PR does (to my understanding based on the tests) is: If an attribute is set on a promoted property and valid for parameters only, instead of rejecting the attribute when attempting to also attach it to the property, it will be skipped.
 
cmb
Might make sense to comment that on the PR. :)
 
What part of that? I've basically just repeated my analysis from here: github.com/php/php-src/issues/9420#issuecomment-1226217444 :-)
 
@cmb I know, but I wasn't sure if I was just missing something
@TimWolla So, userland attributes already work on promoted properties?
 
cmb
@TimWolla Sorry, I've missed the "Fix GH-9420".
@ramsey I was referring to Tim's comment. :)
 
3:29 PM
@ramsey Yes, because they are only validated when attempting to call ->newInstance() on them. See: 3v4l.org/TALWR
The attribute is only valid for methods, but it will be attached to both the parameter and the property.
However when calling ->newInstance(), it will throw. This behavior is different for internal attributes, which will not be "attached" in the first place.
 
The issue I've run into in 8.1 is attempting to use a userland Attribute::TARGET_PROPERTY attribute on a promoted property. It didn't work because it didn't also have Attribute::TARGET_PARAMETER.
So, in those cases, if I want to use that attribute, I can't use promoted properties
 
Yes, you can. You just may not call ->newInstance() for the one you receive from the ReflectionProperty / ReflectionParameter. This is consistent with userland attributes in other combinations.
 
Hmm... I'll have to remember what it was I was trying to do and create an example
 
You can put a method attribute on a class. It will be listed in the return value of ->getAttributes(), but if you call ->newInstance(), it goes boom: 3v4l.org/8lcoG
However a native method attribute (ReturnTypeWillChange) may not even be set on a class: 3v4l.org/5gjNF
 
3:45 PM
@cmb Do you know who has access to the rsync server?
Peter Cowburn does... but I don't remember his handle here
 
@TimWolla Well, this is interesting: 3v4l.org/SlhAP#v8.1.11
Maybe it was Psalm or PHPStan that was complaining
Also, I wouldn't expect the reflected parameter to return that attribute, since the attribute is designated for properties only
But maybe I'm thinking about it the wrong way?
Ah, ha! I see how it works now. 3v4l.org/ElbFN#v8.1.11
That makes sense
 
cmb
@Derick No, I don't, so let's ask @salathe. :)
 
I tried that, didn't auto-complete
 
@ramsey Yes, userland attributes are only validated at ->newInstance() time. Native attributes are validated immediately.
Attributes also don't need to be backed by a class. You can write anything between #[] and it will work until you attempt to get an object.
 
@derick try ssh-ing to sc2, please. :)
 
cmb
4:00 PM
@Derick autocomplete only works for "recent" visitors (whatever that exactly means)
 
@salathe ssh works, sudo not
 
@ramsey Reviews can only be requested from organization members. They are also the only ones who can use "approve" or "request changes", non-members can only comment.
 
@Derick Always forget that... try again. :)
 
already root, thanks
 
\o/
 
cmb
4:06 PM
@LeviMorrison Did you see github.com/php/php-src/pull/9648? We're wondering about the motivation for no longer copying the module entry in the first place. /cc @ArnaudLeBlanc
 
4:17 PM
@salathe Can you follow up on systems@ that you've done this? So thar mj and rasmus don't waste time?
 
:)
 
@salathe long time no see
 
 
1 hour later…
5:39 PM
@Danack You wrote a doc on type aliasing?
 
JRL
 
OK good, but why isn't stuff like this on the wiki???
Why spread it out? Clearly not efficient from an organizational pov?
 
JRL
well, what's in there is highly opinionated. it doesn't (and probably shouldn't) represent the whole project or all the people who contribute
 
@JRL With the risk of losing important thoughts forever if the person quits or deletes it?
 
@OlleHärstedt nothing actually useful on type aliasing. There are words github.com/Danack/RfcCodex/blob/master/typedef_callables.md but not many, and not any that would actually save much time.
 
5:45 PM
@Danack Got it, thank you :)
 
JRL
huh yeah, for some reason i thought i remembered reading one on type aliasing
 
@OlleHärstedt I am annoyed with myself for not having pushed the PHP foundation to be more open about goals....but that is mostly because I am about 80% disabled from chronic pain currently (try not to be in car crashes kids).
But also...........there is a problem with PHP core that it doesn't have a Code of Conduct, and also that most code of conducts are bloody useless at actually stopping people from being annoying twats. And can even be misused to punish people for pointing out bad behaviour.
@JRL oh...hmmm.
 
JRL
there is also the problem of leaderless leaders. having a leaderless organization doesn't actual remove leaders or leadership. it just makes it informal, difficult to understand, and less accountable.
 
Didnt' realize they had any goal formulation. Good if they did. Better if it's public, yeah. :)
Sorry to hear about your pain. Happy drugging.
 
> Better if it's public
 
5:51 PM
@JRL Yeah, I don't know much about php internals, I admit.
 
That is also a point of contention. I think it would be worth publishing goals, if it would lead to more money being sent to the foundation e.g. window build boxes, and if the foundation had enough money (and will/agreement) to hire people to look after those boxes. But a lot of PHP end-users opinions about what the foundation should be working are a 'bit' dumb.
 
OK, I have zero opinion about that personally.
Mostly happy there is one. :) Finally.
 
More random words on callable types - github.com/Danack/FunctionTypes/blob/master/…
 
The inline version would probably be a good first step, no? wiki.php.net/rfc/callable-types
I don't know if voters prefer to split RFC into mergeable chunks, or all-at-once feature sets...
 
JRL
you know, and please someone tell me why this is stupid... it feels like a lot of the ideas that people are pressing up on now are running into the problem of PHP being totally shared nothing... that there is no "global execution context" that is easily userland programmable
 
5:56 PM
@OlleHärstedt I kind of hate the inline version.
 
JRL
there is the ini file, but that is configuration, not userland program
 
What's "totally shared nothing"? Global space?
@Danack Shouldn't such reasoning be part of the RFC then?
 
In particular, trying to define a function that takes a particular type ofcallable, and one of the parameters for that is also a particular type of callable, is too god ugly to used.
 
JRL
i.e., there is no universal bootstrapping process for PHP apps. everyone in userland has to build their own bootstrapping from scratch as part of their application
 
@OlleHärstedt not sure what you mean by "such reasoning" ?
 
5:57 PM
@Danack Arguments for and against an RFC. Or does each RFC only contain pro-arguments?
@JRL OK, I have no overview over current RFCs in the pipeline, so, I wouldn't know. :)
/me tea
 
JRL
im not aware of anyone even ever proposing some kind of universal userland bootstrapping for PHP
im not even sure how one would accomplish that
it would have to be some kind of file obviously. but how do you handle shared servers that run multiple independent applications?
if the global bootstrapping is in the /etc folder, it could only be used by people that basically have full access to the entire box
 
@OlleHärstedt Each RFC is written by the author, they are free to include whatever they think is relevant. There has been drama before when a certain someone 'audited' an RFC (I'll find a link in a mo). And yes, it would be good if there was a place where people could clearly document why they think an RFC is bad. But trying to figure out how to do that in a non-drama filled way is hard.
 
JRL
or perhaps it could be configured according to the executing user? in any case, it sounds insanely messy
but, if that existed, things like typedefs would be a lot cleaner
not sure how your IDE would understand it though, if it were organized in that fashion, which is a different problem instead
 
@JRL I put together a short list of what things need to be type aliasable in PHP gist.github.com/Danack/9e46dd0e7a31367d6dddbd92ba18eeab probably that?
@OlleHärstedt Behold, drama.
 
@Danack Wasn't there a specific wiki for argumentation.......
 
6:06 PM
There was a semi-serious conversation on internals (that I can't be bothered to find), about making feedback be listed alongside an RFC. That drama made me realised that supporting that would need to start with a platform that had CoC+moderation built in (i.e. not communication over email), because it's just too annoying otherwise.
 
@Danack Ha! Good example! Wiki might need a system for comments. :D
@Danack Well, different paragraphs of an RFC could be linked to its own discussion. Same as with modern collaborative web app writers, no? Google docs etc
 
JRL
@Danack Goddamn. Every so often... zeev speaks for himself again in some historical document and reaffirms all the things I think about him.
 
Jul 18, 2019 at 12:08, by Danack
Systemantics should be required reading.
@OlleHärstedt points and laughs at the programmer trying to fix a system by adding to it.
 
@Danack Boooo, "work" is not defined!
Also, I'd need to see some empirical evidence of such sweeping statements...
 
6:15 PM
gestures at the entire fucking world right now
 
@JRL I'm not even sure what you mean by that.
 
@Danack Well, if you use the metric of average expected life-time and number of humans on earth, society is a massive success. :) Not to get too much off track. Just saying, you need a fitness function.
Maybe that's a simple change, to make each RFC also have a discussion page, like on Wikipedia...?
 
What would the discussion page do, what the discussion thread on the list doesn't do?
 
@TimWolla have more meta-arguments about people sabotaging their carefully written words, and about the layout of the RFC, and whether pros and cons are actually 'valid' or not.
 
@TimWolla Discussion thread might be many, far apart in time. Being able to follow one single argument and its pros and cons is valuable. In emails, arguments are spread out.
And you can try to filter out the "drama" or emotional content in the discussion page, where in the email list, people can throw pies at each other. :)
 
6:23 PM
So it would also have a meta-meta-argument about the filtering.
 
In my email client all the emails related to a single thread are grouped together (except when someone messes up the in-reply-to header).
But generally I've all the emails sitting together in a nice tree.
 
@Danack Well, you can have a "main" discussion page about how discussion pages should look like, in tone and content. ^^
@TimWolla Sure, the emails. Not the arguments.
One email = many arguments
"To which email address do you have to send an email to now?" - what? o0
Oh, internals...
 
@OlleHärstedt and people would argue about whether something would be on one of those pages and not the other. You should read systemantics. Some useful systems can't be easily discovered through experimentation.
 
@Danack That's a hypothesis. Now let's be good scientists and test it. :D
But I assume it would have same issues as on Wikipedia, sure. However it works there.
 
> Note: wiki account does not give you edit privileges. To get authorization you must send a quick introduction to the internals mailing list. Mention your wiki username and say what you're planning to do. This email lets us know you're a human (and not a robot) and what you'll be working on.
 
6:28 PM
Got it, thanks
 
JRL
@TimWolla I'm talking about things like... if you have bootstrapping type code, such as typedefs, or say global operator overloads, those would necessarily need to be at the beginning of the application in the bootstrapping phase.
so i suppose what i was musing about was something like a PHP "header" file, that the engine understands to be part of bootstrapping without application structure
there is often discussion about "how would this be done for all files in the application? as part of autoloading? seems messy" for lots of different ideas/proposals
i was wondering if the lack of this sort of "header file" is sort of bogging down some kinds of proposals
 
@JRL Can't composer configure bootstrapping files?
 
JRL
in some languages (mostly compiled ones) there's a designated application entry point, such as main.x
or in python, there is an assumed application entry point if you don't define one yourself as part of the execution
 
Fun fact: OCaml can have an entry point in every module ^^ (compiled, still)
 
JRL
6:45 PM
python has __init__.py as an example from an interpretted language
 
@JRL So a class can inject type-aliasing that's loaded for the entire project?
Being one use-case
 
JRL
@OlleHärstedt in __init__.py, it's just implicitly executed before any of the code in that directory/package runs
 
I am trying to document stdClass. I created a new file called stdclass.xml in predefined folder but when I compile the manual, the file is not generated
 
JRL
you could use that to do anything that would be global for all the files in that directory
 
6:49 PM
What could be the reason?
I tried en/class.stdclass.php
I checked in the en folder... it's not there
 
@Dharman What are you even talking about, hahaha
 
About adding a new page to the PHP manual
 
JRL
@OlleHärstedt they're talking about the php documentation
for php.net
 
Ooooh, sorry
 
doc-base contains this line
<!ENTITY language.predefined.stdclass SYSTEM 'file:///D:/projects/en/language/predefined/stdclass.xml'>
so I am pretty sure I have put it in the right place
 
JRL
6:53 PM
wish i could help @Dharman but i know nothing about the docs setup
 
@JRL I believe composer can effectively do that with: getcomposer.org/doc/04-schema.md#files.
Sure it's not something that is in core, but PHP also doesn't have a concept of modules.
 
@TimWolla Yes, I mentioned this. But files can't inject themselves into such a system :d
register_shutdown --> register_startup
 
JRL
@TimWolla no, it doesn't have a concept of modules, but it does have a concept of namespaces. having, for instance, a check for the existence of a __bootstrap.php file in each namespace the first time it is loaded that provides its variables/results only to that namespace would be the equivalent i think
that sounds difficult, to be fair
 
PHP also doesn't have a concept of "file system structure" built in, so such a bootstrap file wouldn't work.
 
There's a parsing phase before execution?
 
6:58 PM
Regarding typedefs I would prefer an explicit import anyway. That works well with TypeScript.
 
JRL
@TimWolla im not sure why not? require and include result in a system path of some kind
 
The file system structure does not need to match your namespace structure.
 
@TimWolla Does that work today? With include + use-statement?
 
JRL
ah, okay, i see what you mean then.
what i was thinking was more like, the first time a namespace is loaded, PHP looks in the same directory that file comes from for a bootstrap file. that bootstrap file applies to that namespace and below not that directory and below
 
@OlleHärstedt I don't understand that question.
 
7:02 PM
File a.php contains "use foo as bar;"
File b.php includes a.php
https://3v4l.org/l15S3/vld
use-statements aren't even part of the compiled code?
 
@JRL I believe there is no such thing as a "below" with namespaces either. I'm also not sure how such a bootstrap file would interact with vendor namespaces as they are commonly used. Where would the bootstrap file for the top-level vendor namespace be searched? Clearly only one library could provide it.
 
JRL
@TimWolla i would presume that the only sensible way to do that would be for PHP to use the autoload register to try and load the file in an arbitrary namespace. though to be clear, this isn't something im working on or anything, just something ive seen discussions bump up against before.
 
@OlleHärstedt No, they are not. And I still don't understand what you are asking.
@JRL I didn't assume you were working on something :-) Using the autoloader to "load a file" isn't a thing either. The autoloader loads classes. How the autoloader does so is up to the autoloader.
You could eval() to dynamically create the class within you autoloader.
 
JRL
@TimWolla dear god, sometimes i forget the horrifying nature of what PHP needs to support
 
@JRL I present you this code I have written: github.com/WoltLab/WCF/blob/… :-)
 
7:12 PM
use function foo as global bar; :D
I really need to read the src related to use...
 
@OlleHärstedt Consider use a compile time search and replace.
 
@TimWolla Ah
But for project-global type alias, you need to put aliases in a bucket, right?
 
JRL
thats why most people suggest a new keyword typedef instead of reusing use
 
I get that
Oh yeah, "use" does not even work with eval()
 
@JRL What I expect and what would probably work best with whatever we have in PHP after thinking about 10 seconds about it: typedef Foo = Bar|Baz would create a new symbol Foo within the current namespace.
You can then refer to that typedef as \Explicit\Name\Space\Foo or import as use typedef \Explicit\Name\Space\Foo and then just use Foo whereever you want to refer to it.
So basically … how classes work.
 
JRL
7:20 PM
@TimWolla yeah, except then a particular file in that namespace must be loaded/used first, which is what my thoughts on bootstrapping were about
 
If you reuse the symbol table for classes, then the existing autoloader would work. I believe that's one reason why enums are classes internally.
 
We want built-in types too, tho. typedef arrayish = array|ArrayAccess;
 
@TimWolla It's been a while but I've started with something like that. github.com/php/php-src/compare/…
This is old, it might be trash.
 
Amazing how good you guys are at hacking php-src...
For me it's just a giant nest
 
@IluTov That looks like exactly what I was suggesting above, yes.
 
7:25 PM
@TimWolla Just a reminder that you'll have to fix some autoloading cases because they assume if a type is not loaded then it can't match, but type Foo = array | ArrayAccess or whatever breaks that: $obj instanceof Foo where Foo hasn't been loaded yet and the does implement ArrayAccess.
 
Ugh. Luckily I'm not the one who needs to think about that, because I don't plan on proposing that :-p
 
@LeviMorrison This is a major issue. TBH the main reason I stopped working on this is because I don't think types in PHP atm are complex enough to justify the headache.
 
@LeviMorrison This issue doesn't happen with "use", if I understand correctly.
Although many other limitations apply :) As reasoned on the mailing list.
 
@OlleHärstedt It wouldn't. But the point of typedef would be to avoid repeating the type over and over, so use doesn't really solve that.
 
I guess use could solve it per-file, which would be better than nothing, I suppose.
 
7:31 PM
@IluTov Well, it solves it in one file, but yes, not globally. And it's also not possible to include use-statements.
Right
 
@OlleHärstedt Which might be worse, as the type reads the same but might refer to something else.
 
LSP checks might catch some of those, but not all (covariance/contravariance where allowed)
 
JRL
Liskov Substitution Principle
The Liskov substitution principle (LSP) is a particular definition of a subtyping relation, called strong behavioral subtyping, that was initially introduced by Barbara Liskov in a 1988 conference keynote address titled Data abstraction and hierarchy. It is based on the concept of "substitutability" – a principle in object-oriented programming stating that an object (such as a class) and a sub-object (such as a class that extends the first class) must be interchangeable without breaking the program. It is a semantic rather than merely syntactic relation, because it intends to guarantee semantic...
 
7:38 PM
@IluTov That's already the case, tho? With current implementation.
Or are there new problems with union types?
use array|ArrayAccess as foo;
$obj instance of foo --> $obj instanceof array|ArrayAccess
Hm
 
JRL
i am personally not a fan of any type aliasing system that requires me to check the defined type using instanceof
 
@JRL It's sometimes needed. To refine a type (Psalm).
 
JRL
you mean like in the case of refining Foo|Bar to just Foo?
for static analysis?
 
JRL
sure
but that's just using instanceof for what it's already for
 
7:44 PM
Not sure I understand "$obj instanceof Foo where Foo hasn't been loaded yet and the does implement ArrayAccess" then :d
 
JRL
use array|ArrayAccess as foo;
$unknown instanceof foo; <-- not a fan
$unknown instanceof ArrayAccess; <-- perfectly fine with this
 
Meh. instanceof union types does not work. Didn't know.
That means "$unknown instanceof foo;" would break too, in a simple search-and-replace implementation, as it is now.
Funny tho
if ($foo instanceof Foo|null)
Looks correct, but is not :)
It's the operator |, bitshift, I guess
 
@OlleHärstedt To an extent, use with an alias, but that's only really used for conflict resolution ATM.
 
Which means a search-and-replace would accept it as valid, but the semantics would be wrong :(
Or what would indeed happen there o0
 
@OlleHärstedt I was simplifying when I was saying "search and replace".
 
7:50 PM
@IluTov What is used for conflict resolution?
@TimWolla Yeah, got it
 
@OlleHärstedt use Foo as Bar;
In pretty much all other cases you refer to exactly what is there. IMO that's much better than in JS where the same symbols might have different names.
 
@IluTov You mean that's the current use-case for class aliasing with "use"? Hm.
 
Yeah. I don't see it being used as "I don't like the name so let me change it" (and I think it shouldn't)
I guess the one common case is including the doctrine/symfony annotation namespaces.
 
8:16 PM
@OlleHärstedt Neither does anyone else.
 
The voters know? One might hope xD
 
@JRL The closest thing there is to what you describe is the preload file. Which... is wonky and so it seems not often used, which is unfortunate.
And yes, it's not really shared-hosting compatible, but then, that's increasingly rare these days.
 
I should read the RFC for "use ... as" :d
 
JRL
8:42 PM
@Crell did anything i described sound remotely useful? i feel like it's something that has been in the back of my mind for a while
 
8:54 PM
@JRL Oh yes. Having PHP start up and run to some point, then freeze that and start all new requests from that point is something people have been either asking for or trying to figure out how to do for at least a decade. But it's tricksy. Preloading of symbols is the closest we've gotten. But something like that would completely change how frameworks handle bootstrapping, and make PHP a lot more attractive for microservices.
@OlleHärstedt What you want is the pattern matching RFC. :-)
 
9:19 PM
@Crell Hehe, in that case, yes. Btw, did you et al sketch something on pattern matching also matching on exceptions? It's supported in OCaml and it's super useful, actually.
match foo($bar) {
| "moo" -> do_something()
| exception $ex -> do_something_else($ex)
}
 
@OlleHärstedt The current plan there doesn't treat exceptions in a special way. The existing catch syntax I think is sufficient.
 
Hell no it ain't ;D
But I can reason about it later, when pattern matching is further along
Or wait
You mean existing try-catch, or something else?
Anyway, it's amazingly ergonomic in practical use.
 
9:36 PM
Existing try-catch. It's more verbose than what OCaml has (your code snippet), but it does the same thing.
Or you could match-is on the object type of the exception, like any other object type.
 
@Crell Hmm, that would only work if the exception is returned as an object tho?
OCaml does have a try-catch actually, which is older than the inclusion of pattern-matching of exception. They added it later as syntactic sugar.
 
Well, if you want someone to *return* an exception, not throw it, then you're not talking about exceptions as they exist in PHP today. You're talking about something that one way or another boils down to an Either monad or a union return. Like what Midori does.

More thoughts on that front here: https://peakd.com/hive-168588/@crell/much-ado-about-null
 
That's actually what I'd like to avoid :) So that the exception can be caught without forcing the client code to non-idiomatic coding. But true, result types are also usable.
I did a fun snippet the other day to try to imitate Go
if (([$result, $error] = bar()) === [$result, null]) {
echo 'all good, we got result ' . $result;
} else {
echo $error;
}

Poor man's pattern matching
 
10:19 PM
Oh my...
 
JRL
10:34 PM
i think you're mixing up a failure and an exception @OlleHärstedt
an exception, typically, is supposed to be something that, absent some change to the current program, prevents the program from continuing at all
so the proto-typical exception handling is things like logging, and making sure that all your resources and persistent data are squared away
 
Excellent piece on error handling: joeduffyblog.com/2016/02/07/the-error-model
 
10:48 PM
@Danack AFAIK they want to make more stuff public but it's still an admin mess
 
JRL
@Crell I have an exception that I throw in Fermat only for recoverable errors. OptionalExit
the point about it being heavy to compile the stack trace just to recover is still valid, but it does simplify it a bit
 
@Crell Glad you're preaching it :p
 
JRL
11:02 PM
hard to implement the Midori concept of contracts without enforcing immutability everywhere in the language
otherwise stuff like requires $obj->isValid() might have side effects
Customer?? customer = customers[id];
if (customer != null) {
// Notice, `customer` is still `Customer?` in here, and could still be `null`!
}
sorry, but i dont think any amount of "but it's so functionally pure!" can ever convince me that have $var be null inside a conditional checking for null is a good thing
 

« first day (4367 days earlier)      last day (567 days later) »