Code That Says Exactly What It Means

Peter C peterc at gmail.com
Sun Oct 26 09:35:47 UTC 2025


On Sunday, 26 October 2025 at 08:32:37 UTC, monkyyy wrote:
>
> ..
> You wrote a big class, only to use floats to represent money. 
> All the safety keywords and you broke your type theory. When 
> you do this, youd be fired instantly; but if for some reason 
> you managed to ship people would steal pennies with floating 
> point errors.
>
> Your reducing clarity.

You might be missing the point here ;-)

Of course my background is in C#, where I (regulary) use a 
decimal type. But my knowledge of D is somewhat limited - I don't 
think it even has a decimal type?? - and the code was merely an 
example (as per the name of the module) to demonstrate code that 
desires to narrow the visiblity,in a particular case, not widen 
it (with package). Nothing else in the code is relevant here, 
except 'how' to implement that programmers desire.

In that example code, it is 'scopeprivate' that allowed the 
programmer of that code, to do just that, in an explicit and 
enforceable manner.

Without scopeprivate, I'm not sure how that programmer could have 
expressed that intent 'in a meaningful way', and certainly not in 
a way that is enforceable.



More information about the Digitalmars-d mailing list