Live data from Hacker News

Show HN: The C3 programming language (C alternative language)

github.com

191–192 of 192 posts

Re: Show HN: The C3 programming language (C alternative language)

#191
post #190

Earlier quoted context omitted.

The temp allocator is a stack allocator, How much have you used that? C has that and it will get cleared at the end of a scope too, but it is pretty exotic because it is so fragile. It's a catch-22, if something is so big that you need to allocate the exact size to save stack space, then it could become problematic and blow the stack. This is not a substitute for having allocations be freed at the end of a scope. For…

No, not alloca , I mean a stack allocator as you push / pop memory scopes. The trailing body macro is something I think you should try out before dismissing it. It's similar to how Ruby can do it, with the closures exiting the "outer scope", which is unusual.

You keep saying "stack allocator" but you haven't been specific and said if you mean allocating on the stack or allocating on the heap and freeing memory based on the stack.

I'm not dismissing the trailing body macro approach, I just don't see what advantage it has over destructors which is a well worn solution. It seems like some of the design decisions are based off of 'don't do something that C++ does'

Re: Show HN: The C3 programming language (C alternative language)

#192
post #190

Earlier quoted context omitted.

No, not alloca , I mean a stack allocator as you push / pop memory scopes. The trailing body macro is something I think you should try out before dismissing it. It's similar to how Ruby can do it, with the closures exiting the "outer scope", which is unusual.

You keep saying "stack allocator" but you haven't been specific and said if you mean allocating on the stack or allocating on the heap and freeing memory based on the stack. I'm not dismissing the trailing body macro approach, I just don't see what advantage it has over destructors which is a well worn solution. It seems like some of the design decisions are based off of 'don't do something that C++ does'

A stack allocator is an allocator that aside from allocate, has a push and a pop function. Image an arena allocator (aka bump allocator), where ”push” stores the current start of free memory, and ”pop” resets to this point, erasing all allocations between push and pop. This is a stack allocator.

It is similar to the function stack, but push and pop can be arbitrarily granular, as opposed to only happening at entry/exit.

Post reply on HN