Arthur O’Dwyer's "const is a contract":
https://quuxplusone.github.io/blog/2019/01/03/const-is-a-contract/
Do not quite agree with Arthur's post with using const type as argument a bad style:
quoted:
Lazy typing and busy side projecting :-p
to sum up, refer to Titus Winters' Revisiting Regular Types.
(note here: http://vsdmars.blogspot.com/2018/06/c-regular-type.html )
And further reddit discussion:
https://www.reddit.com/r/cpp/comments/acbf1w/const_is_a_contract/ed6o5k9/
Relevant:
Since Golang has no idea about const-ness in function argument
(and argument by default copy-by-value)
people even blog for slice-gotcha...
https://allegro.tech/2017/07/golang-slices-gotcha.html
and gotcha in official document as well:
https://blog.golang.org/slices
Regular type is a strong idea which can be used in different languages due to it's merely an design abstraction.
Reference:
propagate_const https://en.cppreference.com/w/cpp/experimental/propagate_const
std::span https://en.cppreference.com/w/cpp/container/span
https://quuxplusone.github.io/blog/2019/01/03/const-is-a-contract/
Do not quite agree with Arthur's post with using const type as argument a bad style:
quoted:
void counterfeit(const Ming vase); // BAD STYLE!
Lazy typing and busy side projecting :-p
to sum up, refer to Titus Winters' Revisiting Regular Types.
(note here: http://vsdmars.blogspot.com/2018/06/c-regular-type.html )
And further reddit discussion:
https://www.reddit.com/r/cpp/comments/acbf1w/const_is_a_contract/ed6o5k9/
Relevant:
Since Golang has no idea about const-ness in function argument
(and argument by default copy-by-value)
people even blog for slice-gotcha...
https://allegro.tech/2017/07/golang-slices-gotcha.html
and gotcha in official document as well:
https://blog.golang.org/slices
Regular type is a strong idea which can be used in different languages due to it's merely an design abstraction.
Reference:
propagate_const https://en.cppreference.com/w/cpp/experimental/propagate_const
std::span https://en.cppreference.com/w/cpp/container/span
#include <iostream> using namespace std; void run(int a); struct Fun{ void run (){ } void run() const { } }; int main(){ run(10); } void run(const int a){ }
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.