top | item 28294778

(no title)

stephen82 | 4 years ago

You are free to manage memory yourself, if that is what you mean [1].

[1] https://nelua.io/overview/#memory-management

discuss

order

duped|4 years ago

That's not really what I meant. The example is showing the problem, the transition to manual memory management just makes it a bit easier to write a program without memory operations in critical sections.

What I'm talking about is a hypothetical language that makes memory operations in critical sections forbidden and considered a compilation error.

com2kid|4 years ago

> What I'm talking about is a hypothetical language that makes memory operations in critical sections forbidden and considered a compilation error.

This is easy to do in C, and you'll see it in embedded code. A simple preprocessor macro that redefined malloc to something that causes an error.

To enable malloc in some chunk of code (embedded defaults to "malloc is bad"), you can define it accordingly in the .c files that need it.

p0nce|4 years ago

D has the @nogc attribute. Using it to make memory allocation forbidden in parts of the codebase.