Get the latest tech news

An effect system proposal for C2y


Proposal for C2y WG14 3317 Title: Essential Effects for C Author, affiliation: Alex Celeste, Perforce Date: 2024-08-19 Proposal category: New feature, discussion Target audience: Compiler implementers, users In this discussion proposal we suggest that C would be improved by extending the core type system into a type and effect system, that forces functions and blocks to declare which classes of effects will result from their evaluation. We show how this can be used to improve composability in metaprogramming, and can be used to define MISRA-style restrictions more easily through signatures expressed in the core language.

The system we use is mostly additive, as for resource tracking we prefer to rely on full flow analysis; however, it is capable of the operations described above to both count and cancel-out, and thus handle effects "algebraically" as well. We can later generalize this into a description of the C control structures as analogous to higher-order operators accepting actions as their operands, which has many useful properties for metaprogramming and program construction and allows us to define "types" for what are currently language fragments like do or if. This makes development of staged programming environments that embed C a much more consistent and attractive proposition and has many interesting future applications in offloading more advanced type checking to a first-stage metalanguage.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of c2y

c2y

Related news:

News photo

Improving _Generic in C2y

News photo

LLVM Clang 19 Adds Initial "-std=c2y" Support For The Next C Standard