Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    typedef struct fat_ptr_t {
        size_t size;
        void * start;
    } fat_ptr_t;

    extern void foo(fat_ptr_t a);
if it's a good idea to use a fat pointer, why do we need new syntax to sell it? What am I missing here?


> What am I missing here?

- A concise syntax for declaring, accessing and mutating them. Dealing with lists is such a common thing in programming languages, that it's simply crazy to not have a proper syntax for them.

- Generics/templating, so that you can use concrete types instead of 'void *'. Having that prevents mistakes and also tends to make code self-documenting.

"If it's such a good idea to use a safety belt and airbags, why do we need special devices for it? Why can't I just use a piece of rope I had in a drawer and some leftover balloons from my previous birthday party?"


There are lots of places you can make C's syntax more concise. What do you get for changing the syntax here? Why is it worth it?

void* was merely for example. Yes make it typed when you use it in your C code. Also used accessor functions to wrap array index so you can switch on & off a macro for bounds checking, absolutely do that. Does new syntax change anything if you do these things?

Don't much care for the seatbelt analogy there, remove your working, properly fitted seatbelts with our red ones because they're easier to see? These kinds of analogies always break down. Especially car analogies for programming and yes, I use them too.




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

Search: