« first day (4353 days earlier)      last day (586 days later) » 

8:01 AM
 
@Derick ty
 
@RemiCollet We used to have a collection of examples that touched all opcodes (like I just did for github.com/derickr/vld/commit/…), but I can't find that anymore...
I wonder who will whine if I would update this to something useful: php.net/manual/en/debugger-about.php
 
8:38 AM
apt-get install php-bcmath
php7.4-bcmath 7.4.30-1+deb11u1 [Not candidate version]
E: Package 'php-bcmath' has no installation candidate
What is the problem? I'm in php 8.1
 
JRL
isn't bcmath included in the default build for 8.1?
 
no
and even if it was, distributions unbundle this stuff
 
JRL
hmmm
i wonder why i thought it was
 
@LeviMorrison I would somehow expect @JRL to know what a Monad is
 
JRL
to my understanding, a monad is a thing that you learn to explain to others what a monad is
 
8:51 AM
I do think I've got a somewhat good way to explain what a monad is, but it takes a 40min talk
 
JRL
that tracks
 
Or lead up to what a type of Monad is
Because I truly believe when people attempt to explain them they go for the most "simplest" example, which sadly completely misses the point as to why you would even care about them in the first place
 
JRL
every example ive ever seen has made me wonder why it would be useful
 
I know right :D
 
JRL
well
i should say
that another thing that has confused me is people who seem to think that using a "monadic type" or a type wrapper for a return value, is somehow inseperable from monadic functional programming
like, having a Maybe type is useful regardless of whether you use functional or OOP programming
 
8:57 AM
Sure, but a monad is not just a type wrapper, it also has a "bind" function (terrible naming IMHO) which allows to pipe different monads together which handles the unwrapping of the inner value(s) or bailing out for you
The main premise is to move the possible error states into the type system in a way that you are forced to acknowledge it. Which is easier to do in a language which provides this out of the box
But I do agree I don't think it's fundamentally tied to functional programming
 
JRL
right... i dunno if there's a term for it, but having types that contain logic, something like "rich types", is definitely possible in lots of languages
 
The problem with monads is the same as moving from procedural to OOP IMHO, you don't get it until you do, and then it becomes really hard to explain it to other people
 
JRL
well, i was mostly just contemplating casting magic methods for objects, not rewriting the entire PHP type system, so it caught me a bit off guard, lol
 
9:35 AM
Does it beneficial when using docker-php-ext-install ? It's slow, Why not using apt ?
 
 
2 hours later…
11:30 AM
Happy Friday all!
 
happy friday indeed o/
 
Morning @Ekin is your friday halfway done or has it just started?
 
it has just started :-)
 
Same
 
\o/ we have the entire day to enjoy
 
11:43 AM
Stuck in meetings till 2PM -_-
Then gaming all night :)
 
I have just one meeting today at 1:30 thank goodness
 
lucky
 
11:58 AM
Has anyone else noticed a slight uptick in bug reports from github users who appear to have solely created github accounts to make bug reports?
 
@Danack Isn't that the point?
Or is it there are more bug reports because there are more problems?
 
12:19 PM
Apparently, if you use Microsoft MFA (or something) you might want to turn off push-requests for auth:
 
Hhaha
I am currently fighting with Windows core isolation/memory integrity settings
 
12:50 PM
@TimWolla My thoughts are...the current behaviour is rubbish, in particular not being able to know why unserialization failed is terrible. Adding a way to get the reason why unserialization failed in a structured was would clearly be an improvement.
btw that doesn't necessarily need to be an exception. If PHP had used tuple-ish returns earlier, a lot of functions (including the file opening) would look more like:
[$data, $error] = unserialize($input);
So I think for the current proposal, only changing the error reporting severity doesn't bring much value, but changing it to throw an exception is too big a BC break for people to find acceptable, unless a very cunning way can be thought of to make the change not be an 'only detectable in production' BC change.
Introducing a new function (e.g. something like unserialize_or_throw()) allows people to have saner unserization behaviour in the next version of PHP, and kicks the problem of what to do about the current version of unserialize down the road...
 
@Sara Yes, and would you mind handling 8.0.25 as well? I'll be travelling
Then, we are back to ping-pong: I'll handle .26, you handle .27, etc.
 
1:07 PM
21 hours ago, by TimWolla
@Danack Are you personally concerned about the "wrap exception", the "E_WARNING to Exception" or both?
 
1:43 PM
@TimWolla I guess both? tbh, I'm not entirely sure what you are asking exactly.
 
@Danack There was also a second message after the one I linked, giving additional context to the question.
 
Then definitely both, but more on "E_WARNING to Exception" than "wrap exception".
To be clear, some of the objections are possibly not really relevant and are grasping for straws to objects to the RFC....but a BC break in something that has been stable for many years is really likely to generate significant drama.
 
1:59 PM
The E_WARNING to Exception I understand that – that's why there is a separate vote to decide whether it just unifies to E_WARNING (there are some E_NOTICE) or all the way up to Exception.
I don't particularly care about that one, it doesn't affect me in any way, because I use a throwing error handler.
For the "wrap Exception" one, I'd argue that the behavior is in fact not stable at all, because __unserialize() decides on its own what to throw and that includes arbitrary userland libraries.
 
