CBFalconer wrote:
Peter N Lewis wrote:
... snip ...
New(s,57) gives a runtime error on failure, and so the compiler knows that it need not bother checking.
s := New(String,57) potentially returns nil, so the compiler checks.
- `New' as a function is a GPC (and in other contexts, namely objects, also a BP) extension. That's basically just syntactic sugar that doesn't add a lot, but also doesn't hurt much ...
Ahh. So since New is a GPC extension, as well as a BP extension where it looks like New can return nil, perhaps it is quiet reasonable to allow New as a function to return nil? I would have no problem using New as a function when I wanted to ensure I could defend against memory allocation failures. Peter.