Origins of the D Programming Language

Q. Schroll qs.il.paperinik at gmail.com
Fri Dec 7 21:17:31 UTC 2018


On Saturday, 1 December 2018 at 17:32:44 UTC, Paolo Invernizzi 
wrote:
> On Saturday, 1 December 2018 at 16:07:28 UTC, H. S. Teoh wrote:
>> On Sat, Dec 01, 2018 at 11:02:51AM +0000, Kagamin via 
>> Digitalmars-d wrote: [...]
>>> [...]
>>
>> I think you misunderstand the intent here.  Purity by default 
>> doesn't mean everything must be pure with no way out except 
>> awkward periphrases like monads.  It means you opt out of 
>> purity by specifying impure, rather than start with impure and 
>> opt into purity by specifying pure. I.e., an undecorated 
>> function will be implicitly pure, but if you want impure code, 
>> you add an `impure` attribute to the function.
>>
>> [...]
>
> And maybe, class methods final by default?

When both options roughly have the same level of justification 
for being the default, make none the default. Require the user to 
decide. In D, this is really easy. If you're writing a class with 
mostly virtual functions, use "@virtual:" (or whatever the 
attribute would be named) at the beginning and you're good; same 
with "final:". You can always opt-out method-wise or even 
block-wise.
None of them should be the default. Period. Not specifying any of 
them will be an error.
Reading your post, I assume methods are virtual by default; in 
fact . The transition of slapping "@virtual:" at the beginning of 
each class is not very difficult, in fact, it can be automated 
easily.



More information about the Digitalmars-d mailing list