Yes, that is normalThen I have a natural followon question - what is the difference between a var and a const in FP?
It's basically a writeable constant.
When ever you apply a type to it then becomes a writeable constant which basically means it gets loaded into memory at program load time.
you can turn this off but you'll find that feature very desirable.
In other languages they call it differently, STATIC for example comes to mind..
Then I have a natural followon question - what is the difference between a var and a const in FP?
you can turn this off but you'll find that feature very desirable.Can you list some scenarios where this feature is useful?
Can you list some scenarios where this feature is useful?these "writeable constants" (horrible name) are useful when a function/procedure wants to keep track of some value across calls. For instance:
these "writeable constants" (horrible name) are useful when a function/procedure wants to keep track of some value across calls.This one cleared cloud in my head. I agree the name 'writeable constants' is a horrible name in that it's not logical at all, and it kills my brain.
I'm not 100% sure, but I guess, consts should be created in "const" executable image section, i.e. read-only section. I.e. such code should compile, but it should cause access violation at runtime. I guess, compiler optimizes such code some way, so such variable is created on stack, that is obviously writable.
It really deserves a dedicated keyword like static in C/C++ or something similar.