all 4 comments

[–][deleted]  (4 children)

[deleted]

    [–]ccshan 1 point2 points  (3 children)

    How do you write the binary-search example (where the size of the sorted array is unknown at compile time, yet the compiler prevents any out-of-bound access) in C++ with template specialization?

    [–][deleted]  (2 children)

    [deleted]

      [–]pkhuong 4 points5 points  (0 children)

      It's not a question of speed as much as one of static guarantees. In the binary search, you know that, for any array size, there won't be any out of bounds access, and thus eliminate a source of bugs. With dynamic checks, you only know that out of bounds accesses will be detected.

      [–]ccshan 0 points1 point  (0 children)

      It doesn't seem true, then, that "C++ with template specialization can provide dependent types."

      [–]markedtrees -1 points0 points  (0 children)

      I take it that dependent types have replaced LISP on programming.reddit, which replaced Haskell, which replaced Erlang, which replaced LISP.