Re: RFC Proposal: Maybe monad and execution time polymorphic methods

From: Date: Tue, 22 Mar 2016 03:23:09 +0000
Subject: Re: RFC Proposal: Maybe monad and execution time polymorphic methods
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-91833@lists.php.net to get a copy of this message
Le lundi 21 mars 2016, 17:04:30 Facundo Martinez Correa a écrit : > But then I realized the problem. There > are many times where we need uncertainty. Code is a reflection of reality, > and as such, it must reflect uncertainty. NULL is a good enough way to > express nonexistence, albeit a bad one. We have been using it in code for > years, but it is also used to say many things. Things that cause > uncertainty in the code. I receive a null, does it mean it doesn't exists? > That it will exist? Should I allow it? Is it a good value? I for sure don't > know. And in my experience, I have used it for many of those cases. And in > many situations that I'm not proud of, all of them at the same time. If your function is supposed to return a User and can’t, maybe it should throw an Exception. Just wanted to point out it can be a good alternative to returning NULL for error handling. Côme

« previous php.internals (#91833) next »