4,610 reputation
21328
bio website keith-s-thompson.github.com
location San Diego, CA
age 55
visits member for 3 years, 4 months
seen Dec 16 at 23:44

I'm a programmer and all-around nerd living in San Diego, California.
I work at JetHead Development Inc.

E-mail: Keith.S.Thompson@gmail.com


Sep
30
awarded  Explainer
Aug
15
comment How does the “Fourth Dimension” work with arrays?
At least in C, a 2-dimensional array is nothing more or less than an array of 1-dimensional arrays. An N-dimensional array is an array of N-1-dimensional arrays. Other languages define these terms differently, but the semantics are similar (though the ordering may vary).
Aug
4
awarded  Yearling
Jul
29
revised printf - source of bugs?
added 196 characters in body
May
6
comment Is converting/casting a boolean to int a good idea?
In C++, the result is well defined. In C, the result is well defined if you're using the built-in bool (_Bool) type, introduced by C99, but older code may define bool in some other way that permits values other than 0 and 1. In Ada, you can't convert a Boolean to type Integer, but the Boolean'Pos attribute yields 0 for False, 1 for True. And so on, with varying answers for all language with a built-in boolean type. I don't believe there's a language-independent answer.
Feb
12
comment What's the difference between syntax and semantics?
To clarify the point, syntax isn't just about the sequence of tokens, it's about how those tokens build up larger constructs. A compiler typically has a lexical analyzer (tokenizer) and a parser as distinct components; both of them deal with syntax.
Feb
12
comment What's the difference between syntax and semantics?
I disagree. The distinction between the two - oeprators is syntactic, not just semantic (though they also have different semantics). Syntax is defined by the language grammar, and the two operators are specified in different sections of the grammar. See the N1570 draft, section 6.5.3 for unary operators and 6.5.6 for additive operators. (BTW, if you're going to use a C example, it should probably be correct; void main() should be int main(void), and you're missing #include <stdio.h> and whatever header declares getch
Feb
8
revised What's the difference between syntax and semantics?
added 21 characters in body
Feb
7
comment Should I change the name in the WTFPL?
@Domenic: My understanding is that "public domain" does have meaning in the US, which is not a commonwealth country.
Feb
6
comment Is there a name for the 'break n' construct?
I find break with a label name (where the label is, ideally, the name of the loop) to be much clearer than break 2. Having the computer require a human to count something is absurd.
Jan
30
comment “Standard” format for using a timestamp as part of a filename
@MikeRosenblum: (Yeah, I'm resonding to a comment from almost 3 years ago.) Spaces in file names can cause problems on some systems.
Jan
30
comment “Standard” format for using a timestamp as part of a filename
I use YYYY-MM-DD-HHMMSS (I might omit the SS in some cases). The date portion is quite readable, and the time portion is readable enough for most purposes.
Jan
28
comment Is there a difference between casting and converting types in imperative programming languages?
@supercat: At least in C, a cast always specifies the same kind of conversion that would be performed implicitly by an assignment to an object of the same type -- if it's one of the conversions (mostly ones between arithmetic types) that can be done implicitly. Other kinds of conversions, e.g., specifying the kind of rounding/truncation for floating-point, can be done via function calls.
Jan
22
comment Is CSV a good alternative to XML and JSON?
@JonRaynor: I think any XML or JSON format can be mapped to CSV -- but not cleanly. You'd have to invent some way of representing the tree structure. The result would be ugly and almost certainly not worth implementing. For almost all practical purposes, you're right.
Jan
10
revised Can only integers be stored as register variables?
added 450 characters in body
Jan
4
comment Can only integers be stored as register variables?
@Yousaf: Yes, that's basically it -- except that the compiler still has to complain about any attempt to take the variable's address, even if it doesn't actually store it in a CPU register.
Jan
4
comment Can only integers be stored as register variables?
There is no one "ANSI C's programming book". Do you mean Kernighan & Ritchie's "The C Programming Language", 2nd Edition?
Jan
4
answered Can only integers be stored as register variables?
Dec
30
comment What's the reason for C standard to consider const-ness recursively?
@constantius: It's "allowed" only in the sense that the compiler isn't required to diagnose an attempt to do it. The behavior is undefined. const int n = 42; (*(int*)&n) ++; printf("%d\n", n); may print 42, or 43, or a suffusion of yellow.
Nov
26
comment Is application written from scratch in programming language has to be license?
Most languages don't have licences. Most implementations of languages do. In many cases (C and C++, for example), there's a license for the language standard document, but that doesn't apply to the language itself.