Final by default?

Mike Parker aldacron at gmail.com
Fri Mar 14 07:34:46 PDT 2014


On 3/14/2014 10:21 PM, Regan Heath wrote:
> On Fri, 14 Mar 2014 10:22:40 -0000, 1100110 <0b1100110 at gmail.com> wrote:
>
>> On 3/14/14, 4:58, Regan Heath wrote:
>>>
>>> Maintenance is very slightly better too, IMO, because you
>>> add/remove/alter a complete line rather than editing a set of || && etc
>>> which can in some cases be a little confusing.  Basically, the chance of
>>> an error is very slightly lower.
>>>
>>> For example, either this:
>>>
>>> version(X86) version = MeaningfulVersion
>>> version(X86_64) version = MeaningfulVersion
>>> version(PPC) version = MeaningfulVersion
>>> version(PPC64) version = MeaningfulVersion
>>> version(ARM) version = MeaningfulVersion
>>> version(AArch64) version = MeaningfulVersion
>>>
>>> version(MeaningfulVersion)
>>> {
>>> }
>>> else version (MIPS32)
>>> {
>>> }
>>>
>>> or this:
>>>
>>> version (X86) version = MeaningfulVersion
>>> version (X86_64) version = MeaningfulVersion
>>> version (PPC) version = MeaningfulVersion
>>> version (PPC64) version = MeaningfulVersion
>>> version (ARM) version = MeaningfulVersion
>>> version (AArch64) version = MeaningfulVersion
>>>
>>> version (MIPS32) version = OtherMeaningfulVersion
>>>
>>> version (MeaningfulVersion)
>>> {
>>> }
>>> else version (OtherMeaningfulVersion)
>>> {
>>> }
>>>
>>> Regan
>>>
>>
>>
>> ...I can't even begin to describe how much more readable the OR'd
>> version is.
>
> It's shorter, but shorter does not mean more "readable".. if by readable
> you mean include the ability to communicate intent etc.  Add to that,
> that readable is just one metric.
>
> Walter's point is that the above pattern is better at communicating
> intent, clarifying your logic, and making the resulting version
> statements easier to understand (aka "more readable")
>
> R
>

For me, the issue is that this has to go in *every* module that needs 
MeaningfulVersion and OtherMeaningfulVersion to be defined. That's a lot 
more points to track than a single line of ORed versions in each module.

When I do need something like this, I just define some manifest 
constants in a config module, import that everywhere, and use static if. 
But that feels very much like the workaround it is. I would much prefer 
to have boolean versions. The bottom line is that I'm doing exactly what 
Walter apparently doesn't want me to do anyway, just with the added 
annoyance of importing an extra module to get it done.


More information about the Digitalmars-d mailing list