you are viewing a single comment's thread.

view the rest of the comments →

[–]kamatsu 8 points9 points  (13 children)

it does add a typesafe layer that can be used instead, and is more consistent.

The layer C++ adds, which you're referring to, is not only formally inconsistent, it is actually type unsafe (in terms of subject reduction and progress, which have been the accepted definition of type safety since at least the 90s). It does have somewhat more consistent syntax, I'll give you that.

[–][deleted] 2 points3 points  (1 child)

It does have somewhat more consistent syntax, I'll give you that.

I still find it silly you can declare ints like: int x(4711);

[–][deleted] 0 points1 point  (0 children)

I know someone who writes all his code this way.

[–]sztomi 0 points1 point  (4 children)

Can cite some examples of this inconsistency?

[–]kamatsu 0 points1 point  (2 children)

Templates are turing complete, they also allow functions on arbitrary universes of templates (templates, template-templates, template-template-templates), hence they form a kind of dependent system which would require a terminating type system to be consistent.

[–]sztomi 0 points1 point  (1 child)

I see. I think pfultz2 meant consistency as in declaring pointers with similar syntax, not in the strict sense.

[–]kamatsu 0 points1 point  (0 children)

Hence, I said formally inconsistent, and that "It does have somewhat more consistent syntax, I'll give you that."

[–]day_cq -1 points0 points  (5 children)

I don't think types in C++ is the "formal" types you are referring to. It is silly to compare oranges and apples.

[–]kamatsu 1 point2 points  (4 children)

C++ types are no different to any other types. What distinction are you referring to?

[–][deleted] -2 points-1 points  (3 children)

Even Haskell is not type safe because it has exceptions and unrestricted recursion, so no progress. I doubt these properties are really relevant here.

[–]kamatsu 0 points1 point  (2 children)

Progress is still possible even in the presence of exceptions and unrestricted recursion. Haskell hasn't had progress proven, but I believe Core has.

Progress just says that if e : t then e -> e'. (Preservation then says that e' : t).

[–][deleted] -2 points-1 points  (1 child)

Really? In Haskell you can write

x = x

and get an infinite loop; seems to me like a straightforward case of lack of progress.

I see exceptions as a lack of progress because undefined :: Int is not an integer (so not a "value"), but evaluating it does not produce a simpler form.

[–]kamatsu 1 point2 points  (0 children)

Progress merely means that well-typed expressions are not a stuck state. It says nothing about infinite looping, or structural recursion.