Const arguments

the idea is to use this as a stepping stone for const generics

Simultaneous Art from C++: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1045r0.html

basically I want a very simple and very limited form of const generics.

They’d only work in functions. they’d only be const-checked when calling the function, but inside the function it’d be treated like a non-const as far as everything is concerned. This is extremely limited, but compatible with const generics, so if we do get const generics we can then “fix” this, and make it work like const generics.

It would be a stepping stone for const generics, and would introduce an useful behavior - erroring if an argument isn’t const. It may not seem very useful but it really is. I’m working on some code that uses an argument to emit notifications, and we expect the argument to be fixed at compile-time.

Note that “const mut” would NOT be available, as that would be incompatible with const generics.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.