4 ms·
A nullable char pointer is a perfectly sensible implementation of "Maybe String". At least, presuming a non-nullable char pointer is a perfectly sensible imple
by dllthomas 11y ago
A nullable char pointer is a perfectly sensible implementation of "Maybe String".
At least, presuming a non-nullable char pointer is a perfectly sensible implementation of String.
- rtpg 11y agoI kind of cover it in my other comment, but the issue is that now all char pointers are nullable, so you _have_ to assume that all "char* " are Maybe'd. But it could just as well be that only some of your strings are nullable, and so you could get rid of certain code paths.
- dllthomas 11y agoIt's a matter of types vs representation. A compiler could represent (with or without promising to do so) optional strings as a nullable pointer to a char array. Without additional help from the compiler to distinguish between Maybe String and String, then things are as you say. Incidentally, while Maybe String can be a nullable char pointer, Maybe (Maybe String) needs a different representation. This is where "nullable" in C# breaks down compared to a real option type - but only because they conflate type and representation.