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 the language features.

For a type of ?int, null is indeed a valid value; but so is 0, and -1, and so 
on. Why should the language assume that one default, among all the 
possibilities, if you don't specify any?

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.
We have two different "things" that currently return a NULL value. Similar to a function with a void returntype still returning NULL.


Perhaps we need to think about introducing "undefined" to make that clearer? But what is actually clearer than throwing an error when trying to access something that is undefined...

https://stackoverflow.com/questions/5076944/what-is-the-difference-between-null-and-undefined-in-javascript

So how complicated would it be to throw that same error when assigning the return type of a void function to a variable?

Cheers

Andreas

--
                                                              ,,,
                                                             (o o)
+---------------------------------------------------------ooO-(_)-Ooo-+
| Andreas Heigl                                                       |
| mailto:andr...@heigl.org                  N 50°22'59.5" E 08°23'58" |
| https://andreas.heigl.org                                           |
+---------------------------------------------------------------------+
| https://hei.gl/appointmentwithandreas                               |
+---------------------------------------------------------------------+
| GPG-Key: https://hei.gl/keyandreasheiglorg                          |
+---------------------------------------------------------------------+

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to