Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.os.development > #8344 > unrolled thread
| Started by | "Alexei A. Frounze" <alexfrunews@gmail.com> |
|---|---|
| First post | 2015-07-11 20:39 -0700 |
| Last post | 2015-09-16 10:17 -0700 |
| Articles | 20 on this page of 88 — 7 participants |
Back to article view | Back to alt.os.development
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-11 20:39 -0700
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-12 04:24 -0400
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-12 03:17 -0700
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-13 03:28 -0400
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-07-12 19:12 +0100
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-12 17:09 -0700
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-07-13 11:10 +0100
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-13 23:13 -0400
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-07-14 09:08 +0100
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-15 02:23 -0400
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-08-15 02:12 -0700
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-06 15:54 -0700
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-07 12:19 -0700
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-07 13:30 -0700
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-09 19:38 -0700
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-09 19:49 -0700
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-09 20:58 -0700
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-10 01:45 -0700
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-10 10:45 -0700
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-10 23:20 -0700
Re: Smaller C "wolfgang kern" <nowhere@never.at> - 2015-09-11 09:26 +0200
Re: Smaller C "wolfgang kern" <nowhere@never.at> - 2015-09-11 09:50 +0200
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-11 00:58 -0700
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-11 17:38 -0400
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-11 23:39 +0100
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-11 19:39 -0400
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-12 11:22 +0100
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-12 02:21 -0700
Re: Smaller C "wolfgang kern" <nowhere@never.at> - 2015-09-12 21:53 +0200
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 03:37 -0400
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-13 09:49 +0100
Re: Smaller C "wolfgang kern" <nowhere@never.at> - 2015-09-13 12:58 +0200
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 07:32 -0400
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-13 19:05 +0100
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-14 13:19 +0100
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-15 00:01 -0400
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-18 14:48 +0100
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-26 16:23 -0400
Re: Smaller C James Harris <james.harris.1@gmail.com> - 2015-09-27 00:23 +0100
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-26 16:37 -0700
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-27 10:17 -0400
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-27 10:24 -0400
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-27 10:46 -0400
Re: Smaller C James Harris <james.harris.1@gmail.com> - 2016-01-16 16:14 +0000
Re: Smaller C Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-01-23 13:20 -0500
Re: Smaller C James Harris <james.harris.1@gmail.com> - 2016-01-27 13:52 +0000
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-27 10:28 -0400
Re: Smaller C James Harris <james.harris.1@gmail.com> - 2016-01-16 16:31 +0000
Re: Smaller C Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-01-23 13:20 -0500
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-18 16:21 +0100
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-20 17:25 -0700
Re: Smaller C "wolfgang kern" <nowhere@never.at> - 2015-09-13 12:43 +0200
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-13 09:21 +0100
Re: Smaller C "wolfgang kern" <nowhere@never.at> - 2015-09-13 13:02 +0200
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-13 19:09 +0100
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-11 13:32 -0700
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-11 18:51 -0400
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-11 18:16 -0700
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-12 02:36 -0700
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-12 11:56 +0100
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 03:45 -0400
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-13 10:28 +0100
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-13 02:53 -0700
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 11:17 -0400
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-13 16:54 -0700
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 21:39 -0400
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-13 20:31 -0700
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 09:03 -0400
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-13 19:48 +0100
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 21:33 -0400
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-14 23:17 +0100
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-20 17:37 -0400
Re: Smaller C "James Harris" <james.harris.1@gmail.com> - 2015-09-20 23:46 +0100
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-11 21:37 -0700
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-11 22:29 -0700
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-12 03:25 -0700
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-12 11:18 -0700
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-12 11:39 -0700
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 03:47 -0400
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 11:31 -0400
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-13 02:00 -0700
Re: Smaller C "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-13 11:31 -0400
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-13 09:15 -0700
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-12 02:45 -0700
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-12 10:55 -0700
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-15 19:23 -0700
Re: Smaller C "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-09-16 03:03 -0700
Re: Smaller C "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-09-16 10:17 -0700
Page 2 of 5 — ← Prev page 1 [2] 3 4 5 Next page →
| From | "wolfgang kern" <nowhere@never.at> |
|---|---|
| Date | 2015-09-11 09:26 +0200 |
| Message-ID | <mstvn8$qt$1@speranza.aioe.org> |
| In reply to | #8739 |
Alex and Ben in discussion... [...] > Let me copy that example one more time so it's not lost: > > int * volatile * const * const volatile pppi; > > These consts and volatiles aren't redundant. Generally, it's not > just a matter of taste of where to put them. > > What does the above declaration declare? > > Let's read it right to left: > > pppi: pointer (itself being const and volatile) to > pointer (which is constant) to > pointer (which is volatile) to > int. > > You can also make that int (the base type) const and/or volatile: > > const volatile int * volatile * const * const volatile pppi; > > and in the base type part it is permitted to put these modifiers > before or after the type they modify: > > int const volatile * volatile * const * const volatile pppi; > > Still with me? ... No intention to interrupt your discussion, but this caught my eye. It took me a while to figure what could be behind this example. I'd interprete a standalone 'volatile constant int' as 'push imm32' and the constant&volatile ptr[constant ptr[volatile ptr]] as: push imm32 ;ptr01 is a volatile constant mov esi,[esp] ;ptr02 is constant if you keep esi alive. push [esi] ;ptr03 may vanish after mov eax,[esi] ;int = [ptr01[ptr02[ptr03]]] add esp,8 ;get rid of the volatiles am I wrong ? perhaps it's just a matter of used terms. __ wolfgang
[toc] | [prev] | [next] | [standalone]
| From | "wolfgang kern" <nowhere@never.at> |
|---|---|
| Date | 2015-09-11 09:50 +0200 |
| Message-ID | <msu14t$3qd$1@speranza.aioe.org> |
| In reply to | #8740 |
I wrote and have to correct it yet: ... > It took me a while to figure what could be behind this example. > I'd interprete a standalone 'volatile constant int' as 'push imm32' > and the constant&volatile ptr[constant ptr[volatile ptr]] as: > push imm32 ;ptr01 is a volatile constant mov esi,[esp] ;ptr02 is constant if you keep esi alive. mov ecx [esi] ;ptr03 may vanish after mov eax,[ecx] ;int = [ptr01[ptr02[ptr03]]] add esp,4 ;get rid of the volatile > am I wrong ? > > perhaps it's just a matter of used terms. > __ > wolfgang >
[toc] | [prev] | [next] | [standalone]
| From | "Alexei A. Frounze" <alexfrunews@gmail.com> |
|---|---|
| Date | 2015-09-11 00:58 -0700 |
| Message-ID | <1975728e-a1fc-4489-9150-112f7e07cf83@googlegroups.com> |
| In reply to | #8740 |
On Friday, September 11, 2015 at 12:26:36 AM UTC-7, wolfgang kern wrote: > Alex and Ben in discussion... > > [...] > > Let me copy that example one more time so it's not lost: > > > > int * volatile * const * const volatile pppi; > > > > These consts and volatiles aren't redundant. Generally, it's not > > just a matter of taste of where to put them. > > > > What does the above declaration declare? > > > > Let's read it right to left: > > > > pppi: pointer (itself being const and volatile) to > > pointer (which is constant) to > > pointer (which is volatile) to > > int. > > > > You can also make that int (the base type) const and/or volatile: > > > > const volatile int * volatile * const * const volatile pppi; > > > > and in the base type part it is permitted to put these modifiers > > before or after the type they modify: > > > > int const volatile * volatile * const * const volatile pppi; > > > > Still with me? > ... > > No intention to interrupt your discussion, but this caught my eye. > > It took me a while to figure what could be behind this example. > I'd interprete a standalone 'volatile constant int' as 'push imm32' Unless we're talking about variable length arrays, a variable declaration in C has no code associated with it, it only reserves data space. It is only when you start using a declared variable or when you initialize it on the stack code comes in. So, technically, you can't make the above interpretation. Or you need to clarify your language. Further, in C a combination of both const and volatile means that you aren't allowed to modify it, but it may change nonetheless. Think of something like a read-only register of a memory-mapped device. So, push imm is not correct in this case if you're going to use the fixed value imm. You need to make a memory read and use what you read. > and the constant&volatile ptr[constant ptr[volatile ptr]] as: > > push imm32 ;ptr01 is a volatile constant > mov esi,[esp] ;ptr02 is constant if you keep esi alive. > push [esi] ;ptr03 may vanish after > mov eax,[esi] ;int = [ptr01[ptr02[ptr03]]] > add esp,8 ;get rid of the volatiles > > am I wrong ? You're close. The simplest way to evaluate ***pppi is to make 3 memory reads, each producing an address for the next read and then read the actual integer. Alex
[toc] | [prev] | [next] | [standalone]
| From | "Rod Pemberton" <boo@fasdfrewar.cdm> |
|---|---|
| Date | 2015-09-11 17:38 -0400 |
| Message-ID | <op.x4tid3ygyfako5@localhost> |
| In reply to | #8742 |
On Fri, 11 Sep 2015 03:58:57 -0400, Alexei A. Frounze <alexfrunews@gmail.com> wrote: > On Friday, September 11, 2015 at 12:26:36 AM UTC-7, wolfgang kern wrote: >> No intention to interrupt your discussion, but this caught my eye. >> >> It took me a while to figure what could be behind this example. >> I'd interprete a standalone 'volatile constant int' as 'push imm32' > > Unless we're talking about variable length arrays, a variable > declaration in C has no code associated with it, it only > reserves data space. It is only when you start using a declared > variable or when you initialize it on the stack code comes in. > So, technically, you can't make the above interpretation. Well, technically, C doesn't require a stack, so to be proper ... s/on the stack/"" > Or you need to clarify your language. Ditto. See above. ;-) AIR, Wolfgang doesn't program in C, ... yet. ;-) He uses hex assembly. I'm glad to see he's learning a bit. Rod Pemberton -- Just how many texting and calendar apps does humanity need?
[toc] | [prev] | [next] | [standalone]
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2015-09-11 23:39 +0100 |
| Message-ID | <msvl3m$3e0$1@dont-email.me> |
| In reply to | #8744 |
"Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message news:op.x4tid3ygyfako5@localhost... ... > s/on the stack/"" What notation is that, Rod? One of your own? Have you actually implemented it or explained it somewhere? ;-( James
[toc] | [prev] | [next] | [standalone]
| From | "Rod Pemberton" <boo@fasdfrewar.cdm> |
|---|---|
| Date | 2015-09-11 19:39 -0400 |
| Message-ID | <op.x4tnz7q0yfako5@localhost> |
| In reply to | #8745 |
On Fri, 11 Sep 2015 18:39:33 -0400, James Harris <james.harris.1@gmail.com> wrote: > "Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message > news:op.x4tid3ygyfako5@localhost... >> s/on the stack/"" > > What notation is that, Rod? One of your own? Have you actually > implemented it or explained it somewhere? ;-( Que? Haven't I seen you use that syntax too? I'm pretty sure I had both here and on comp.lang.misc ... AIR, you you pointed out once before that it needs a / at the end. It's from VI. Specifically, it's the last part of an EX (or ED) line-editor command within VI used to "substitute" text, i.e., replace. I used "" to represent an empty string since this was a Usenet text message and I thought that would be more clear. E.g., :g/pattern/action :g/^/s/on the stack/wrong answer/ I.e., that 'g' globally finds every line with a '^' start of line, then 's' substitutes "wrong answer" for "on the stack" once per line in every line where the '^' start of line was found. :g/^/s/on the stack// The empty field for the replacement text in latter EX line deletes the text. If there were multiple instances per line to delete, you'd globally replace per line: :g/^/s/on the stack//g VI with the EX (or ED) line-editor commands has the ability to match the start or end of line. This is very useful for creating scripts, .bat's, or processing logs, or files with many short lines of text. Other text or word processors can't do this. So, it was just used to say replace this with that, but to delete in this instance. Rod Pemberton -- Just how many texting and calendar apps does humanity need?
[toc] | [prev] | [next] | [standalone]
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2015-09-12 11:22 +0100 |
| Message-ID | <mt0uad$eeb$1@dont-email.me> |
| In reply to | #8748 |
"Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message news:op.x4tnz7q0yfako5@localhost... > On Fri, 11 Sep 2015 18:39:33 -0400, James Harris > <james.harris.1@gmail.com> wrote: > >> "Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message >> news:op.x4tid3ygyfako5@localhost... > >>> s/on the stack/"" >> >> What notation is that, Rod? One of your own? Have you actually >> implemented it or explained it somewhere? ;-( > > Que? Haven't I seen you use that syntax too? I'm pretty > sure I had both here and on comp.lang.misc ... AIR, you > you pointed out once before that it needs a / at the end. Oh, with a / on the end I understand it but since you keep omitting it and, in this case, placed a pair of double quotes there, I wasn't sure if it was something you had made up - e.g. one that terminated at the end of line or at the first space character or something else. > It's from VI. Specifically, it's the last part of an EX > (or ED) line-editor command within VI used to "substitute" > text, i.e., replace. I used "" to represent an empty > string since this was a Usenet text message and I thought > that would be more clear. > > E.g., > > :g/pattern/action > > :g/^/s/on the stack/wrong answer/ > > I.e., that 'g' globally finds every line with a '^' start > of line, then 's' substitutes "wrong answer" for "on the stack" > once per line in every line where the '^' start of line was > found. > > :g/^/s/on the stack// > > The empty field for the replacement text in latter EX line > deletes the text. > > If there were multiple instances per line to delete, you'd > globally replace per line: > > :g/^/s/on the stack//g > > VI with the EX (or ED) line-editor commands has the ability > to match the start or end of line. This is very useful > for creating scripts, .bat's, or processing logs, or files > with many short lines of text. Other text or word processors > can't do this. Thanks, I didn't know about the initial g. That's useful. When in vi if I want to replace on every line with a match I use 1;$s/from/to/ The 1;$ before the s specifies line 1 to line $ (which is the last line of the file). But I see that g can be used much more widely. Cool! I use the substitute command mainly in sed. For example, cat file | sed "s/from/to/" That also allows a trailing g if needed. > So, it was just used to say replace this with that, but > to delete in this instance. So in reality you would have written s/on the stack// but you wrote s/on the stack/"" for Usenet readers? I expect anyone who knows about the notation would understand the proper form. James
[toc] | [prev] | [next] | [standalone]
| From | "Alexei A. Frounze" <alexfrunews@gmail.com> |
|---|---|
| Date | 2015-09-12 02:21 -0700 |
| Message-ID | <3dbae649-580b-4aad-a96f-fe6ae4f32e7f@googlegroups.com> |
| In reply to | #8744 |
On Friday, September 11, 2015 at 2:38:12 PM UTC-7, Rod Pemberton wrote: > On Fri, 11 Sep 2015 03:58:57 -0400, Alexei A. Frounze <...@gmail.com> wrote: > > > On Friday, September 11, 2015 at 12:26:36 AM UTC-7, wolfgang kern wrote: > > >> No intention to interrupt your discussion, but this caught my eye. > >> > >> It took me a while to figure what could be behind this example. > >> I'd interprete a standalone 'volatile constant int' as 'push imm32' > > > > Unless we're talking about variable length arrays, a variable > > declaration in C has no code associated with it, it only > > reserves data space. It is only when you start using a declared > > variable or when you initialize it on the stack code comes in. > > So, technically, you can't make the above interpretation. > > Well, technically, C doesn't require a stack, so to be proper ... > > s/on the stack/"" > > > Or you need to clarify your language. > > Ditto. See above. ;-) I think stack is something more native and dear to most of us than automatic storage. :) Alex
[toc] | [prev] | [next] | [standalone]
| From | "wolfgang kern" <nowhere@never.at> |
|---|---|
| Date | 2015-09-12 21:53 +0200 |
| Message-ID | <mt1vt9$vqp$1@speranza.aioe.org> |
| In reply to | #8744 |
Rod Pemberton mentioned: ... > AIR, Wolfgang doesn't program in C, ... yet. ;-) You can be sure that I never ever will start coding in any HLL ! > He uses hex assembly. I'm glad to see he's learning a bit. Yeah, I learned that 'const' doesn't mean a 'constant'. I find it really interesting that a lot of misleading terms are widely used in all HLL, perhaps just meant to hide functionality from ignorant peepers like me :) __ wolfgang
[toc] | [prev] | [next] | [standalone]
| From | "Rod Pemberton" <boo@fasdfrewar.cdm> |
|---|---|
| Date | 2015-09-13 03:37 -0400 |
| Message-ID | <op.x4v4snbyyfako5@localhost> |
| In reply to | #8764 |
On Sat, 12 Sep 2015 15:53:48 -0400, wolfgang kern <nowhere@never.at> wrote: > Rod Pemberton mentioned: >> AIR, Wolfgang doesn't program in C, ... yet. ;-) > > You can be sure that I never ever will start coding in any HLL ! So, you've never used a HLL? You've never even used BASIC or Pascal or Fortran? How did you manage that? Usually school or work wants you to use some HLL ... What if you design one? >> He uses hex assembly. I'm glad to see he's learning a bit. > > Yeah, I learned that 'const' doesn't mean a 'constant'. A 'static' variable doesn't mean 'constant' either and can change ... If fact, 'static' has multiple meanings depending on where it's used. If my old copy of Harbison & Steele is correct, it has four meanings. Since I almost never use 'static', I had to look that up. That's just one of many such situations with C. A quote or text string is a string literal. A character is a character constant. Like everything else in life, there is a "learning curve," which means it takes some time and experience. :-) > I find it really interesting that a lot of misleading terms are > widely used in all HLL, perhaps just meant to hide functionality > from ignorant peepers like me :) Haven't you ever needed another name or word for a subroutine or label but were unable to think of one? Sometimes, there are no useable names remaining. 'loop' is an instruction. What other words are there for 'loop' in English? There's 'loop'. That's it. British English has 'roundabout' which is a type of backwards loop. C came up with 'for' 'while' 'do' ... or perhaps borrowed them from other languages. 'repeat' might work, but nothing accurately represents 'loop'. I'd panic if I ever had to navigate this in England: https://en.wikipedia.org/wiki/Magic_Roundabout_%28Swindon%29 I sometimes can't think of another appropriate name ... I'm naming them 'stuff' and 'things' and 'whatever', like 'do_stuff' 'fill_things' and 'emit_whatever'. Yes, I use completely vague names so I'm not wasting time thinking of good names. Or, I start labeling them with a letter and hex: l0000, l0001, ... lffff. If I exceed the number for 'l' then it's 'm': m0000, m0001, ... and so on. Rod Pemberton -- Just how many texting and calendar apps does humanity need?
[toc] | [prev] | [next] | [standalone]
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2015-09-13 09:49 +0100 |
| Message-ID | <mt3d77$boq$1@dont-email.me> |
| In reply to | #8765 |
"Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message news:op.x4v4snbyyfako5@localhost... > On Sat, 12 Sep 2015 15:53:48 -0400, wolfgang kern <nowhere@never.at> > wrote: > >> Rod Pemberton mentioned: > >>> AIR, Wolfgang doesn't program in C, ... yet. ;-) >> >> You can be sure that I never ever will start coding in any HLL ! > > So, you've never used a HLL? You've never even used BASIC or Pascal > or Fortran? How did you manage that? Usually school or work wants > you to use some HLL ... What if you design one? Wolfgang design an HLL? That would be interesting, for sure. Perhaps there should be a rule that people who hate HLLs and love assembly should get to design at least one HLL in their lives. The result might be novel and welcome to anyone who values efficiency. >>> He uses hex assembly. I'm glad to see he's learning a bit. >> >> Yeah, I learned that 'const' doesn't mean a 'constant'. > > A 'static' variable doesn't mean 'constant' either and can change ... > If fact, 'static' has multiple meanings depending on where it's used. > If my old copy of Harbison & Steele is correct, it has four meanings. Perhaps H&S are splitting a static function from a static variable to make one concept into two (even though that would still only make three concepts rather than four)? They did that with the switch keyword we discussed a while ago, thus making the concept harder to grasp - in the guise of making it easier. :-( > Since I almost never use 'static', I had to look that up. Since you mentioned four uses I also had to look it up but could only find the two I mentioned. Again, H&S multiplying necessities...? https://en.wikipedia.org/wiki/Occam%27s_razor (Sorry to anyone who likes H&S for my negative view of their tome. However, from the little I have heard of it it seems to continually make properly learning C harder rather than easier. I remember heading about another C author, one of the Schildts, possibly, who wrote a book on the C standard that was so riddled with errors both small and conceptual that it actually prevented readers from learning C. Yet it became a big seller. There's not necessarily a link between popularity and helpfulness.) ... > Haven't you ever needed another name or word for a subroutine > or label but were unable to think of one? > > Sometimes, there are no useable names remaining. 'loop' is an > instruction. What other words are there for 'loop' in English? > There's 'loop'. That's it. British English has 'roundabout' > which is a type of backwards loop. I have to say from this side of the pond I wouldn't equate roundabout with loop. > C came up with 'for' 'while' > 'do' ... or perhaps borrowed them from other languages. 'repeat' > might work, but nothing accurately represents 'loop'. FOR was from mathematics, I think. DO from Fortran sounds like something that is to be done once, not repeated (although C's DO ... WHILE sounds more apt). REPEAT makes more sense, though. > I'd panic if I ever had to navigate this in England: > https://en.wikipedia.org/wiki/Magic_Roundabout_%28Swindon%29 Yeah, that looks a bit crazy. > I sometimes can't think of another appropriate name ... I'm > naming them 'stuff' and 'things' and 'whatever', like 'do_stuff' > 'fill_things' and 'emit_whatever'. Yes, I use completely vague > names so I'm not wasting time thinking of good names. Or, I > start labeling them with a letter and hex: l0000, l0001, ... > lffff. If I exceed the number for 'l' then it's 'm': m0000, > m0001, ... and so on. At least in well-structured HLL code we need far fewer labels. Poor old Wolfgang has to label every jump target. ;-) James
[toc] | [prev] | [next] | [standalone]
| From | "wolfgang kern" <nowhere@never.at> |
|---|---|
| Date | 2015-09-13 12:58 +0200 |
| Message-ID | <mt3l4v$6o5$2@speranza.aioe.org> |
| In reply to | #8770 |
James Harris said in part: ... > At least in well-structured HLL code we need far fewer labels. > Poor old Wolfgang has to label every jump target. ;-) No, labels arent needed here, my call/jump targets are just addressed by their offset. __ wolfgang
[toc] | [prev] | [next] | [standalone]
| From | "Rod Pemberton" <boo@fasdfrewar.cdm> |
|---|---|
| Date | 2015-09-13 07:32 -0400 |
| Message-ID | <op.x4wfnyq1yfako5@localhost> |
| In reply to | #8770 |
On Sun, 13 Sep 2015 04:49:27 -0400, James Harris <james.harris.1@gmail.com> wrote: >> A 'static' variable doesn't mean 'constant' either and can change ... >> If fact, 'static' has multiple meanings depending on where it's used. >> If my old copy of Harbison & Steele is correct, it has four meanings. > > Perhaps H&S are splitting a static function from a static variable to > make one concept into two (even though that would still only make three > concepts rather than four)? Well, I'll let you decide. (paraphrased) 'static' 1) on a function, used to not export the function name to the linker 2) on a function declaration, used to indicate the function will be defined later in the file with storage class 'static' 3) on data declarations, use to not export the declaration to the linker 4) on variables, used to indicate static extent instead of local extent, i.e., auto Rod Pemberton -- Just how many texting and calendar apps does humanity need?
[toc] | [prev] | [next] | [standalone]
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2015-09-13 19:05 +0100 |
| Message-ID | <mt4dpo$6es$1@dont-email.me> |
| In reply to | #8781 |
"Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message news:op.x4wfnyq1yfako5@localhost... > On Sun, 13 Sep 2015 04:49:27 -0400, James Harris > <james.harris.1@gmail.com> wrote: > >>> A 'static' variable doesn't mean 'constant' either and can change >>> ... >>> If fact, 'static' has multiple meanings depending on where it's >>> used. >>> If my old copy of Harbison & Steele is correct, it has four >>> meanings. >> >> Perhaps H&S are splitting a static function from a static variable to >> make one concept into two (even though that would still only make >> three >> concepts rather than four)? > > Well, I'll let you decide. (paraphrased) OK > 'static' > > 1) on a function, used to not export the function name to the linker > 2) on a function declaration, used to indicate the function will be > defined later in the file with storage class 'static' > 3) on data declarations, use to not export the declaration to the > linker > 4) on variables, used to indicate static extent instead of local > extent, > i.e., auto Well, 1 and 3 are the same. 4 is the other use. 2 is 'interesting'! James
[toc] | [prev] | [next] | [standalone]
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2015-09-14 13:19 +0100 |
| Message-ID | <mt6dtq$dcc$1@dont-email.me> |
| In reply to | #8791 |
"James Harris" <james.harris.1@gmail.com> wrote in message news:mt4dpo$6es$1@dont-email.me... > > "Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message > news:op.x4wfnyq1yfako5@localhost... >> On Sun, 13 Sep 2015 04:49:27 -0400, James Harris >> <james.harris.1@gmail.com> wrote: ... >> 'static' >> >> 1) on a function, used to not export the function name to the linker >> 2) on a function declaration, used to indicate the function will be >> defined later in the file with storage class 'static' >> 3) on data declarations, use to not export the declaration to the >> linker >> 4) on variables, used to indicate static extent instead of local >> extent, >> i.e., auto > > Well, 1 and 3 are the same. 4 is the other use. 2 is 'interesting'! I have done some checking on case 2. Helpful references were http://port70.net/~nsz/c/c89/c89-draft.html C89 draft. Section 3.1.2.2 Linkages of identifiers https://books.google.co.uk/books?id=441tAwAAQBAJ&lpg=PA22&ots=SlyNaJGFFc&pg=PA20#v=onepage&q&f=false The Cert C Coding Standard, 2nd edition. From page 20 on http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf C2011 draft. Section 6.2.2 Linkages of identifiers Those standards docs are very much NOT easy to read. The choices, then: 1) pay for the services of a top legal team to work out the answer or 2) try to work out the answer myself ... then pay for the services of a top psychiatric team to help me recover. Believe it or not the answer seems to depend on the *order* in which the declarations appear - but only sometimes. One good thing is that the standard seems to have been very consistent between c89 and c2011. To test the understanding I came to I made up some examples and ran them through GCC. Fortunately it agreed with me! I will show the examples in this post and then try to explain them in another post later. Note that I have only looked at the rules for objects and functions declared at file scope. I have not included any comments on identifiers declared in a function (though they don't seem to be too big an addition once the file-scope stuff has been worked out). The examples are as follows together with comments showing my take, based on the standards, on what they mean and where there is a conflict. int X1; /* External linkage */ extern int X1; /* Copies the above */ extern int X2; /* External linkage */ int X2; /* External linkage */ static int X3; /* Internal linkage */ int X3; /* External linkage - conflict */ static int X4; /* Internal linkage */ extern int X4; /* Copies the above */ extern int X5; /* External linkage */ static int X5; /* Internal linkage - conflict */ Verified. GCC complained about X3 and X5 only. void F1(void); /* == extern void F(void); */ extern void F1(void); /* Copies the above */ extern void F2(void); void F2(void); /* == extern void F(void); */ static void F3(void); /* Internal linkage */ void F3(void); /* == extern ...; copies the above */ static void F4(void); extern void F4(void); /* Copies the above */ void F5(void); /* == extern .... External linkage */ static void F5(void); /* Internal linkage - conflict */ extern void F6(void); /* External linkage */ static void F6(void); /* Internal linkage - conflict */ Verified. GCC complained about F5 and F6 only. If someone else wants to try to explain the above feel free. Either way, I will get back to it later. James
[toc] | [prev] | [next] | [standalone]
| From | "Rod Pemberton" <boo@fasdfrewar.cdm> |
|---|---|
| Date | 2015-09-15 00:01 -0400 |
| Message-ID | <op.x4zj4l2myfako5@localhost> |
| In reply to | #8804 |
On Mon, 14 Sep 2015 08:19:54 -0400, James Harris <james.harris.1@gmail.com> wrote: > "James Harris" <james.harris.1@gmail.com> wrote in message > news:mt4dpo$6es$1@dont-email.me... >> "Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message >> news:op.x4wfnyq1yfako5@localhost... >>> On Sun, 13 Sep 2015 04:49:27 -0400, James Harris >>> <james.harris.1@gmail.com> wrote: > Those standards docs are very much NOT easy to read. See, there is no real point in rejecting H&S as an authorative source. That was meant to be funny, but is a half-truth. You really only need the specifications for determining the validity of rather rare situations. Even then, most people have problems understanding what is truly meant by them due to the abstractions used. So, is there a valid reason to go through the pain? H&S went through that for you. In this case, you're asking your "savior", i.e., H&S, to be perfect. ;-) > The choices, then: > 1) pay for the services of a top legal team to work out the answer or 2) > try to work out the answer myself ... then pay for the services of a top > psychiatric team to help me recover. LOL. You seemed to be doing really good understanding them, even though I usually disagree with some of your conclusions. (Ditto Alexei.) > Believe it or not the answer seems to depend on the *order* in which the > declarations appear - but only sometimes. It makes no real difference to me, as I've almost never used 'static'. Until you (or Alexei) can convince me otherwise, it's a moot point from my perspective. > One good thing is that the standard seems to have been very consistent > between c89 and c2011. Amazing. That must be a first ... > To test the understanding I came to I made up some examples and ran them > through GCC. Fortunately it agreed with me! :-) It's likely the standard behavior, then, although I'd only rank that at about 98% certainty. Although, GCC isn't perfect. It has a bunch of extensions, and changes the meaning of things to suit their needs. I just noticed that the '-ansi' flag I always use disables a bunch of checks for things, including at least one keyword. This isn't good. So, my code was compiling cleanly with '-ansi' but failing without. The list of (false) errors this caused GCC to emit was unbelievable. Apparently, half asleep, I used 'asm' as a pointer to a file, since I was emitting assembly it seemed like a good choice. The DJGPP versions of GCC also defined MSDOS and other things for "internal" use. So, now I'm using "gcc -Wall -c" first to make sure nothing is overlooked by enabling the other flags, then compiling with '-ansi' and '-pedantic'. Just an FYI. > If someone else wants to try to explain the above feel free. > Either way, I will get back to it later. Sorry, I'm definately not interested. Don't fault me. I'm human! :-) Rod Pemberton -- Just how many texting and calendar apps does humanity need?
[toc] | [prev] | [next] | [standalone]
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2015-09-18 14:48 +0100 |
| Message-ID | <mth4jo$bja$1@dont-email.me> |
| In reply to | #8807 |
"Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message news:op.x4zj4l2myfako5@localhost... > On Mon, 14 Sep 2015 08:19:54 -0400, James Harris > <james.harris.1@gmail.com> wrote: > >> "James Harris" <james.harris.1@gmail.com> wrote in message >> news:mt4dpo$6es$1@dont-email.me... >>> "Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message >>> news:op.x4wfnyq1yfako5@localhost... >>>> On Sun, 13 Sep 2015 04:49:27 -0400, James Harris >>>> <james.harris.1@gmail.com> wrote: > >> Those standards docs are very much NOT easy to read. > > See, there is no real point in rejecting H&S as an authorative source. > That was meant to be funny, but is a half-truth. You really only > need the specifications for determining the validity of rather > rare situations. Even then, most people have problems understanding > what is truly meant by them due to the abstractions used. So, is > there a valid reason to go through the pain? H&S went through that > for you. In this case, you're asking your "savior", i.e., H&S, to > be perfect. > > ;-) You have a point. The rules for static vs extern vs no qualifier are very fiddly and the standard writes them in such a way that every word matters. For example, from C89 draft: "If the declaration of an identifier for a function has no storage-class specifier, its linkage is determined exactly as if it were declared with the storage-class specifier extern . If the declaration of an identifier for an object has file scope and no storage-class specifier, its linkage is external." But "extern" and "its linkage is external" don't necessarily mean the same thing. In the previous case where we discussed H&S, i.e. in connection with the switch statement, I found an online copy of their book and it seemed to me that they had come across what they thought of were two different forms (and were surprised at what they had found) so listed them without realising how C worked. I don't know but it seems here that they may have done the same thing and heard of or come across another form of declaration and so included it in their book but not understood it. (Unlike the switch statement, however, in this case I don't blame them!) Nevertheless, the standard does seem to allow for an identifier to be declared with both internal and external linkage without the compiler objecting, which is worrying. If an identifier is so declared the C89 standard just says that the behaviour is undefined. >> The choices, then: >> 1) pay for the services of a top legal team to work out the answer or >> 2) >> try to work out the answer myself ... then pay for the services of a >> top >> psychiatric team to help me recover. > > LOL. > > You seemed to be doing really good understanding them, even though > I usually disagree with some of your conclusions. (Ditto Alexei.) Thanks. I have even written up a grid to try to separate out all of the meanings. The problem, then, is to write that in a concise form that is easier to understand than the standard's legalese. >> Believe it or not the answer seems to depend on the *order* in which >> the >> declarations appear - but only sometimes. > > It makes no real difference to me, as I've almost never used 'static'. > Until you (or Alexei) can convince me otherwise, it's a moot point > from my perspective. The interesting thing, to me, is that C's extern keyword does not mean that an object or function should be external! Instead, extern is almost a tentative external, i.e. make this external unless you got a better offer elsewhere. I didn't know any of that. My guess is that it was designed so that a header can have the term extern in it and still be #included in the one file where the same identifier is declared and defined. But it gets weirder in that extern will copy the attributes of something already in scope. For example, if you declared X as static and then extern C would treat it as static. But if you declared it as extern and then static then you would get undefined behaviour. That suggests that we are supposed to define external objects *before* #including headers that refer to them. Again, not something I knew or have ever considered. >> One good thing is that the standard seems to have been very >> consistent >> between c89 and c2011. > > Amazing. That must be a first ... > >> To test the understanding I came to I made up some examples and ran >> them >> through GCC. Fortunately it agreed with me! > > :-) > > It's likely the standard behavior, then, although I'd only rank that > at about 98% certainty. Agreed, and that is probably generous. I was just glad to get something to agree. ... >> If someone else wants to try to explain the above feel free. >> Either way, I will get back to it later. > > Sorry, I'm definately not interested. Don't fault me. I'm human! > :-) No worries. Though, as above, this has turned into something related more to extern than to static, and to how to pull in header files. James
[toc] | [prev] | [next] | [standalone]
| From | "Rod Pemberton" <boo@fasdfrewar.cdm> |
|---|---|
| Date | 2015-09-26 16:23 -0400 |
| Message-ID | <op.x5k6wvvfyfako5@localhost> |
| In reply to | #8815 |
On Fri, 18 Sep 2015 09:48:26 -0400, James Harris <james.harris.1@gmail.com> wrote: > "Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message > news:op.x4zj4l2myfako5@localhost... >> On Mon, 14 Sep 2015 08:19:54 -0400, James Harris >> <james.harris.1@gmail.com> wrote: >>> "James Harris" <james.harris.1@gmail.com> wrote in message >>> news:mt4dpo$6es$1@dont-email.me... >>>> "Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message >>>> news:op.x4wfnyq1yfako5@localhost... >>>>> On Sun, 13 Sep 2015 04:49:27 -0400, James Harris >>>>> <james.harris.1@gmail.com> wrote: >>> Those standards docs are very much NOT easy to read. >> >> See, there is no real point in rejecting H&S as an authorative source. >> That was meant to be funny, but is a half-truth. You really only >> need the specifications for determining the validity of rather >> rare situations. Even then, most people have problems understanding >> what is truly meant by them due to the abstractions used. So, is >> there a valid reason to go through the pain? H&S went through that >> for you. In this case, you're asking your "savior", i.e., H&S, to >> be perfect. >> >> ;-) > > You have a point. [...] > > In the previous case where we discussed H&S, i.e. in connection with the > switch statement, I found an online copy of their book and it seemed to > me that they had come across what they thought of were two different > forms (and were surprised at what they had found) so listed them without > realising how C worked. It seems as if you still don't accept it. Do you agree that Duff's device both exists and works? If so, then you must accept that H&S are correct here. Rod Pemberton -- Just how many texting and calendar apps does humanity need? Just how many food articles from neurotic millenials do we need?
[toc] | [prev] | [next] | [standalone]
| From | James Harris <james.harris.1@gmail.com> |
|---|---|
| Date | 2015-09-27 00:23 +0100 |
| Message-ID | <mu79ae$bft$1@dont-email.me> |
| In reply to | #8847 |
On 26/09/2015 21:23, Rod Pemberton wrote: > On Fri, 18 Sep 2015 09:48:26 -0400, James Harris > <james.harris.1@gmail.com> wrote: ... >> In the previous case where we discussed H&S, i.e. in connection with the >> switch statement, I found an online copy of their book and it seemed to >> me that they had come across what they thought of were two different >> forms (and were surprised at what they had found) so listed them without >> realising how C worked. > > It seems as if you still don't accept it. > > Do you agree that Duff's device both exists and works? > > If so, then you must accept that H&S are correct here. Was this one of the C conversations you mysteriously stopped replying to? If so then I have to say I can't see a point in responding. The same might happen again. :-( James
[toc] | [prev] | [next] | [standalone]
| From | "Alexei A. Frounze" <alexfrunews@gmail.com> |
|---|---|
| Date | 2015-09-26 16:37 -0700 |
| Message-ID | <994e1098-7e76-4eb7-bfd1-aba396d22ec8@googlegroups.com> |
| In reply to | #8848 |
On Saturday, September 26, 2015 at 4:23:50 PM UTC-7, James Harris wrote: > On 26/09/2015 21:23, Rod Pemberton wrote: > > On Fri, 18 Sep 2015 09:48:26 -0400, James Harris > > <...@gmail.com> wrote: > > ... > > > >> In the previous case where we discussed H&S, i.e. in connection with the > >> switch statement, I found an online copy of their book and it seemed to > >> me that they had come across what they thought of were two different > >> forms (and were surprised at what they had found) so listed them without > >> realising how C worked. > > > > It seems as if you still don't accept it. > > > > Do you agree that Duff's device both exists and works? > > > > If so, then you must accept that H&S are correct here. > > Was this one of the C conversations you mysteriously stopped replying > to? If so then I have to say I can't see a point in responding. The same > might happen again. :-( > > James )-:-)-:-)-:-)-:-)-:-)-:-) Alex
[toc] | [prev] | [next] | [standalone]
Page 2 of 5 — ← Prev page 1 [2] 3 4 5 Next page →
Back to top | Article view | alt.os.development
csiph-web