Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

[Programming] Constants [Variables]

Name: Anonymous 2008-02-21 14:28

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 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: Anonymous 2008-02-21 14:30

In before all hell breaks loose.

Name: Anonymous 2008-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: Anonymous 2008-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.

Name: EXPERT HASKELL PROGRAMMER 2008-02-21 17:06

Variables are constants.

Name: Anonymous 2008-02-21 17:29

>>5
Stop trying to promote a vice to a feature.

Name: Anonymous 2008-02-21 19:25

You bitch. You reversed the TOC with this thread

Name: Anonymous 2008-02-21 19:39

>>7
Posting in the wrong thread!

Name: Anonymous 2008-02-21 19:43

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 use the State monad? Please someone enlighten me.

Thanks in advance.

Name: Anonymous 2008-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.

Name: Anonymous 2008-02-21 21:47

>>10
confusing‽
you must be an idiot.

Name: Anonymous 2008-02-22 11:29

same person, and we have been trolled variably.

Name: Anonymous 2008-02-22 11:35

>>12
Failed attempt at giving ``same person, and we have been trolled constantly'' a meme status.

Name: Anonymous 2008-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: Anonymous 2008-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: Anonymous 2008-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: Anonymous 2008-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.

Name: Anonymous 2009-03-06 13:10

Variably.

Name: Anonymous 2010-02-04 19:40

What does /prog/ think about #define's?

Name: Anonymous 2010-02-04 19:45

>>19
Dead threads don't say no.

Name: Anonymous 2010-12-20 19:49

Name: Anonymous 2013-01-18 23:32

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Don't change these.
Name: Email:
Entire Thread Thread List