Should D have control-flow expressions? IS it possible?

Basile B. b2.temp at gmx.com
Fri Sep 11 05:05:23 UTC 2026


On Friday, 11 September 2026 at 04:07:20 UTC, Meta wrote:
> On Friday, 11 September 2026 at 03:35:47 UTC, Basile B. wrote:
>> On Thursday, 10 September 2026 at 06:56:25 UTC, Meta wrote:
>>> [...]
>>> Anyway, is this reasonably doable? I personally want it for 
>>> switch expressions (or Rikki's proposed .match statement, 
>>> which I think lowers to a tree of ternary expressions 
>>> similarly to what my POC does).
>>
>> The problem is about algorithmic complexity. D does the flow 
>> analysis at the statement level. That way you dont have to 
>> explore the whole sub-expressions to create the "basic blocks".
>>
>> You can allow expressions to change the flow, but this is a 
>> serious shift. For example Zig does that. In the past they had 
>> a lot of bugs related to the way they mix expressions and 
>> statements.
>
> Hmmm, do you remember anything in particular? From what I've 
> read, one of the big issues is around cleanup.

for some reason I don't have access granteed to codeberg (running 
joke), but basically in the past, every bug related to 
"terminator" (when they used LLVM) [are about the flow 
analysis](https://github.com/ziglang/zig/issues?q=is%3Aissue%20state%3Aclosed%20terminator%20LLVM). You see I have no problem with that prog-lang but due to my own interest I've spent a lot of time reading bug reports. As a user of LLVM I can tell you frankly that that used to be one of their main problem.


More information about the Digitalmars-d mailing list