Question

Is it a way to create mutable state with modules? How can using this be a good idea? Wouldn't that kind of break the immutability idea from functional programming?

Was it helpful?

Solution

No because it's used at compile-time. It's kind of #define in C.

You can see example https://gist.github.com/mprymek/8379066 where attribute "sensors" is used to accumulate functions defined with macro "sensor". When you have all these functions accumulated, you can automatically generate function "run_all" which runs all of them. Of course all of this must be done at compile-time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top