Hacker Newsnew | past | comments | ask | show | jobs | submit | jasdfwasd's commentslogin

I plan to remain smaller than two VMs


Trump and Netanyahu believe they can win this one [1]:

[1]: https://www.nytimes.com/2026/04/07/us/politics/trump-iran-wa...


Could large data types be problematic for the prelude types Option/Result/Tuple? They don't store as pointer and every receiver is by value.


> p = (char*)"";

yikes


I thought that was a typo or the forum software removed something, but no - it's a pointer to an empty string literal. If I understand how that works, this creates a null byte (in the read-only memory section of the compiled output?) and points to it. Before this line it checks if p is NULL.

I wonder what is the advantage of doing this? Maybe to make sure that p is an actual pointer, so later code can just make that assumption.


Yeah, it simplifies later code, and is safer in the face of future changes.

Or put another way, it tightens the API/contract of that chunk of code to always return a valid string.


That makes sense, with that "guard" at the top, the rest of the function can return the pointer anywhere. And I imagine the compiler will ensure the empty string literal is created only once. Good to know!


it would be better to make p a const char* though, so that the code is not casting away the constness of the string literal (which can invoke undefined behaviour, though in practice string literals are going to be in a read-only area of memory anyway).


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: