I have a question related to Programming, so I thought, where else to come besides here, right?
So anyway, my question is about constants. Why are they in programming languages? Why can't you just set a variable and then not fucking change it? Please someone enlighten me.
Thanks in advance
Name:
Anonymous2008-02-21 14:30
In before all hell breaks loose.
Name:
Anonymous2008-02-21 14:31
>>1 I have a question related to Programming, so I thought, where else to come besides here, right?
Correct. So anyway, my question is about constants. Why are they in programming languages? Why can't you just set a variable and then not fucking change it?
So that when a person (you) reads the program later, they see it's a constant and know it will not be fucked with. The compiler may also optimize access to constants.
Name:
Anonymous2008-02-21 14:44
So people who use your people later may change the constants to alter the behaviour of the program. The first example from K&R comes to mind, the one with printing table of temperatures: you can change the range of the temps taken.
I have a question related to Programming, so I thought, where else to come besides here, right?
So anyway, my question is about mutable variables. Why are they in programming languages? Why can't you just use the State monad? Please someone enlighten me.
Thanks in advance.
Name:
Anonymous2008-02-21 21:14
>>9
It turns out that monads are confusing and scary, as well as being a hack to get around a lack of mutable variables.
>>12
Failed attempt at giving ``same person, and we have been trolled constantly'' a meme status.
Name:
Anonymous2008-02-22 11:41
>>9
It is a relic from the days when computer architectures had registers and memory banks where one could write data. The languages of that era simply reflected the hardware features.
Name:
Anonymous2008-02-22 14:48
>>9 It really works without much change
What's up /prog/?
I have a question related to Programming, so I thought, where else to come besides here, right?
So anyway, my question is about mutable variables. Why are they in programming languages? Why can't you just set a variable and then not fucking change it? Please someone enlighten me.
Thanks in advance
Name:
Anonymous2008-02-22 16:53
typedef const int int;
typedef const char char;
typedef const float float;
typedef const double double;
typedef const long long;
Name:
Anonymous2008-02-22 20:38
>>15
It is much easier to reason the correctness of pure functions than functions that contain side effects. The time saved by not having to trace side effects allows us to invest that time into more meaningful endeavours.