Why must the last part of an Objective-C method name take an argument (when there is more than one part)?

This is Brad Cox. My original answer misunderstood the question. I assumed reallyFast was a hardcoded extension to trigger faster messaging, not a kind of syntactic sugar. The real answer is that Smalltalk didn’t support it, perhaps because its parser couldn’t deal with the (assumed) ambiguity. Although OC’s square brackets would remove any ambiguity, I … Read more

Why is adding null to a string legal?

From MSDN: In string concatenation operations, the C# compiler treats a null string the same as an empty string, but it does not convert the value of the original null string. More information on the + binary operator: The binary + operator performs string concatenation when one or both operands are of type string. If … Read more

Why can’t local variable be used in GNU C basic inline asm statements?

You can use local variables in extended assembly, but you need to tell the extended assembly construct about them. Consider: #include <stdio.h> int main (void) { int data1 = 10; int data2 = 20; int result; __asm__( ” movl %[mydata1], %[myresult]\n” ” imull %[mydata2], %[myresult]\n” : [myresult] “=&r” (result) : [mydata1] “r” (data1), [mydata2] “r” … Read more

History of trailing comma in programming language grammars

I’m not an expert on the commas, but I know that standard Pascal was very persnickity about semi-colons being statement separators, not terminators. That meant you had to be very very careful about where you put one if you didn’t want to get yelled at by the compiler. Later Pascal-esque languages (C, Modula-2, Ada, etc.) … Read more

What exactly is or was the purpose of C++ function-style casts?

Function style casts bring consistency to primitive and user defined types. This is very useful when defining templates. For example, take this very silly example: template<typename T, typename U> T silly_cast(U const &u) { return T(u); } My silly_cast function will work for primitive types, because it’s a function-style cast. It will also work for … Read more