OpenBSD port of dmd?

Daniel Murphy yebblies at nospamgmail.com
Fri Mar 16 19:13:35 PDT 2012


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:jk0ptd$29g2$1 at digitalmars.com...
>>>
>>> But why duplicate doItSlowWay(); which may be an arbitrarily long
>>> sequence?
>>
>> If duplicating that block is a problem, there are other ways to do it.
> [snip]
>
> This is in the same vein: "let's avoid else".
>

Yes.

>>> This seems to accomplish little more than "well I didn't use else".
>>>
>>> Again: what exactly is wrong with specialization?
>>>
>>
>> The advantage is, that when you write the code, you have _no idea_ what
>> platform/os it might need to run on in the future.  You _cannot_ know 
>> which
>> version is most appropriate for _all_ new platforms, or even if any of 
>> them
>> will work at all.
>
> Oh yes I do. Often I know every platform has e.g. getchar() so I can use 
> it. That will definitely work for everyone. Then, if I get to optimize 
> things for particular platforms, great. This is the case for many 
> artifacts.
>

Are there really no platforms out there where getchar doesn't exist?  What 
if you need to work around a buggy c standard lib on some platforms?

Relying on getchar (and most of the c standard lib) working correctly is 
probably ok, so long as we never target more exotic architectures.  But this 
is not true generally, and do you really trust everybody who works on the 
code to make the right choice each time?

>> The only time to make this decision is when implementing
>> support for a specific platform, and this pattern forces you to consider
>> each place where platform specific behaviour is required.  When doing 
>> things
>> like this, 100 false positives are much faster to fix than a single false
>> negative causing wrong code/corruption.
>
> I just find it difficult to get convinced about this. Walter has often 
> talked my ear off about this dogma and never produced a convincing 
> argument.
>
>
> Andrei

Well, he managed to convince me some time ago.  Maybe you should try porting 
code between microcontrollers and see if it makes more sense then.  The best 
part is that if you use this pattern when it isn't needed, the cost is very 
small. 




More information about the Digitalmars-d mailing list