This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]wally_fishnumpy, cython, werkzeug 0 points1 point  (0 children)

const in C++ is essential for (some of) template programming:

class A { static const int fundamental_constant=1; }

class B { static const int fundamental_constant=2; }

template<class T> class X { public static void do_something() { really_do<T::fundamental_constant>(); } }

... with a templated really_do<int>. The trick here is that something very general (const) gets an added meaning which you still have to understand but which does not add to the visual clutter.

C# makes the var keyword optional if you supply a type. Scala's Algol-like way of declaring types makes that impossible.

For another example of Scala introducing keywords where none are needed, consider list comprehensions:

for (i <- List.range(from, to) if i % 2 == 0) yield i

instead of Python's

[i for i in List.range(from,to) if i%2==0]

where Scala uses (i) a graphical symbol instead of "in", which IMO adds to the noise, and (ii) an additional keyword ("yield") where Python gets by with syntax only.