Stream: general

Topic: const promotion of static addresses (re: lang team meeting)


Lokathor (Oct 11 2019 at 14:53, on Zulip):

@RalfJ Hi friend. I have a question related to the recent discussion in the lang team meeting.

In my own crate, so far I don't have the problem with raw hardware addresses and const eval interacting badly because I ended up making a type (VolAddress<T>) which is internally a NonZeroUsize + PhantomData<T>, and then all the const fn manipulations of this type do const math to offset the address or whatever thing, while the actual reading and writing of the memory (where the address value is cast to *mut T at the last minute) isn't const fn so you simply can't end up writing a const expression where you'd read or write the memory. I think I'm just naturally saved in this situation by the type system.

My question to you is, "does this sound like a sane and correct approach?" or is there perhaps something I missed that would make this a fall down suddenly?

RalfJ (Oct 12 2019 at 14:04, on Zulip):

yeah I'm a fan of that approach :D

RalfJ (Oct 12 2019 at 14:04, on Zulip):

@Lokathor you are basically typing your integer addresses as usize instead of using pointers. which in some sense is more correct.

Last update: Nov 20 2019 at 11:25UTC