I completely agree with Marco. We should not mix up nullsafe operator with
array access. As for me, aforementioned code works as expected.
As an improvement, we can think of access-safe operator (like `$arr[?0]`),
however I'm not sure if introduction of such will make sense.
Regards
Yevhen
On We
`$undefined?->bar()` does feel wrong, but `$arr[0]?->bar()` does not to me.
But maybe i've just been using javascript too much lately
On Wed, 24 Aug 2022 at 15:11, Marco Pivetta wrote:
>
> Hey Gert,
>
> On Wed, 24 Aug 2022 at 14:59, Gert de Pagter wrote:
>>
>> Hi Internals,
>>
>> I recently lea
Hey Gert,
On Wed, 24 Aug 2022 at 14:59, Gert de Pagter wrote:
> Hi Internals,
>
> I recently learned that using null safe on an array access can still
> emit a warning when the array access is not defined. I kinda expected
> it to work like a null coalesce and just short circuit there,without
>
Hi Internals,
I recently learned that using null safe on an array access can still
emit a warning when the array access is not defined. I kinda expected
it to work like a null coalesce and just short circuit there,without
the warning.
Is there any chance this behaviour could be changed in a n upc
Hello, everybody!
After using nullsafe operator for a while, I have some further thoughts.
In most cases when we make type nullable, we would use nullsafe operator if
we don't know how to deal with it. This causes clogging main code with this
? signs. Possible solution is to make nullsafe type in
> On Nov 4, 2020, at 1:38 PM, Eugene Sidelnyk wrote:
>
> Yeah... Creating null was a huge mistake.
> Now it is probably too late to fix that (maybe some new language can
> introduce that).
>
> But what do you think about introducing special class `NullObject`?
I would rather let an instance be
Hey,
On Wed, Nov 4, 2020, 20:39 Eugene Sidelnyk wrote:
> Yeah... Creating null was a huge mistake.
> Now it is probably too late to fix that (maybe some new language can
> introduce that).
>
>
Y'all confusing Java's `null` (billion dollar mistake) with PHP's `null`.
* In Java, `null|object` pa
Yeah... Creating null was a huge mistake.
Now it is probably too late to fix that (maybe some new language can
introduce that).
But what do you think about introducing special class `NullObject`?
On Wed, Nov 4, 2020, 9:32 PM Christian Schneider
wrote:
> Am 04.11.2020 um 19:39 schrieb Eugene Sid
Am 04.11.2020 um 19:39 schrieb Eugene Sidelnyk :
> Thus, can you provide any other dangerous example?
I think at this point you could have realised that it is
a) a BC break (code which has thrown an exception before now wouldn't)
b) not finding any love among the community here. Possibly for a rea
> Implicit nullable is terrible, moreover I don't see why users should return
> null values more often.
> They serve their purpose but most of the time you can use another sane/safe
> default of the given
> property type.
>
Agreed.
I’m not overly opinionated about much, but null as a default
Thus, can you provide any other dangerous example?
On Wed, Nov 4, 2020, 6:59 AM Eugene Sidelnyk wrote:
> But wait!
>
> In your example, funds won't get detracted. If `$accounts->get($receiver)`
> will return `null`, then everything inside `addFunds(...)` will not be
> executed.
> Your example (s
But wait!
In your example, funds won't get detracted. If `$accounts->get($receiver)`
will return `null`, then everything inside `addFunds(...)` will not be
executed.
Your example (simplified): https://3v4l.org/38Dk3
Another one:
```php
function expensive_function() {
var_dump(__FUNCTION__);
}
However, `null` value is not a good way to use a default value instead of
an object.
When it comes to polymorphism, we would like to avoid null checks from
being all around.
The same goes not only for `->`, but also return / argument type-hintings.
Why do we even need to know that object can be nu
Hm, yes. If the `get()` method can return `null`, then it is a problem.
Currently `null` is abused to indicate that value was not found.
`NotFoundException` should be thrown instead.
But.. yeah, we can't just use `nullsafe` by default because of abuse of
`null`.
On Tue, Nov 3, 2020 at 10:11 PM Ma
Hey,
On Tue, Nov 3, 2020 at 9:11 PM Marco Pivetta wrote:
> Overall, "null safe" can be very dangerous if made the default.
>
> Here's a scenario where I'd never want "null safe" behaviour (which does
> anything but introducing safety):
>
> ```php
> $accounts->get($receiver)
> ->addFunds(
>
Heya,
On Tue, Nov 3, 2020, 17:38 Eugene Sidelnyk wrote:
> Hello, internals!
> I am wondering why don't we use ordinary `->` operator with safe null
> handling? Programmers will be more prone to return null values. And thus,
> in most of cases `?->` will replace `->`.
> Why do we need another ope
> > But some people vote down, because they are "narrow-minded" and "have bad
> > preconceptions" and would like to find more things they like about the
> > feature.
>
I think these words are quoted from a comment of mine on the operator
overloading RFC (or a surprising coincidence). This was a mi
> Le 3 nov. 2020 à 17:38, Eugene Sidelnyk a écrit :
>
> Hello, internals!
> I am wondering why don't we use ordinary `->` operator with safe null
> handling? Programmers will be more prone to return null values. And thus,
> in most of cases `?->` will replace `->`.
> Why do we need another ope
On Tue, 3 Nov 2020 at 19:36, Eugene Sidelnyk wrote:
> But some people vote down, because they are "narrow-minded" and "have bad
> preconceptions" and would like to find more things they like about the
> feature.
Please don't call people names.
People vote based on their own choice, and yes some
About implemented, there were many implemented features, but not accepted.
I was very frustrated, when I knew that PHP could have
https://wiki.php.net/rfc/userspace_operator_overloading , and it was
already implemented.
But some people vote down, because they are "narrow-minded" and "have bad
preco
-- Forwarded message -
From: G. P. B.
Date: Tue, Nov 3, 2020 at 9:08 PM
Subject: Re: [PHP-DEV] Nullsafe
To: Eugene Sidelnyk
On Tue, 3 Nov 2020 at 19:05, Eugene Sidelnyk wrote:
> Null value by itself was invented to indicate lack of data.
> But we can't just use it
On Tue, Nov 3, 2020, 7:58 PM Benjamin Morel
wrote:
> Hi,
>
> It currently returns null but issues a warning (which can be, and often
> is, converted to an exception by frameworks / custom error handlers):
> https://3v4l.org/1ZkVC
>
> The new operator returns null with no warning:
> https://3v4l.o
-- Forwarded message -
From: Eugene Sidelnyk
Date: Tue, Nov 3, 2020 at 9:05 PM
Subject: Re: [PHP-DEV] Nullsafe
To: G. P. B.
Null value by itself was invented to indicate lack of data.
But we can't just use it instead of objects, because of how it works.
We need to cre
-- Forwarded message -
From: Eugene Sidelnyk
Date: Tue, Nov 3, 2020 at 8:11 PM
Subject: Re: [PHP-DEV] Nullsafe
To: Benjamin Morel
When trying call a method, php falls with fatal error:
https://3v4l.org/jk5Fp
With nullsafe it silently returns null:
https://3v4l.org/MhXtM
Are
-- Forwarded message -
From: Eugene Sidelnyk
Date: Tue, Nov 3, 2020 at 7:08 PM
Subject: Re: [PHP-DEV] Nullsafe
To: Benjamin Morel
But currently working code doesn't fail with NullPointerException?
Otherwise it would not be a working code.
Early fail will be when we try r
On Tue, 3 Nov 2020 at 19:08, G. P. B. wrote:
> On Tue, 3 Nov 2020 at 19:05, Eugene Sidelnyk wrote:
>
>> Null value by itself was invented to indicate lack of data.
>> But we can't just use it instead of objects, because of how it works.
>> We need to create a boilerplate of NullObjects.
>> Consi
On Tue, 3 Nov 2020 at 16:48, Benjamin Morel
wrote:
> On Tue, 3 Nov 2020 at 17:38, Eugene Sidelnyk wrote:
>
> > I am wondering why don't we use ordinary `->` operator with safe null
> > handling?
>
Implicit nullable is terrible, moreover I don't see why users should return
null values more often
On Tue, 3 Nov 2020 at 17:38, Eugene Sidelnyk wrote:
> I am wondering why don't we use ordinary `->` operator with safe null
> handling?
Hi,
- changing the current behaviour of `->` would be a huge BC break
- and if we need another reason, there are many situations where you do
want to fail ear
Hello, internals!
I am wondering why don't we use ordinary `->` operator with safe null
handling? Programmers will be more prone to return null values. And thus,
in most of cases `?->` will replace `->`.
Why do we need another operator, if we can implement null safe in current
operator without BC b
29 matches
Mail list logo