Comment

Comment by brundolf

What I actually had in mind was Rust. Broadly speaking Rust requires all stack-allocated values to be sized at compile time. Also, thanks to borrow-checking, code is encouraged to stay fairly stack-oriented, so at least I personally end up with lots of function-local data structures that get passed by reference down to other logic. So I think "pointless" is overstating it.

However, the bigger question wasn't about the size limit but about being runtime-dynamic. Why can't a function's argument have a dynamic size, and the stack frame just allocates the needed space at call-time? Even if we're not talking about large structures, this would be useful for things like (for example) ad-hoc union types (as opposed to enums, where all variants have to be known at compile time and are packed into a single bit-width regardless of the value). Maybe you could even get rid of some of the code-duplication that happens when generic functions get reified.

I assume there's a good reason, I just don't see what it is.

parent brundolf 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton