An effect system proposal for C2y
18 points
1 year ago
| 4 comments
| open-std.org
| HN
AlotOfReading
1 year ago
[-]
Not a big fan of this. The suggested effects have some ambiguities. For example, does sprintf imply the errno effect that's only required under POSIX? Does printf imply file or just system depending on implementation?

I'm also not sure what you really gain from this effort beyond mut annotations. It doesn't give you a way to detect or eliminate UB. It doesn't allow the compiler to optimize pure functions better like the reproducible directive does. A better effects system could do these things, but this is an unhappy middle ground between something simple enough to actually get standardized and something powerful enough to provide useful guarantees.

reply
omoikane
1 year ago
[-]
See also:

https://news.ycombinator.com/item?id=41464994 - C2y Proposal: Essential Effects for C (2024-09-06, 30 comments)

Is there a corresponding proposal for C++? The earlier thread mentioned that "C++ doesn't have this yet", but I am wondering if C++ has enough template magic that it's able to do it through libraries without changes to the language.

reply
wizzwizz4
1 year ago
[-]
> This proposal composes well with N3316 The void-which-binds,

Broken link. Should be *.htm, not *.html.

reply
fithisux
1 year ago
[-]
It needs an implementation
reply
pjmlp
1 year ago
[-]
For sure, however if you bothered to read it, MISRA verifiers and Deputy are given as examples from prior art.
reply
wizzwizz4
1 year ago
[-]
> Please don't comment on whether someone read an article. "Did you even read the article? It mentions that" can be shortened to "The article mentions that".

https://news.ycombinator.com/newsguidelines.html

reply