Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #42596 > unrolled thread
| Started by | partremmaps@gmail.com |
|---|---|
| First post | 2014-04-05 13:07 -0700 |
| Last post | 2014-04-07 23:48 -0700 |
| Articles | 20 on this page of 142 — 23 participants |
Back to article view | Back to comp.lang.c
Is enum a suitable way to implement a "local define?" partremmaps@gmail.com - 2014-04-05 13:07 -0700
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-05 13:55 -0700
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-05 14:14 -0700
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-06 22:18 +0200
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-06 13:28 -0700
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-06 16:35 -0400
Re: Is enum a suitable way to implement a "local define?" Ian Collins <ian-news@hotmail.com> - 2014-04-07 08:55 +1200
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-06 23:30 +0200
Re: Is enum a suitable way to implement a "local define?" Ian Collins <ian-news@hotmail.com> - 2014-04-07 10:12 +1200
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-06 18:22 -0400
Re: Is enum a suitable way to implement a "local define?" Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-05 14:30 -0700
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-05 22:39 +0100
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-06 22:27 +0200
Re: Is enum a suitable way to implement a "local define?" Ian Collins <ian-news@hotmail.com> - 2014-04-07 08:52 +1200
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-06 23:20 +0100
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-07 02:17 +0200
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-06 19:00 -0700
Re: Is enum a suitable way to implement a "local define?" glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-07 04:44 +0000
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-07 10:15 +0100
Re: Is enum a suitable way to implement a "local define?" glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-07 18:32 +0000
Re: Is enum a suitable way to implement a "local define?" Kaz Kylheku <kaz@kylheku.com> - 2014-04-07 18:47 +0000
Re: Is enum a suitable way to implement a "local define?" Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-04-07 11:39 +0200
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-07 08:58 +0200
Re: Is enum a suitable way to implement a "local define?" Ian Collins <ian-news@hotmail.com> - 2014-04-07 19:34 +1200
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-07 09:41 +0100
Re: Is enum a suitable way to implement a "local define?" Ian Collins <ian-news@hotmail.com> - 2014-04-07 21:45 +1200
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-07 11:03 +0100
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-07 12:54 +0200
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-07 13:48 +0100
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-07 15:27 +0200
Re: Is enum a suitable way to implement a "local define?" Ian Collins <ian-news@hotmail.com> - 2014-04-07 23:00 +1200
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-07 11:31 +0200
Re: Is enum a suitable way to implement a "local define?" Les Cargill <lcargill99@comcast.com> - 2014-04-07 07:24 -0500
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-07 15:02 +0200
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-07 10:19 +0100
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-07 12:43 +0200
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-07 13:27 +0100
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-07 15:16 +0200
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-07 14:43 +0100
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-07 16:44 +0200
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-07 16:52 +0100
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-07 12:53 -0400
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-07 12:59 -0400
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-07 18:12 +0100
Re: Is enum a suitable way to implement a "local define?" Richard <rgrdev_@gmail.com> - 2014-04-07 18:27 +0100
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-08 23:22 +0100
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-08 18:44 -0400
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-09 00:22 +0100
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-08 09:39 +0200
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-08 23:27 +0100
Re: Is enum a suitable way to implement a "local define?" Ian Collins <ian-news@hotmail.com> - 2014-04-09 10:52 +1200
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-09 00:24 +0100
Re: Is enum a suitable way to implement a "local define?" Ian Collins <ian-news@hotmail.com> - 2014-04-09 11:32 +1200
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-09 08:58 +0200
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-08 19:54 -0400
Re: Is enum a suitable way to implement a "local define?" Kaz Kylheku <kaz@kylheku.com> - 2014-04-09 00:41 +0000
Re: Is enum a suitable way to implement a "local define?" glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-08 23:05 +0000
Re: Is enum a suitable way to implement a "local define?" Stephen Sprunk <stephen@sprunk.org> - 2014-04-08 18:24 -0500
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-08 19:39 -0400
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-08 22:41 -0700
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-09 09:16 +0200
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-09 07:27 -0400
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-09 15:32 +0200
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-09 08:32 -0700
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-10 11:03 +0200
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-10 07:27 -0400
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-10 14:02 +0200
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-10 08:34 -0700
Re: Is enum a suitable way to implement a "local define?" glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-10 16:36 +0000
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-10 12:58 -0400
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-09 11:36 -0400
Re: Is enum a suitable way to implement a "local define?" glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-09 18:36 +0000
Re: Is enum a suitable way to implement a "local define?" Stephen Sprunk <stephen@sprunk.org> - 2014-04-09 14:11 -0500
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-10 13:55 +0200
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-09 02:35 +0200
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-08 23:05 -0700
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-09 09:45 +0200
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-09 08:19 -0700
Re: Is enum a suitable way to implement a "local define?" Richard <rgrdev_@gmail.com> - 2014-04-10 09:08 +0100
Re: Is enum a suitable way to implement a "local define?" Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-10 02:57 -0700
Re: Is enum a suitable way to implement a "local define?" Richard <rgrdev_@gmail.com> - 2014-04-10 11:50 +0100
Re: Is enum a suitable way to implement a "local define?" Seungbeom Kim <musiphil@bawi.org> - 2014-04-10 11:37 -0700
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-10 14:52 -0400
Re: Is enum a suitable way to implement a "local define?" Kaz Kylheku <kaz@kylheku.com> - 2014-04-10 18:53 +0000
Re: Is enum a suitable way to implement a "local define?" glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-10 19:36 +0000
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-10 15:59 -0400
Re: Is enum a suitable way to implement a "local define?" glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-10 20:12 +0000
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-10 16:18 -0400
Re: Is enum a suitable way to implement a "local define?" Martin Shobe <martin.shobe@yahoo.com> - 2014-04-11 10:24 -0500
Re: Is enum a suitable way to implement a "local define?" Martin Shobe <martin.shobe@yahoo.com> - 2014-04-11 14:36 -0500
Re: Is enum a suitable way to implement a "local define?" David Thompson <dave.thompson2@verizon.net> - 2014-05-25 16:44 -0400
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-10 12:47 -0700
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-10 16:05 -0400
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-10 13:34 -0700
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-10 16:59 -0400
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-10 16:01 -0700
Re: Is enum a suitable way to implement a "local define?" Tim Rentsch <txr@alumni.caltech.edu> - 2014-04-14 21:24 -0700
Re: Is enum a suitable way to implement a "local define?" Tim Rentsch <txr@alumni.caltech.edu> - 2014-04-14 21:36 -0700
Re: Is enum a suitable way to implement a "local define?" glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-15 05:26 +0000
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-15 07:18 -0400
Re: Is enum a suitable way to implement a "local define?" Tim Rentsch <txr@alumni.caltech.edu> - 2014-04-18 09:01 -0700
Please ignore trolls Noob <root@127.0.0.1> - 2014-04-09 15:26 +0200
Re: Please ignore trolls David Brown <david.brown@hesbynett.no> - 2014-04-09 15:38 +0200
Re: Please ignore trolls James Kuyper <jameskuyper@verizon.net> - 2014-04-09 12:02 -0400
Re: Please ignore trolls Kaz Kylheku <kaz@kylheku.com> - 2014-04-09 19:18 +0000
Re: Please ignore trolls "BartC" <bc@freeuk.com> - 2014-04-10 20:18 +0100
Re: Please ignore trolls James Kuyper <jameskuyper@verizon.net> - 2014-04-10 15:49 -0400
Re: Please ignore trolls gazelle@shell.xmission.com (Kenny McCormack) - 2014-04-10 20:14 +0000
Re: Please ignore trolls "BartC" <bc@freeuk.com> - 2014-04-11 14:35 +0100
Re: Please ignore trolls Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-11 07:35 -0700
Re: Please ignore trolls "BartC" <bc@freeuk.com> - 2014-04-11 15:51 +0100
Re: Please ignore trolls Jorgen Grahn <grahn+nntp@snipabacken.se> - 2014-04-12 15:48 +0000
Re: Please ignore trolls Kaz Kylheku <kaz@kylheku.com> - 2014-04-10 21:16 +0000
Re: Please ignore trolls "BartC" <bc@freeuk.com> - 2014-04-12 15:35 +0100
Re: Please ignore trolls Keith Thompson <kst-u@mib.org> - 2014-04-09 08:03 -0700
Re: Please ignore trolls gazelle@shell.xmission.com (Kenny McCormack) - 2014-04-09 15:25 +0000
Re: Is enum a suitable way to implement a "local define?" Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-04-09 21:28 +0100
Re: Is enum a suitable way to implement a "local define?" Ian Collins <ian-news@hotmail.com> - 2014-04-10 08:39 +1200
Re: Is enum a suitable way to implement a "local define?" Kaz Kylheku <kaz@kylheku.com> - 2014-04-09 23:38 +0000
Re: Is enum a suitable way to implement a "local define?" Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-04-10 02:07 +0100
Re: Is enum a suitable way to implement a "local define?" Ike Naar <ike@iceland.freeshell.org> - 2014-04-09 05:18 +0000
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-09 08:05 -0700
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-07 08:33 -0700
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-07 17:16 +0100
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-07 11:07 -0700
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-08 09:49 +0200
Re: Is enum a suitable way to implement a "local define?" Ian Collins <ian-news@hotmail.com> - 2014-04-08 20:33 +1200
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-08 12:31 +0200
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-08 21:59 -0400
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-08 07:37 -0700
Re: Is enum a suitable way to implement a "local define?" Stephen Sprunk <stephen@sprunk.org> - 2014-04-08 08:35 -0500
Re: Is enum a suitable way to implement a "local define?" Seungbeom Kim <musiphil@bawi.org> - 2014-04-08 11:30 -0700
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-08 23:46 +0100
Re: Is enum a suitable way to implement a "local define?" Stephen Sprunk <stephen@sprunk.org> - 2014-04-08 18:28 -0500
Re: Is enum a suitable way to implement a "local define?" Seungbeom Kim <musiphil@bawi.org> - 2014-04-08 17:21 -0700
Re: Is enum a suitable way to implement a "local define?" "BartC" <bc@freeuk.com> - 2014-04-09 09:07 +0100
Re: Is enum a suitable way to implement a "local define?" James Kuyper <jameskuyper@verizon.net> - 2014-04-09 07:22 -0400
Re: Is enum a suitable way to implement a "local define?" Keith Thompson <kst-u@mib.org> - 2014-04-06 16:25 -0700
Re: Is enum a suitable way to implement a "local define?" David Brown <david.brown@hesbynett.no> - 2014-04-07 02:22 +0200
Re: Is enum a suitable way to implement a "local define?" Ike Naar <ike@iceland.freeshell.org> - 2014-04-06 06:08 +0000
Re: Is enum a suitable way to implement a "local define?" jacob navia <jacob@spamsink.net> - 2014-04-06 08:54 +0200
Re: Is enum a suitable way to implement a "local define?" partremmaps@gmail.com - 2014-04-07 23:48 -0700
Page 5 of 8 — ← Prev page 1 2 3 4 [5] 6 7 8 Next page →
| From | Richard <rgrdev_@gmail.com> |
|---|---|
| Date | 2014-04-10 11:50 +0100 |
| Message-ID | <8738hlmpan.fsf@gmail.com> |
| In reply to | #42751 |
Malcolm McLean <malcolm.mclean5@btinternet.com> writes: > On Thursday, April 10, 2014 9:08:29 AM UTC+1, Richard wrote: >> Keith Thompson <kst-u@mib.org> writes: >> >> Without the application of "const" in any shape or form it has a very >> well defined meaning. The clue is in what "variable" means and in >> addition to that real humans are capable of understanding what someone >> means when they say "a constant int" for example. >> > But programmers also say "that variable is a constant". > It's referenced by a symbol rather than a raw value, but the value doesn't change during the lifetime of > the program. However it might change if the program is compiled with > different settings. What "some programmers" say is immaterial. They "say" a lot of wrong things. This does not mean that "variable" is undefined in a general talk involving C. The fact I specifically addressed (albeit not in c.l.c laborious minutiae) your counterargument not withstanding. A variable, when discussed between to adults, is a well known entity. Those same adults would generally say "the constant X" more often than "the constant variable X" but "constant variable X" would be understood by any half sentient programmer. -- "Avoid hyperbole at all costs, its the most destructive argument on the planet" - Mark McIntyre in comp.lang.c
[toc] | [prev] | [next] | [standalone]
| From | Seungbeom Kim <musiphil@bawi.org> |
|---|---|
| Date | 2014-04-10 11:37 -0700 |
| Message-ID | <li6odd$hop$1@usenet.stanford.edu> |
| In reply to | #42721 |
On 2014-04-08 23:05, Keith Thompson wrote:
>
> It's not entirely clear what the word "variable" should mean in C. The
> standard doesn't use the term;
It's interesting to find out that C never defines the term.
I thought that C defined it in an analogous way to how C++ defines it:
"A /variable/ is introduced by the declaration ((of a reference
other than a non-static data member or)) of an object.
The variable’s name denotes the ((reference or)) object."
excluding the irrelevant parts about references (marked with (( )) by me),
of course. So a key feature of a variable would be a named, declared thing.
> instead it uses "object".
With the definition discussed above, they are not the same;
e.g. malloc(1) would create a char-sized object but not a variable.
> [...] mine is that I avoid
> using the word "variable" when there's any chance of confusion.
I agree that using the term "object" is sufficient in many cases.
--
Seungbeom Kim
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2014-04-10 14:52 -0400 |
| Message-ID | <5346E87C.30407@verizon.net> |
| In reply to | #42768 |
On 04/10/2014 02:37 PM, Seungbeom Kim wrote: > On 2014-04-08 23:05, Keith Thompson wrote: >> >> It's not entirely clear what the word "variable" should mean in C. The >> standard doesn't use the term; > > It's interesting to find out that C never defines the term. > I thought that C defined it in an analogous way to how C++ defines it: > > "A /variable/ is introduced by the declaration ((of a reference > other than a non-static data member or)) of an object. > The variable’s name denotes the ((reference or)) object." > > excluding the irrelevant parts about references (marked with (( )) by me), > of course. So a key feature of a variable would be a named, declared thing. More precisely, it is a named, declared object. Most occurrences of "variable" in the C standard are as an adjective, but every use of the term "variable" as a noun in the C standard is consistent with the C++ definition. However, most of the time the C standard uses "variable" in ways that would also apply to unnamed objects, so perhaps in C, "variable" is simply a synonym for "object"? I've informally adopted the C++ definition even in C contexts. I admit, it's a bit counterintuitive to describe something as "variable" even if it happens to be a constant.
[toc] | [prev] | [next] | [standalone]
| From | Kaz Kylheku <kaz@kylheku.com> |
|---|---|
| Date | 2014-04-10 18:53 +0000 |
| Message-ID | <20140410114854.252@kylheku.com> |
| In reply to | #42768 |
On 2014-04-10, Seungbeom Kim <musiphil@bawi.org> wrote: > On 2014-04-08 23:05, Keith Thompson wrote: >> >> It's not entirely clear what the word "variable" should mean in C. The >> standard doesn't use the term; > > It's interesting to find out that C never defines the term. > I thought that C defined it in an analogous way to how C++ defines it: > > "A /variable/ is introduced by the declaration ((of a reference > other than a non-static data member or)) of an object. > The variable’s name denotes the ((reference or)) object." ANSI Common Lisp uses "variable", and nonchalantly introduces the oxymoron "constant variable" as a normative term in its glossary: constant variable n. a variable, the value of which can never change; that is, a keyword or a named constant. ``The symbols t, nil, :direction, and most-positive-fixnum are constant variables.'' Cringe-inducing abuse of English. As adjectives, "constant" and "variable" are diametric opposites. To be constant is not to vary.
[toc] | [prev] | [next] | [standalone]
| From | glen herrmannsfeldt <gah@ugcs.caltech.edu> |
|---|---|
| Date | 2014-04-10 19:36 +0000 |
| Message-ID | <li6rsl$i02$1@speranza.aioe.org> |
| In reply to | #42771 |
Kaz Kylheku <kaz@kylheku.com> wrote: (snip) > ANSI Common Lisp uses "variable", and nonchalantly introduces the > oxymoron "constant variable" as a normative term in its glossary: > constant variable n. a variable, the value of which can never > change; that is, a keyword or a named constant. > ``The symbols t, nil, :direction, and most-positive-fixnum > are constant variables.'' > Cringe-inducing abuse of English. As adjectives, "constant" > and "variable" are diametric opposites. To be constant is > not to vary. I suppose, but in the algebra statement: X=2 do you call X a variable? Seems to me that you treat is as a variable in algebraic operations, but then consider it to have the value 2. If you do that, someone could come along later, erase the 2, write in 3, and the rest of the page would be correct, except possibly that last line where the 2 is plugged in. In computers, a more important distinction is whether memory is allocated to store it in. A Fortran PARAMETER is normally not considered a variable, and normally not in allocated memory. In Java, static final variables can't be changed, but one could go edit the file where the value was defined and put in a different one. When declared in the same class, the compiler can optimize them just like constants, and process constant expressions accordingly. From a different class, I think the compiler can't do that. There is a story from someone with an atomic clock that is good to 1 part in 1e18. There was a comment that it wouldn't lose a second over the age of the universe, where someone then commented that they didn't think the plastic on the wires would last that long. When deciding that something is constant, you have to give the time scale for it being constant. -- glen
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2014-04-10 15:59 -0400 |
| Message-ID | <5346F818.9000809@verizon.net> |
| In reply to | #42773 |
On 04/10/2014 03:36 PM, glen herrmannsfeldt wrote: ... > There is a story from someone with an atomic clock that is good > to 1 part in 1e18. There was a comment that it wouldn't lose a > second over the age of the universe, where someone then commented > that they didn't think the plastic on the wires would last that long. The big official time keepers actually use multiple atomic clocks, allowing them to take one out of service for maintenance (such as replacing the wires), and re-syncing it with the others when the maintenance is complete. I find it amazing that they can re-sync it with sufficient precision, but apparently they can do so.
[toc] | [prev] | [next] | [standalone]
| From | glen herrmannsfeldt <gah@ugcs.caltech.edu> |
|---|---|
| Date | 2014-04-10 20:12 +0000 |
| Message-ID | <li6tut$nck$1@speranza.aioe.org> |
| In reply to | #42776 |
James Kuyper <jameskuyper@verizon.net> wrote: > On 04/10/2014 03:36 PM, glen herrmannsfeldt wrote: >> There is a story from someone with an atomic clock that is good >> to 1 part in 1e18. There was a comment that it wouldn't lose a >> second over the age of the universe, where someone then commented >> that they didn't think the plastic on the wires would last that long. > The big official time keepers actually use multiple atomic clocks, > allowing them to take one out of service for maintenance (such as > replacing the wires), and re-syncing it with the others when the > maintenance is complete. I find it amazing that they can re-sync it with > sufficient precision, but apparently they can do so. But the physical clock, even if you do that, won't last 1e18s. By the way, the clock is good enough to measure the general relativistic effect from the change in gravitational field if you lift it up 0.3m (one foot for those using that system). -- glen -- glen
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2014-04-10 16:18 -0400 |
| Message-ID | <5346FC9B.40106@verizon.net> |
| In reply to | #42779 |
On 04/10/2014 04:12 PM, glen herrmannsfeldt wrote: > James Kuyper <jameskuyper@verizon.net> wrote: >> On 04/10/2014 03:36 PM, glen herrmannsfeldt wrote: > >>> There is a story from someone with an atomic clock that is good >>> to 1 part in 1e18. There was a comment that it wouldn't lose a >>> second over the age of the universe, where someone then commented >>> that they didn't think the plastic on the wires would last that long. > >> The big official time keepers actually use multiple atomic clocks, >> allowing them to take one out of service for maintenance (such as >> replacing the wires), and re-syncing it with the others when the >> maintenance is complete. I find it amazing that they can re-sync it with >> sufficient precision, but apparently they can do so. > > But the physical clock, even if you do that, won't last 1e18s. Replacing the entire physical clock is just an extreme form of "maintenance", and can be dealt with in the same fashion.
[toc] | [prev] | [next] | [standalone]
| From | Martin Shobe <martin.shobe@yahoo.com> |
|---|---|
| Date | 2014-04-11 10:24 -0500 |
| Message-ID | <li91g0$p3a$1@dont-email.me> |
| In reply to | #42773 |
On 4/10/2014 2:36 PM, glen herrmannsfeldt wrote: > Kaz Kylheku <kaz@kylheku.com> wrote: > > (snip) > >> ANSI Common Lisp uses "variable", and nonchalantly introduces the >> oxymoron "constant variable" as a normative term in its glossary: > >> constant variable n. a variable, the value of which can never >> change; that is, a keyword or a named constant. >> ``The symbols t, nil, :direction, and most-positive-fixnum >> are constant variables.'' > >> Cringe-inducing abuse of English. As adjectives, "constant" >> and "variable" are diametric opposites. To be constant is >> not to vary. > > I suppose, but in the algebra statement: > > X=2 > > do you call X a variable? Seems to me that you treat is as a variable > in algebraic operations, but then consider it to have the value 2. In mathematics, X would technically be a free variable that ranges over the class of things that makes the statement(s) it appears in true. 2 is a constant. It refers to a particular thing. In this example, the class of things X ranges over contains only a single value. It should also be noted that X does not vary between statements. You have to use the same value in all the statements even when X ranges over more than one value. In mathematics, the primary distinction between a variable and a constant is one of syntax. A variable may be bound to a quantifier while a constant may not. For example, "There exists an X such that X=2." is meaningful while "There exists a 2 such that X=2." is not. I'll let others decide what sort of impact this should have on naming the parts of a programming language. Martin Shobe
[toc] | [prev] | [next] | [standalone]
| From | Martin Shobe <martin.shobe@yahoo.com> |
|---|---|
| Date | 2014-04-11 14:36 -0500 |
| Message-ID | <li9g7h$ap8$1@dont-email.me> |
| In reply to | #42807 |
On 4/11/2014 12:15 PM, Stefan Ram wrote: > Martin Shobe <martin.shobe@yahoo.com> writes: >> In mathematics, X would technically be a free variable that ranges over > > Mathematics uses variables, but they are not mathematical > objects (they are not sets). They are objects of what I call > »metamathematics«. I define metamathematics as the field > that has the language of mathematics as its object. There is > no common, well-established, formal definition of »variable« > in mathematics, but this term is defined indeed in some > metamathematical theories. Not everything in mathematics is a set. Classes and categories are two rather well-known exceptions. Furthermore, regardless of how you define metamathematics, most mathematicians would also consider mathematical study of the language of mathematics a part of mathematics. (See mathematical logic.) > »Free variable« is a term that is used in metamathematics, > for example, in the lambda-calculus or when talking about > referential transparency. But I believe one can graduate in > mathematics without having ever heard a formal definition of > »variable« or »free variable«. The meaning of »free > variable« depends on the theory chosen. I have an idea of > what a »free variable« is in the lambda calculus, but the > same term might have a different meaning in another > metamathematical theory. Mathematics is a vast field. One can graduate in mathematics without ever having heard a formal definition of topos as well, but it's still a part of mathematics. Yes, there are details about variables that vary from language to language: which symbols are variables and which are not, are the variables typed, sorted, etc. Still, there are other things which are consistent across all formal languages: variables range over classes of things, they are symbols, they can be bound to quantifiers (though the quantifier might also have to be of the right type and/or sort), etc. Martin Shobe
[toc] | [prev] | [next] | [standalone]
| From | David Thompson <dave.thompson2@verizon.net> |
|---|---|
| Date | 2014-05-25 16:44 -0400 |
| Message-ID | <q1u1o9t9ckdvfrl2vhmofvfgl4jfak13v3@4ax.com> |
| In reply to | #42773 |
On Thu, 10 Apr 2014 19:36:53 +0000 (UTC), glen herrmannsfeldt <gah@ugcs.caltech.edu> wrote: <snip variables and constants> > In computers, a more important distinction is whether memory > is allocated to store it in. A Fortran PARAMETER is normally not > considered a variable, and normally not in allocated memory. > > In Java, static final variables can't be changed, but one could go > edit the file where the value was defined and put in a different one. > When declared in the same class, the compiler can optimize them just > like constants, and process constant expressions accordingly. > From a different class, I think the compiler can't do that. > If primitive type or String and initialized by a constant expression, the compiler can AND MUST fold it. See definition of 'constant variable' (!) in 4.12.4, and 13.1p3 and 13.4.9, in Java 7 Language Specification; I ass-u-me 8 is the same but haven't looked yet. In particular 13.4.9 says this should be used for "only values which truly are unlikely ever to change" and 13.4.10 shows a kludgy way to make the initialization of an actual constant value a non-constant expression and thus the variable not foldable. This is similar to C++'s making a namespace-scope const integer object initialized by constant expression into a constant itself. C++ doesn't require this for floating-point on the theory that runtime (target) floating-point may differ from the compiler. Java tried to require IEEE floating-point everywhere but had to back off. In order to resolve overloads and check types the java compiler already requires that all classes and interfaces referenced from and not defined in the set of source files processed in one compilation -- what I might loosely call 'net imports' -- must be available already compiled in CLASSPATH, usually though not necessarily in library jars. This means the needed 'static final' values are available.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2014-04-10 12:47 -0700 |
| Message-ID | <lnob099dc2.fsf@nuthaus.mib.org> |
| In reply to | #42768 |
Seungbeom Kim <musiphil@bawi.org> writes:
> On 2014-04-08 23:05, Keith Thompson wrote:
>> It's not entirely clear what the word "variable" should mean in C. The
>> standard doesn't use the term;
Correction: the standard does use the term, but it doesn't define it.
> It's interesting to find out that C never defines the term.
> I thought that C defined it in an analogous way to how C++ defines it:
>
> "A /variable/ is introduced by the declaration ((of a reference
> other than a non-static data member or)) of an object.
> The variable’s name denotes the ((reference or)) object."
>
> excluding the irrelevant parts about references (marked with (( )) by me),
> of course. So a key feature of a variable would be a named, declared thing.
I've seen that definition before. The problem with it is that it
makes a couple of statements about variables without actually saying
what a variable *is*. Perhaps the author(s) thought it was obvious.
The obvious meaning would be that the object *is* a "variable",
but it doesn't actually say so. A "variable" could also be some
abstract thingie that isn't the object, but whose name denotes
the object. It could even be a compile-time symbol table entry.
If I have an object declared in a recursive function, and there are
currently two running instances of the function, I have two object
with the same name. Is that one "variable" or two? How is either
answer supported by that definition?
Getting back to C (which doesn't define the term), there are plenty
of contexts where the word "variable" can be used without ambiguity.
If you say that `int x = 42;` defines a variable whose name is "x",
whose type is int, and whose initial value is 42, I have no problem
with that.
The problem is when it's used where the distinction between
declarations and objects or between const and non-const objects,
or among named objects, subobjects, and allocated objects, actually
matters. In such contexts, I think it's best to stick as closely
possible to the terms defined by the standard, and to use them with
their standard-defined meanings.
[...]
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2014-04-10 16:05 -0400 |
| Message-ID | <5346F9A4.7050902@verizon.net> |
| In reply to | #42774 |
On 04/10/2014 03:47 PM, Keith Thompson wrote: > Seungbeom Kim <musiphil@bawi.org> writes: >> On 2014-04-08 23:05, Keith Thompson wrote: >>> It's not entirely clear what the word "variable" should mean in C. The >>> standard doesn't use the term; > > Correction: the standard does use the term, but it doesn't define it. > >> It's interesting to find out that C never defines the term. >> I thought that C defined it in an analogous way to how C++ defines it: >> >> "A /variable/ is introduced by the declaration ((of a reference >> other than a non-static data member or)) of an object. >> The variable’s name denotes the ((reference or)) object." >> >> excluding the irrelevant parts about references (marked with (( )) by me), >> of course. So a key feature of a variable would be a named, declared thing. > > I've seen that definition before. The problem with it is that it > makes a couple of statements about variables without actually saying > what a variable *is*. Perhaps the author(s) thought it was obvious. True: but it uses the ISO convention of italicizing "variable" to identify that clause, despite it's defects, as the official definition of "variable". > The obvious meaning would be that the object *is* a "variable", > but it doesn't actually say so. A "variable" could also be some > abstract thingie that isn't the object, but whose name denotes > the object. It could even be a compile-time symbol table entry. I don't think that's consistent with the sentence "The variable's name denotes the object." If it's the variable's name, how can the name denote anything other than the variable? To put it another way, if the name denotes the object, and if the variable is something other than the object, how does the name qualify as being the name of that variable?
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2014-04-10 13:34 -0700 |
| Message-ID | <lnha60appo.fsf@nuthaus.mib.org> |
| In reply to | #42778 |
James Kuyper <jameskuyper@verizon.net> writes:
> On 04/10/2014 03:47 PM, Keith Thompson wrote:
>> Seungbeom Kim <musiphil@bawi.org> writes:
>>> On 2014-04-08 23:05, Keith Thompson wrote:
>>>> It's not entirely clear what the word "variable" should mean in C. The
>>>> standard doesn't use the term;
>>
>> Correction: the standard does use the term, but it doesn't define it.
>>
>>> It's interesting to find out that C never defines the term.
>>> I thought that C defined it in an analogous way to how C++ defines it:
>>>
>>> "A /variable/ is introduced by the declaration ((of a reference
>>> other than a non-static data member or)) of an object.
>>> The variable’s name denotes the ((reference or)) object."
>>>
>>> excluding the irrelevant parts about references (marked with (( )) by me),
>>> of course. So a key feature of a variable would be a named, declared thing.
>>
>> I've seen that definition before. The problem with it is that it
>> makes a couple of statements about variables without actually saying
>> what a variable *is*. Perhaps the author(s) thought it was obvious.
>
> True: but it uses the ISO convention of italicizing "variable" to
> identify that clause, despite it's defects, as the official definition
> of "variable".
Which would be fine if it were actually a definition.
>> The obvious meaning would be that the object *is* a "variable",
>> but it doesn't actually say so. A "variable" could also be some
>> abstract thingie that isn't the object, but whose name denotes
>> the object. It could even be a compile-time symbol table entry.
>
> I don't think that's consistent with the sentence "The variable's name
> denotes the object." If it's the variable's name, how can the name
> denote anything other than the variable? To put it another way, if the
> name denotes the object, and if the variable is something other than the
> object, how does the name qualify as being the name of that variable?
Hmm. If the statement "the FOO'S name is BAR" is logically
equivalent to "the name BAR denotes the FOO", then I see your point.
I'm thinking of the possibility that a "variable" is an abstract
entity that has an attribute called its "name", and that that name
*when used in a program* denotes the object.
If the intent is that the variable is the object, then the definition
should just say so. As it stands, the wording "A variable is
introduced by the declaration ... of an object" implies, at least
to me, that the variable and the object are two different things.
I think I recall someone claiming that a "variable" is the *name*
of an object, not the object itself -- but the phrase "The variable's
name" is inconsistent with that.
Summary: IMHO we all know what a variable is in some cases, we'll
probably never all agree on what is or is not a variable in all cases,
and the C++ standard does a poor job of defining the term.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2014-04-10 16:59 -0400 |
| Message-ID | <5347064D.1010307@verizon.net> |
| In reply to | #42784 |
On 04/10/2014 04:34 PM, Keith Thompson wrote: > James Kuyper <jameskuyper@verizon.net> writes: ... >> True: but it uses the ISO convention of italicizing "variable" to >> identify that clause, despite it's defects, as the official definition >> of "variable". > > Which would be fine if it were actually a definition. Agreed. It could certainly be improved. ... >> I don't think that's consistent with the sentence "The variable's name >> denotes the object." If it's the variable's name, how can the name >> denote anything other than the variable? To put it another way, if the >> name denotes the object, and if the variable is something other than the >> object, how does the name qualify as being the name of that variable? > > Hmm. If the statement "the FOO'S name is BAR" is logically > equivalent to "the name BAR denotes the FOO", then I see your point. Yes, that's what I'm saying. The argument isn't quite airtight, but it seems good enough to me. ... > Summary: IMHO we all know what a variable is in some cases, we'll > probably never all agree on what is or is not a variable in all cases, > and the C++ standard does a poor job of defining the term. While reviewing the usage of "variable" in the C standard, I came across several places where I'm fairly certain that what it said was intended to apply to unnamed objects as well as named ones - mostly in the context of text that is new in C2011. Either "variable" should be replaced by "object" in those cases, or C should formally adopt a definition for "variable" that's inconsistent with the C++ definition. I don't think we can afford to leave that issue open.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2014-04-10 16:01 -0700 |
| Message-ID | <lnd2goaiwn.fsf@nuthaus.mib.org> |
| In reply to | #42787 |
James Kuyper <jameskuyper@verizon.net> writes:
> On 04/10/2014 04:34 PM, Keith Thompson wrote:
>> James Kuyper <jameskuyper@verizon.net> writes:
> ...
>>> True: but it uses the ISO convention of italicizing "variable" to
>>> identify that clause, despite it's defects, as the official definition
>>> of "variable".
>>
>> Which would be fine if it were actually a definition.
>
> Agreed. It could certainly be improved.
>
> ...
>>> I don't think that's consistent with the sentence "The variable's name
>>> denotes the object." If it's the variable's name, how can the name
>>> denote anything other than the variable? To put it another way, if the
>>> name denotes the object, and if the variable is something other than the
>>> object, how does the name qualify as being the name of that variable?
>>
>> Hmm. If the statement "the FOO'S name is BAR" is logically
>> equivalent to "the name BAR denotes the FOO", then I see your point.
>
> Yes, that's what I'm saying. The argument isn't quite airtight, but it
> seems good enough to me.
>
> ...
>> Summary: IMHO we all know what a variable is in some cases, we'll
>> probably never all agree on what is or is not a variable in all cases,
>> and the C++ standard does a poor job of defining the term.
>
> While reviewing the usage of "variable" in the C standard, I came across
> several places where I'm fairly certain that what it said was intended
> to apply to unnamed objects as well as named ones - mostly in the
> context of text that is new in C2011. Either "variable" should be
> replaced by "object" in those cases, or C should formally adopt a
> definition for "variable" that's inconsistent with the C++ definition. I
> don't think we can afford to leave that issue open.
Looking at the uses of the word "variable" in the C++ standard, I see at
least one that clearly implies that a "variable" is, or at the very
least can be, an object. C++11 3.2 (One definition rule), paragraph 2:
A variable whose name appears as a potentially-evaluated
expression is *odr-used* unless it is an object that satisfies
the requirements for appearing in a constant expression and
the lvalue-to-rvalue conversion is immediately applied.
But the definition makes it somewhat clear that a variable is a named
object, and the C standard doesn't use it that way consistently.
(I also ran across a note, N1570 6.7.6.1p3, where the standard conflates
"const" and "constant". At least it's non-normative.)
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Tim Rentsch <txr@alumni.caltech.edu> |
|---|---|
| Date | 2014-04-14 21:24 -0700 |
| Message-ID | <kfnlhv7cj9j.fsf@x-alumni2.alumni.caltech.edu> |
| In reply to | #42774 |
Keith Thompson <kst-u@mib.org> writes: > Seungbeom Kim <musiphil@bawi.org> writes: >> On 2014-04-08 23:05, Keith Thompson wrote: >>> It's not entirely clear what the word "variable" should mean in C. The >>> standard doesn't use the term; > > Correction: the standard does use the term, but it doesn't define it. > >> It's interesting to find out that C never defines the term. I >> thought that C defined it in an analogous way to how C++ defines >> it: >> >> "A /variable/ is introduced by the declaration ((of a reference >> other than a non-static data member or)) of an object. >> The variable?s name denotes the ((reference or)) object." >> >> excluding the irrelevant parts about references (marked with (( )) >> by me), of course. So a key feature of a variable would be a named, >> declared thing. > > I've seen that definition before. The problem with it is that it > makes a couple of statements about variables without actually saying > what a variable *is*. Perhaps the author(s) thought it was obvious. > > The obvious meaning would be that the object *is* a "variable", > but it doesn't actually say so. A "variable" could also be some > abstract thingie that isn't the object, but whose name denotes the > object. It could even be a compile-time symbol table entry. > > If I have an object declared in a recursive function, and there are > currently two running instances of the function, I have two object > with the same name. Is that one "variable" or two? How is either > answer supported by that definition? The C++ standard defines the term "variable" so that there is a single word that applies to both references and non-references. It's there purely for convenience, and has no bearing on the terminology issue here. > Getting back to C (which doesn't define the term), there are plenty > of contexts where the word "variable" can be used without ambiguity. > If you say that `int x = 42;` defines a variable whose name is "x", > whose type is int, and whose initial value is 42, I have no problem > with that. > > The problem is when it's used where the distinction between > declarations and objects or between const and non-const objects, > or among named objects, subobjects, and allocated objects, actually > matters. In such contexts, I think it's best to stick as closely > possible to the terms defined by the standard, and to use them with > their standard-defined meanings. Personally I don't see anything wrong with using the term "variable". I agree it is used in several different ways, and it does have more than one meaning depending on context. But these ambiguities can be sorted out easily just by adding some qualifying phrases, eg, "possibly non-modifiable variable". Furthermore, when what we're talking about is compile time properties, there isn't really a good alternative. The Standard does define the term "object", but "object" is clearly wrong here, because objects don't exist at compile time, only at run time. This result is not some accident of wording but spelled out quite explicitly in 6.2.4, "Storage durations of objects". We might talk about "a declared identifier which at runtime will designate an object" (perhaps of some particular storage duration), but that seems rather cumbersone, does it not? Even when people disagree on exactly what properties a "variable" should have, I don't anyone really misunderstands the term. If/when it's important to disambiguate the different usages I think it's easy enough to do that.
[toc] | [prev] | [next] | [standalone]
| From | Tim Rentsch <txr@alumni.caltech.edu> |
|---|---|
| Date | 2014-04-14 21:36 -0700 |
| Message-ID | <kfnha5vcip4.fsf@x-alumni2.alumni.caltech.edu> |
| In reply to | #42721 |
Keith Thompson <kst-u@mib.org> writes: > "const" in C simply means "read-only". "Constant" refers to > something that can (and must) be evaluated at compile time, as > in "integer constant" (what some languages call an "integer > literal") or a "constant expression" (an expression that can be > used as if it were a literal). Not exactly right. An address constant is a form of constant expression, but it can't be evaluated at compile time. It is evaluated before program execution begins but AFAIK it is not required to be fixed even after linking is done. That is, different runs of the same executable might produce different values for an "address constant". I'm pretty sure the Standard means for an address constant to have any particular value only within a single execution of a compiled and linked program, not necessarily for all executions (of the same program image).
[toc] | [prev] | [next] | [standalone]
| From | glen herrmannsfeldt <gah@ugcs.caltech.edu> |
|---|---|
| Date | 2014-04-15 05:26 +0000 |
| Message-ID | <liiftu$rok$1@speranza.aioe.org> |
| In reply to | #42946 |
Tim Rentsch <txr@alumni.caltech.edu> wrote: > Keith Thompson <kst-u@mib.org> writes: >> "const" in C simply means "read-only". "Constant" refers to >> something that can (and must) be evaluated at compile time, as >> in "integer constant" (what some languages call an "integer >> literal") or a "constant expression" (an expression that can be >> used as if it were a literal). > Not exactly right. An address constant is a form of constant > expression, but it can't be evaluated at compile time. It is > evaluated before program execution begins but AFAIK it is not > required to be fixed even after linking is done. I haven't heard the term "address constant" used so much outside of S/360 (and successor) assembler programming. > That is, different runs of the same executable might > produce different values for an "address constant". >I'm pretty sure the Standard means for an address constant > to have any particular value only within a single execution > of a compiled and linked program, not necessarily for > all executions (of the same program image). For S/360 address constants, which may or may not generalize to other systems, they can be either absolute or relocatable. Absolute address constants don't change on relocation, and relocatable ones do (maybe that is too obvious). Pointer constant sounds more C-like to me. The assembler stores the offset into the CSECT, the linker updates that as it relocates it within the load module, and program fetch updates again as it is being loaded into memory. To get back to C, some things are required to be known at compile time, and so compile time constants. Among others, C doesn't require subtraction between pointers to different objects to have a defined value. Subtracting two constant pointers to different objects, then, should not be a compile time constant, even though the compilers for some systems could probably compute one. I presume C can compute a constant absolute expression with pointers to the same object. Another interesting feature of the OS/360 assembler that I haven't known in others is that the relocation factor, in addition to the usual 0 or 1, can also be -1 or 2. In C terms, you can compute the value of -pointer, 2*pointer, or pointer1+pointer2 as an address constant. C doesn't allow for that. -- glen
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2014-04-15 07:18 -0400 |
| Message-ID | <lij4hk$ecf$1@dont-email.me> |
| In reply to | #42948 |
On 04/15/2014 01:26 AM, glen herrmannsfeldt wrote: > Tim Rentsch <txr@alumni.caltech.edu> wrote: ... >> Not exactly right. An address constant is a form of constant >> expression, but it can't be evaluated at compile time. It is >> evaluated before program execution begins but AFAIK it is not >> required to be fixed even after linking is done. <nit-pick> Some address constants (namely, null pointers) can be evaluated at compile time.</nit-pick> > I haven't heard the term "address constant" used so much outside > of S/360 (and successor) assembler programming. "An _address constant_ is a null pointer, a pointer to an lvalue designating an object of static storage duration, or a pointer to a function designator; ..." (6.6p9). The phrase "address constant" is italicised, indicating that this sentence constitutes the definition of that phrase. ... > For S/360 address constants, which may or may not generalize to > other systems, they can be either absolute or relocatable. In C, address constants are not required to be absolute, nor are they required to be relocatable - that's an implementation detail outside the scope of the C standard. > Absolute address constants don't change on relocation, and > relocatable ones do (maybe that is too obvious). I think it is - but "obvious" depends upon the reader. > Pointer constant sounds more C-like to me. The C standard says otherwise. -- James Kuyper
[toc] | [prev] | [next] | [standalone]
Page 5 of 8 — ← Prev page 1 2 3 4 [5] 6 7 8 Next page →
Back to top | Article view | comp.lang.c
csiph-web