DIP62: Volatile type qualifier for unoptimizable variables in embedded programming
Iain Buclaw via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jul 15 10:16:24 PDT 2014
On 15 July 2014 17:25, Johannes Pfau via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> You may have seen Mike's talk about D on embedded systems and were
> surprised about Iain's comment that using 'shared' as a replacement for
> 'volatile' is actually only possible because of a bug in gdc.
>
> DIP62 describes how to solve this problem and make embedded programming
> a first-class citizen in D:
> http://wiki.dlang.org/DIP62
>
> This is the only language change necessary to make D really perfect for
> embedded programming, so it's important that we fix this.
> There are some more implementation issues, but these aren't language
> problems and easy to fix.
>
> The DIP provides detailed descriptions and rationales so I won't
> copy/paste this information into this post. But please:
>
> * Read the complete DIP before commenting. I'd took a long time to
> write, so it's OK if it takes some time to read ;-) Also your question
> might already be answered.
> * Although it's explained in the DIP in detail, I must mention this
> here again: We need _first-class_ support for embedded programming in
> D. Workarounds might be available (peek/poke, inline asm) but it will
> be obvious to most C programmers that C has got the better solution
> with the volatile qualifier. D enthusiasts might be happy if they can
> use workarounds to make D work on microcontrollers. But if we want to
> appeal to outsiders we can't confront them with obvious workarounds
> and hacks as the first thing they see in D. And if they think embedded
> programming is a second class citizen in D, why should they use it
> at all?
>
More simply put. A volatile keyword would be strictly for hardware
access without locks. We have 'shared' for inter-thread
communication, and for ensuring that there is an ordered relationship
between threads when accessing the same data location at the same
time.
Regards
Iain
More information about the Digitalmars-d
mailing list