4,518 reputation
21227
bio website keith-s-thompson.github.com
location San Diego, CA
age 54
visits member for 2 years, 8 months
seen 2 days ago

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

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


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.
Nov
26
awarded  Nice Answer
Nov
26
comment Using a function's return value as an if condition, good practice?
@guenis: You can assume that, but it may not continue to be true as the code is modified. In my example, it's used in debugging code.
Nov
26
answered Using a function's return value as an if condition, good practice?
Nov
15
comment How to handle divide by zero in a language that doesn't support exceptions?
Does your language support integers and floating-point numbers as distinct types? NaN is typically defined for floating-point types, not for integers. You could define your own integer NaN, but it would be a bit unusual.
Nov
11
comment The keyword const and the linker file
What do you mean by "this pointer"? The address of Ptr, like the address of any declared object, does not change. The address contained in Ptr can be changed to anything you like by assigning a value to it. (Your title mentions the const keyword, but you don't actually ask about it.)