Command–query separation principle [re: @mustuse as a function attribute]

mw mingwu at gmail.com
Wed Oct 19 17:16:45 UTC 2022


On Wednesday, 19 October 2022 at 16:47:45 UTC, rikki cattermole 
wrote:
>
>> Yes, for this logic to work, every compilation need to do 
>> global system analysis (that is what Eiffel compiler does).
>
> But not for native compilers. They work in partial builds, this 
> is core to how they work.

Eiffel is a native compiler, and they do support incremental 
build. They have a compilation technology called melting ice:

https://www.eiffel.org/doc/eiffelstudio/Melting_Ice_Technology

(In the past, I'm more a language theorist than a language 
implementator, so I didn't study the details of it.)

>> Now the compiler writer have to work harder to implement this 
>> logic. Do not compromise!
>
> No amount of work is going to change the fact that the compiler 
> may not be aware that code exists.
>
> rt package one example.
>
> Shared libraries another.

Yes pre-built binaries is a concern, but since @mustuse now is a 
half-way introduced remedy (rather than D doing DbC right from 
the very beginning), I think we only need to enforce @mustuse on 
the source code that the compiler actually visit during each 
compilation, that will eliminate the problems the programmer has 
control with. (for pre-built binaries that the programmer have no 
control, there is no way to apply the enforcement either).




More information about the Digitalmars-d mailing list