r/cpp
•
u/steveklabnik1
•
Oct 24 '24
•
1
Why Safety Profiles Failed
https://www.circle-lang.org/draft-profiles.html
180
Upvotes
View all comments
Show parent comment
19
u/rundevelopment Oct 25 '24
What does this even mean? What are you analysing? This sounds like you're suggesting to get this information from elsewhere, so where does it come from?
If you're suggesting to analyse the code in the function body to figure out the semantics of a reference, then your solution is unworkable, because libraries exist. You can't analze the body of a function whose source code you do not have.
If you're suggesting analysing the usage of a function at call-site, then this is unworkable as well. You'd essentially define the correct usage of a function by how it is used, which (1) doesn't work if a library uses your functions and (2) isn't how contracts work. You'd also have to solve the problem of picking the "correct" semantic when two call sites disagree.
Any useful solution has to declare all necessary information in the function signature, either explicitly (Rust, Circle C++) or via pre-defined rules (safety profiles).