Remix.run Logo
onionisafruit 4 days ago

I think I would like a “stackvar” declaration that works the same as “var” except my code won’t compile if escape analysis shows it would wind up on the heap. I say that knowing I’m not a language designer and have never written a compiler. This may be an obviously bad idea to somebody experienced in either of those.

I commented elsewhere on this post that I rarely have to think about stacks and heaps when writing Go, so maybe this isn’t my issue to care about either.

Scaevolus 4 days ago | parent | next [-]

This could probably be implemented as an expensive comment-driven lint during compilation.

onionisafruit 4 days ago | parent [-]

I don’t think it can be a true linter because it depends on the compiler. But it’s not a bad idea anyway

Yokohiii 4 days ago | parent | prev [-]

Escape analysis sends large allocation to the stack. The information is there.