Skip to content

Abbreviation for zero-sized types with particular alignment #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gnzlbg opened this issue Jul 24, 2019 · 3 comments · Fixed by #173
Closed

Abbreviation for zero-sized types with particular alignment #172

gnzlbg opened this issue Jul 24, 2019 · 3 comments · Fixed by #173
Labels
S-writeup-needed Status: Ready for a writeup and no one is assigned

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 24, 2019

We often need to talk about zero-sized types (ZSTs) with a particular alignment requirement, e.g., 1, or in general, N:

#[repr(align(N))] struct Zst;

It was suggested in #164 (comment) that we should have an abbreviation for this defined in the glossary, where we also define the zero-sized type (ZST) abbreviation, to avoid writing "a zero-sized one-aligned type" and similar constructs all over the place.

A proposal was to use the N-ZST schema for an "N-aligned zero-sized type", e.g., 1-ZST would stand for a "one-aligned zero-sized type".

@gnzlbg gnzlbg added the S-writeup-needed Status: Ready for a writeup and no one is assigned label Jul 24, 2019
gnzlbg added a commit to gnzlbg/unsafe-code-guidelines that referenced this issue Jul 24, 2019
@JohnScience
Copy link

N-ZST is a great name for talking about the concept in natural language, yet it has a great deficiency. Its particular instances, such as 4-ZST or 16-ZST, cannot be identifiers. aligned crate used A1, A2...A64 as names for 1-ZST ..= 64-ZST. I'm unsure whether I should change the name of A1 to, let's say, A1ZST. The latter may seem cryptic to the outsider.

@RalfJung
Copy link
Member

Alternatively you could use ZST4 etc, which avoids the cryptic A?

@JohnScience
Copy link

JohnScience commented Feb 22, 2022

Alternatively you could use ZST4 etc, which avoids the cryptic A?

I believe that's the best approach. The original author of aligned crate didn't make promises about A1 being ZST, so there even might be no confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-writeup-needed Status: Ready for a writeup and no one is assigned
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants