4,805 reputation
21428
bio website keith-s-thompson.github.com
location San Diego, CA
age 55
visits member for 3 years, 9 months
seen May 20 at 22:24

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


May
20
comment Short circuit evaluation, is it bad practice?
@linac: In C and C++, && is short-circuit and & is not, but they're very different operators. && is a logical "and"; & is a bitwise "and". It's possible for x && y to be true while x & y is false.
Feb
19
awarded  Good Answer
Jan
27
revised Should Perl scripts really have no extension?
added 325 characters in body
Jan
27
answered Should Perl scripts really have no extension?
Jan
27
comment Should Perl scripts really have no extension?
C compilers commonly treat their input files differently depending on the extension. For example, gcc treats . as C source code, .cpp, .cc, .C as C++ source code, .o as an object file to be passed on to the linker, and so on. You can override that with a command-line option, but I've used it so rarely that I don't remember what it is. The .c extension for C source files is important. The .pl extension for executable Perl scripts is not (at least on UNIX-like systems).
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 of 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