News for hackers. Stuff that matters.
Re:Lisp's mysterious tuple problem by kazinator on Wednesday July 12, 2017 @06:08PM (#14757100)
C only introduced the ability to mix declarations and statements in 1999, and not all compilers caught up with C99 right away.

By that time, C had long been a popular language, in spite of demanding that, just like in Pascal, local variables have to be defined at the opening of a new block scope, after which only statements follow.

This is actually a good idea; I avoid mixed declarations and statements in C programming.

Also, mixed declarations and statements are against the Linux kernel coding guidelines and are diagnosed. Yet countless people hack on the Linux kernel for fun and profit.

When I really need some tightly scoped local variable in C, I introduce a little scope with a new braced compound statement, just like `(let` in Lisp. This has the advantage that you determine where the scope ends, not only where it begins. You know: from line 27 this 75 line function, down to line 53, and that's it, not all the way down to line 75.

The mainstream dialect of lisp known as Scheme has a define construct which lets you create new scopes with local variables at the same level of nesting. (Scheme compilers transliterate these defines-s to nested let for you). Yet Scheme is not taking over the world. This aspect rarely even comes up as a topic.

There are no comments on this comment yet.