Skip to main content
26 events
when toggle format what by license comment
May 30 at 6:10 comment added Davislor Follow-up: C23 adds nullptr_t (from C++) as a replacement for the type of a bull pointer. This was motivated primarily by implementations that #define NULL 0, but where a void* and the int value 0 have different widths. This breaks NULL in any context where the compiler cannot deduce that the type is void* and not int, such as passing it to a variadic function. Apparently it’s impossible to get everyone to stop defining NULL as 0.
Mar 9 at 23:44 comment added David Young @Davislor What I mean is if you want the kind of setup like C where null can be used for any pointer type. Also top types are not necessarily what I mean here. I am largely talking about a system without subtyping (in the usual sense anyway). I'm not sure what you mean by an error code. null does not necessarily indicate an error. In fact, null is really the only value that (potentially) makes sense to have with that type since such a value would need to be able to be used at any pointer type (assuming you aren't allowed to cast a integer literal to a pointer or something like that).
Mar 9 at 23:16 comment added Davislor @DavidYoung I do suggest that as a solution for a generic reference. I would recommend against it as the type of an error code.
Mar 9 at 23:07 comment added Davislor @DavidYoung Isn’t that a reference to the top type? I’d normally expect the type checker to allow a value of that type to be used as any kind of pointer, which I would not want.
Mar 9 at 22:00 comment added David Young There is another option for the type of a null pointer. Let's say pointers in our language are represented as a parametrized type named Ptr which we can use like Ptr<Int>. Then, we can give null the type forall A. Ptr<A>. Of course, whether null pointers should exist at all is a separate question.
Jul 19, 2023 at 14:56 vote accept Seggan
Jul 11, 2023 at 14:21 comment added Davislor @AakashM While I liked the joke, I don’t want to spread any misinformation. So, removed.
Jul 11, 2023 at 14:19 history edited Davislor CC BY-SA 4.0
added 222 characters in body
Jul 11, 2023 at 9:30 comment added AakashM Tiny nitpick, while Hoare did invent nulls in the '60s, he didn't say that line until 2009
Jul 11, 2023 at 8:39 comment added Deduplicator Nullability, optionality, whatever you name it. As long as it is not the default and universally applicable (including stackable), it's fine.
Jul 10, 2023 at 22:28 history edited Davislor CC BY-SA 4.0
deleted 3 characters in body
Jul 10, 2023 at 17:20 history edited Davislor CC BY-SA 4.0
deleted 6 characters in body
Jul 10, 2023 at 16:34 comment added Davislor @dan04 Even before that, GCC 4.9.2 had introduced __null as a magic keyword in G++, and Scott Meyers had written a widely-cited nullptr_t template in his book Effective C++. However, I see that GCC on many platforms does still define NULL as ((void*)0).
Jul 10, 2023 at 16:13 comment added dan04 C++11 (I think) replaced the NULL macro with a nullptr keyword, with the type nullptr_t, which is convertible to, but distinct from, void*.
Jul 10, 2023 at 15:14 history edited Davislor CC BY-SA 4.0
added 1722 characters in body
Jul 10, 2023 at 15:02 history edited Davislor CC BY-SA 4.0
added 1722 characters in body
Jul 10, 2023 at 2:03 history edited Davislor CC BY-SA 4.0
added 30 characters in body
Jul 10, 2023 at 1:50 history edited Davislor CC BY-SA 4.0
added 160 characters in body
S Jul 10, 2023 at 1:45 review First answers
Jul 10, 2023 at 2:10
S Jul 10, 2023 at 1:45 history edited Davislor CC BY-SA 4.0
added 160 characters in body
Jul 10, 2023 at 1:22 history edited Davislor CC BY-SA 4.0
added 136 characters in body
S Jul 10, 2023 at 1:16 review First answers
Jul 10, 2023 at 1:34
S Jul 10, 2023 at 1:16 history edited Davislor CC BY-SA 4.0
added 136 characters in body
Jul 10, 2023 at 1:10 review First answers
Jul 10, 2023 at 1:13
S Jul 10, 2023 at 1:06 review First answers
Jul 10, 2023 at 1:09
S Jul 10, 2023 at 1:06 history answered Davislor CC BY-SA 4.0