DIP62: Volatile type qualifier for unoptimizable variables in embedded programming
bearophile via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jul 16 01:13:11 PDT 2014
Walter Bright:
> struct VolatilePointerToUint {
> private:
> size_t ptr;
> public:
> this(size_t ptr) { this.ptr = ptr; }
> uint read() { return peek(cast(uint*)ptr); }
> void write(uint value) { poke(cast(uint*)ptr, value); }
> }
>
> You'd probably wish to flesh this out a bit more, but it's the
> general idea.
To be added to Phobos?
> It's a zero cost abstraction. D has very capable abilities to
> create types that are restricted versions of other types - this
> should be explored and exhausted before considering language
> extensions.
See also the @fantom suggested by Kagamin.
Bye,
bearophile
More information about the Digitalmars-d
mailing list