top | item 46726842

(no title)

platinumrad | 1 month ago

Would it be accurate to think of it as a better way of doing the following?

``` int add(int a, int b) { #ifndef FREESTANDING printf("adding %d and %d\n", a, b); # return a + b; } ```

> You still share logic by compiling the same source multiple times

What's the benefit of this approach over sharing code via libraries?

discuss

order

JhonPork|1 month ago

It’s similar at a surface level, but the key difference is when the choice is made and what is being selected. #ifdef and libraries still live inside a single execution contract — the compiler parses and reasons about everything, and constraints are mostly conventional. In Falcon, the profile selects a different execution contract before IR exists. Non-matching code is not typechecked or lowered at all, and different rules (heap, panics, aliasing, UB) are enforced structurally. Libraries share implementation; profiles share intent. The same source is treated as a specification from which multiple valid-by-construction artifacts are derived, rather than a single program patched with conditionals.