"because I use a throwing error handler." - same, and I consider anyone who doesn't to be quite foolish.
"because __unserialize() decides on its own what to throw and that includes arbitrary userland libraries." - but for anyone who is unserializing stuff, they can already know what exceptions their unserialize call can throw, as they understand their own code, and so currently be specifically catching the 'only' exceptions it could throw.
 
Is that actually a real thing? So far you are the only one who was able to demonstrate a case where unserialize() gets broken input, but broken in a somewhat well-defined way: Additional backslash insertion because of broken DB storage that completely breaks the serialization format – and that one is a E_NOTICE one.
 
2:16 PM
Probably a real lurking horror somewhere, particularly around using exceptions for flow control 3v4l.org/YQFXH
On the one hand people who write code like this deserve some sort of karmic retribution.....but it would be a lot of drama.
 
Technically that one is already broken, because you don't know which Exception (of possibly multiple) is thrown first.
 
If their code is already working reasonably well, people won't care about technicalities.
As I said, I can't currently see a cunning way to improve the behaviour of the current unserialize without causing a lot of drama. And I'm not sure it would or should pass as an RFC. But introducing a new functions gives everyone who wants it the more sane behaviour.
 
Impossible Coding Challenge I would like to enter this competition.
9
 
 
2 hours later…
4:38 PM
@StatikStasis I am still stuck on the first puzzle.
 
4:52 PM
you've gotta be kidding
that's impossible.
 
does anyone here have advice on adding a set of coding standards so they're specified in composer.json? We've an amalgam of PSR-12 and custom ones for work and installing them via composer instead of hammering them in at /usr/share/pear/PHP/CodeSniffer/src/Standards is the better way to go.
 
@kguest why would they be in /usr/share/pear/PHP/CodeSniffer/src/Standards ? If you're using composer they should be in their own directory in your project. Or as a separate library that can be installed.
 
because...old school git here :D
 
You gotta keep up with the cool kids, dad-dio.
 
they're not being loaded thru composer at the moment, and I built things up from scratch/memory of how it used to be done back in the day.
lol yeah that too
I guess I might just have to look at how the slevomat and phpcompatibility standards do it and figure it out from there.
 
5:04 PM
I have a trivial code-sniffer rule here and it's included by including that package in the composer.json, and then referencing it in the codesniffer config here.
 
5:17 PM
Thanks - I must take a look at that on Monday
 
I'm confused 3v4l.org/7pONv why this function is two times faster than built in array_shift ?
 
cmb
@brzuchal array_shift() needs to reindex.
 
> All numerical array keys will be modified to start counting from zero while literal keys won't be affected.
@cmb Got it thanks.
But this makes it so unoptimal then I guess
array_push has no reindex but when I try to mimick it it's 30% slower as well 3v4l.org/kj3fj
Or I'm blind
So is array_pop 3v4l.org/tqq3U :/ ohhh, nvm but funny is that these functions are close to written in C
 
6:24 PM
@Danack =D
 
@kguest like this?
"config": {
    "sort-packages": true,
    "allow-plugins": {
        "captainhook/plugin-composer": true,
        "dealerdirect/phpcodesniffer-composer-installer": true
    }
},
we use captainhook to enforce phpcs rules and psalm on local git commit
there's a phpcs.xml.dist file in the root directory
 
7:26 PM
I have a method, buildIfAvailable() which returns an instance of the member class if requisite state can be found (from an external source) and set internally. Is there a pattern for this kind of behavior?
if there is a pattern, what is it called?
(I want to have a better high-level understanding of the code I'm working with)
 
@Tiffany If I understand you, sounds like caching?
 
maybe? at first glance, that doesn't seem right, but ... let me see if I can get a code sample
 
"Can you use it in a sentence." :-)
 
right...working with IP makes stuff awkward because I'm not sure where the line is as far as what I can share
 
Try working with TCP, that's even worse...
 
7:35 PM
.youtube.com/watch?v=12Hcbx33Rb4 EVGA no longer to do business with EVGA.
 
@Crell gist.github.com/tiffany-taylor/f5fb6dc5b958137891add30ae6599b37 obfuscated some of the code but roughly this
 
I think it's just a static factory method that has a failure mode of null.
 
okay
 
$fooInstance = Foo::buildMeAFoo(...); // Static factory method.
 
right
the "ifAvailable" part is what tripped me up as far as "I'm not sure if this is a factory"
 
JRL
7:40 PM
i imagine the calling code then has and if/match for null
 
And returning null in case of error conditions is one of many ways of handing the unhappy path. (I have written on this extensively in the recent past... :-) )
 
or at least, it's not a simple, pure factory
 
It's still a factory. Just one using null as a sentinel value. Whether that's a good design or not is a separate question, but it's still definitely a factory method.
They sometimes get called "Static constructors", too, especially if the actual constructor is private.
 
JRL
personally not a huge fan of that pattern (null for unsuccessful factory)
but it's a common one
and it can get the job done
 
