On 06/29/2012 01:01 PM, bearophile wrote:
Namespace:
A friend of mine ask me why D's foreach isn't like C#

In D you often omit the type:

foreach (val; arr) {

Using "in" is better for the human programmers.

Certainly not. (except if 'human' means 'python' or 'C#'.)
It is just as good as ';'.

But D is largely
designed to make D compilers too happy. I think Walter said that the
semicolon was preferred because it simplifies the compiler/compilation a
little.

It does not. Parsing the statements just about the same. In fact, only
2 lines in the DMD parser implementation need to be changed (slightly!)
to implement the 'in' syntax instead.

Reply via email to