News for hackers. Stuff that matters.
Re:How to make your C codebase Rusty: rewriting keyboard fir... by Rusky on Thursday November 21, 2019 @09:28PM (#21601919)
But C++ could take the same route of consistency regardless of the lexer hack.

The turbofish is a strict superset of `typename`, and everywhere C++ lets you skip it it could simply require it instead.

Re:How to make your C codebase Rusty: rewriting keyboard fir... by pcwalton on Thursday November 21, 2019 @09:37PM (#21601948)
I don't think that's true. Consider a modified version of [1]:

    template<typename T> class X {
        void foo() {
            typename T::A* pa;
        }
    }
The problem here is that C++ can't parse this without knowing whether T::A is a type or not. Otherwise it might be "T::A multiplied by pa". This is the lexer hack in action.

Rust, by contrast, has no such limitation [2]:

    trait SomeTrait {
        type A;
    }
    struct X<T> {
        f: T,
    }
    impl<T> X<T> where T: SomeTrait {
        fn foo() {
            let pa: *mut T::A;
        }
    }
This compiles and runs just fine with no need for a turbofish on T::A, because Rust has no lexer hack.

[1]: https://en.cppreference.com/w/cpp/language/dependent_name

[2]: https://play.rust-lang.org/?version=stable&mode=debug&editio...

Re:How to make your C codebase Rusty: rewriting keyboard fir... by Rusky on Thursday November 21, 2019 @10:51PM (#21602264)
That's true but antiparallel to my point:

C++ typename could have the same consistency as Rust's turbofish- its complicated rules are not necessitated by the lexer hack.

(In a sense, the complicated rules are what enable the lexer hack.)

Re:How to make your C codebase Rusty: rewriting keyboard fir... by pjmlp on Friday November 22, 2019 @03:14AM (#21603784)
C++20 has simplified the need for typename use cases.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p063...