I will save time and just leave this here, then say no more: peakd.com/hive-168588/@crell/much-ado-about-null
 
JRL
7:42 PM
i ranted about that extensively in Nicolas' attempt to get null intersections included in 8.2 after feature freeze
 
hehehe
I've been thinking on this space for a while now, and everything I come up with eventually comes back to being syntax sugar on the Either monad.
 
JRL
monadic type*
not a full monad necessarily
 
Midori looks like it had a really good model worth reviving.
 
thanks
 
JRL
other ways (besides full monads) include Nullable<T>, or making each class implement a Nullable interface
 
7:55 PM
I think a Nullable marker interface, which ?? and friends would respect, is a very strong contender.
 
JRL
ooo
actually... that wouldn't be that hard to do...
as far as creating an RFC
 
Convincing people of it, however...
That would allow you to return an intelligent error message object (of whatever type), and still say "I don't care, use ?? et al to just discard and use a default."
But you could also introspect the error object (via match, if, instanceof, method calls, or whatever you feel like) to do something more contextually useful.
 
JRL
i think, to make that work properly, the __construct() method of any class that implements a Nullable interface would not be allowed to throw
 
Seems reasonable off hand. Just to avoid convoluted loops.
 
JRL
well, such an interface would probably have two methods on it. something like hasValue() and something like extendedInfo() to allow the class to describe why it's refusing to construct
 
8:01 PM
I don't see why...
 
JRL
but if a class implements this interface, there would an expectation in calling code i would think that it does this instead of throwing
in the constructor
hasValue() would be used by all the language tie ins... null checks, ??, etc.
 
class DivideByZero implements Nullable {}

function divide($numerator, $divisor): float|DivideByZero
{
  if($divisor === 0) return new DivideByZero();
  return $numerator/$divisor;
}

$value = divide($n, $d) ?? $default;
 
JRL
extendedInfo() would be there purely for debugging purposes
though i guess that means it doesn't necessarily need to be part of the interface
 
I'm thinking much lighter touch. It's just a marker that means ?? et al will treat it as null.
You know from the signature that it's going to be a DivideByZero object if anything, so you know what if any methods to access on it.
 
JRL
it's only useful (to me) if the class that implements it can control when it is treated as null
 
8:03 PM
Or in this case just check the type, if there's multiple error cases.
 
JRL
so i would think at least the one method
 
Oh, I'm looking at it as "this is an error/null object, period, kthxbye." The type itself implies it's an error class.
 
JRL
im thinking of it as the engine evaluating some class method and getting a bool that tells it if the object wants the engine to treat it as null
that way you could always for instance return a Result object if you wanted
$app->result($result ?? $notFoundResult);
 
Hm.
So you're thinking of it more as a Maybe monad's isNull().
 
JRL
yes, just with inverted responsibility compared to how monads usually work in order to fit PHP
and work with existing community libraries, standards, etc.
 
8:09 PM
My concern there is that we already saw __toBool() et al get shot down. I can't see a __toNull() (or something equivalent to it) doing much better.
 
JRL
it does bring some of the features people would want form monads to PHP, but making it a lot more possible to use the type system in place of exceptions
ah, this wouldn't control casting exactly, though i also want to try and tackle that
although... i guess there's not a way to "cast" a value to "null"
just assigning it null
 
"Treat this object as this other type" is an area that has a lot of pusback generally. Some of it valid, but much of it just stubbornness. Like, I get why __toInt() is potentially concerning, unless we had a lot of other machinery around it. But Truthiness and Null-equivalence have huge upside potential, if one is willing to accept that objects are, for better or worse, a type system, not a code organization system.
 
JRL
i don't think those arguments have a leg to stand on now that we have intersection types
i mean, those arguments will still be made
i just think they are patently wrong at this point
 
"The type system is your code" is a hard concept to swallow if you're used to "types are suggestions for your code."
 
JRL
this is one of the cases where i think an interface makes sense
i really dont think the code to do this would be that hard though
or at least, not as hard as the code i did for the op overloads
 
8:16 PM
I suppose for the use cases I want I could make it work with a marker interface or a magic method. Either would do it (no pun intended).
 
JRL
yeah. though i think that passing something like this would make getting actual monads harder in the future
if that's a goal of yours
since this sort of accomplishes the same thing without a bind or unit type, and would probably end up being cited as precedent for the "PHP way" to do that sort of thing
 
I'm undecided. I mean, we can get monads today, it's just a bit verbose and the lack of generics is a problem.
 
JRL
generics solves everything! \o/
 
If we wanted error monads in the language, we should do it in such a way that the monad-ness is not directly user-exposed.
Like, what midori does is have returns and "exceptions", which are really just an alternate return channel, and then there's syntax to check which return channel was used. Which... is basically an Either monad by a different name.
That's kind of the direction I'm leaning for PHP, because it sidesteps the generics question.
If we can get the ADT RFC completed, that gives us user-space monads in a decent enough syntax, minus generics.
(Really, I've not had any new thoughts on this since my blog post linked above, so that's where I still stand, more or less.)
 

« first day (4353 days earlier)      last day (586 days later) »