carp-lang / Carp

A statically typed lisp, without a GC, for real-time applications.
Apache License 2.0
5.53k stars 178 forks source link

Wrap all C stlib functions that return a pointer in a Result type #617

Open sdilts opened 5 years ago

sdilts commented 5 years ago

Many C library functions return a null pointer on error, i.e. malloc and fopen, etc. To make these more safe, their return values should be wrapped in a Result type.

sdilts commented 5 years ago

Most of these functions also set errno to indicate how the function failed. Is that something that should be left up to the caller to check, or should we try to interpret it in the error we return?

eriksvedang commented 4 years ago

I think this sounds like a great idea. Since most C functions have weird names I think it would work well to keep those around but use more lispy names for the safe ones.