Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-13 Thread Mike Schinkel
> On Feb 8, 2023, at 9:22 AM, Lydia de Jongh wrote: > > Hi, > > After posting this in the issues list > , I was asked to mail it here. > This is my first time here, so I hope I do it the right way. > > --- > > At last I

Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-13 Thread Claude Pache
> Le 13 févr. 2023 à 13:12, Robert Landers a écrit : > > I hope we can all agree that `null` is the absence of a value. Now we > currently have two different meanings of "absence of a value" which is > super annoying sometimes. > Although `null` is often used with that semantics in mind, fro

Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-13 Thread Andreas Heigl
Hey all. On 13.02.23 13:12, Robert Landers wrote: [...] What is the point of marking the type of a property, other than to prevent mistakes? In non-strict mode, it coerces quite nicely. For example, a string to an integer or an integer to a string. These aren't "mistakes" but making use of th

Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-13 Thread Robert Landers
On Sun, Feb 12, 2023 at 6:47 PM Rowan Tommins wrote: > > On 12 February 2023 11:11:31 GMT, Lydia de Jongh wrote: > >The features of a programming-language should not be about preventing > >mistakes, imho. > > > What is the point of marking the type of a property, other than to prevent > mistakes

Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-12 Thread Rowan Tommins
On 12 February 2023 11:11:31 GMT, Lydia de Jongh wrote: >The features of a programming-language should not be about preventing >mistakes, imho. What is the point of marking the type of a property, other than to prevent mistakes? >For me it is about the cluttering in an otherwise clean propert

Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-12 Thread Tim Düsterhus
Hi On 2/12/23 12:11, Lydia de Jongh wrote: In case I make a mistake and accidentally don't assign a value to the property when I should've, perhaps I've forgot to call the necessary setter in my constructor. If I later access the property it will blow up instead of silently feeding me garbage d

Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-12 Thread Lydia de Jongh
Hi, Thanks for all the answers so far. On 2/8/23 17:04, naitsi...@e.mail.de wrote: > > Would it make sense to make "null" the default value for nullable properties at least? > > So that one could write > > > > class Test { > > public ?string $name; > > } > > > > var_dump((new Test())

Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-08 Thread naitsirch
Am 08-Feb-2023 17:34:43 +0100 schrieb t...@bastelstu.be: > Hi > > On 2/8/23 17:04, naitsi...@e.mail.de wrote: > > Am 08-Feb-2023 15:59:02 +0100 schrieb tekiela...@gmail.com: > >> When using typed properties, the language cannot use NULL as the default > >> anymore because the type might not allo

Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-08 Thread Rowan Tommins
On 8 February 2023 16:14:07 GMT, Lydia de Jongh wrote: >From a programmer's perspective, the property is declared and should be >accessible. Even if it has no value. >There should be no difference between typed and none-typed properties for >this. I've actually been considering a proposal to remo

Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-08 Thread Kamil Tekiela
> But because of the typed properties, you have to initialize them before you can access them. I think that is cluttering up the code. It's not cluttering code. You don't need isset if you do it properly. You have a bug if your code tries to access an uninitialized property. > From a programmer's

Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-08 Thread Tim Düsterhus
Hi On 2/8/23 17:04, naitsi...@e.mail.de wrote: Am 08-Feb-2023 15:59:02 +0100 schrieb tekiela...@gmail.com: When using typed properties, the language cannot use NULL as the default anymore because the type might not allow NULL, e.g public string $name allows only string values. Would it make s

Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-08 Thread Lydia de Jongh
Hi Kamil, Thanks for your reply. With regards to the automatic default, of course I can only agree! Indeed isset() should not be needed for declared properties! But because of the typed properties, you have to initialize them before you can access them. I think that is cluttering up the code. >F

Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-08 Thread naitsirch
Am 08-Feb-2023 15:59:02 +0100 schrieb tekiela...@gmail.com: > When using typed properties, the language cannot use NULL as the default > anymore because the type might not allow NULL, e.g public string $name > allows only string values. Would it make sense to make "null" the default value for null

Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-08 Thread Kamil Tekiela
Hi Lydia, I understand where you are coming from because I encountered this a few times myself, but every time it was actually because I was doing something wrong. The reason for this limitation is actually very simple and logical. Let me explain. When you use untyped properties, the type is not r

[PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-08 Thread Lydia de Jongh
Hi, After posting this in the issues list , I was asked to mail it here. This is my first time here, so I hope I do it the right way. --- At last I have the opportunity to start using php8, I am very happy with it and how m