HNHacker News
TopNewBestAskShowJobs

smlckz

445 karma · joined February 24, 2020

submissionscomments
smlckz··on Eloquent JavaScript 3rd Edition (2018)
try to implement a ES2020 interpreter from scratch (like fabrice bellard's quickjs)

when you're done, you'd have learnt enough on the way and know what you don't know

smlckz··on Tell HN: C Experts Panel – Ask us anything about C
another proposal:

    _If, _Ifdef, _Ifndef
inside function macros

for example:

    #ifdef SOME_CONST
    #define WHATEVER(w, h, a, t, e, v, e, r) \
        ... common part ... \
        ... for SOME_CONST ... \
        ... common part continued ...
    #else
    #define WHATEVER(w, h, a, t, e, v, e, r) \
        ... common part ... \
        ... when SOME_CONST not defined ... \
        ... common part continued ...
    #endif
With _Ifdef, the above could be written like:

    #define WHATEVER(w, h, a, t, e, v, e, r) \
    ... common part ... \
    _Ifdef(SOME_CONST, \
        (... for SOME_CONST ...) , \
        (... when SOME_CONST is not defined ...)
    ) \
    ... common part continued ...
With these, one could also do:

    #define FACTORIAL(n) _If(n == 0, 1, (n) * FACTORIAL(n))
    int f = FACTORIAL(6);
turns into: int f = (6) * (5) * (4) * (3) * (2) * (1) * 1;

That would be very useful, I think. It might help with code duplication in function macros.

Maybe _Switch/_Case thereafter.

smlckz··on Tell HN: C Experts Panel – Ask us anything about C
So, should I not care about that so much, and write programs without free()'ing allocated memory?

If OSes do that, why not standardize that in C?

smlckz··on Tell HN: C Experts Panel – Ask us anything about C
I want this feature in the standard.

If there exists any memory block allocated using malloc() / calloc() / realloc() which has not been free()'d, at the end of the program, they would be free()'d automatically.

One can easily do it with keeping a linked list and using atexit(), but, can it be added to the standard?

A general question, will anything, any feature, which is "easy" to implement in pure C, like array knowing its own length or pascal strings, NOT be allowed to be in C standard, even if it is widely used, maybe almost everywhere?

smlckz··on Google tracking a bike ride past a burglarized home made the rider a suspect
google knows so much about us.

how many people [have] read t&c and privacy policy?

← PreviousPage 6 of 6