-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed as not planned
Description
We've have some open design questions from the past (#22649, #20415, #9448) of wanting to attach some properties to various fields of an object. Separately, while doing other work (and having need of this now), I ended up stumbling across a syntax that I feel I liked for this. It already parses, but currently has no meaning during lowering. To me, this looks like a parenthetical that describes the field, which is indeed what it is!
So, without further ado, here I show a random example struct (the actual names are nonsense), and apply various keyword attributes to some of the fields (also nonsense, but just to show some possibilities for how this could be used/useful):
mutable struct WrapPointedToThing{T} <: AbstractVector{T}
# align the start to 64-bytes (a cache line) and then offset
# by a pointer (to account for type tag)
# and [only] supports atomic access
rcounter(atomic, align=(64, Sys.WORD_SIZE / 8))::Int
# aligned to 32-bytes (just because)
# and also [only] supports atomic access
wcounter(atomic, align=32)::Int
# constant after initialization
tag(readonly)::Symbol
# constant also, and always a reference pointer
something(noinline, readonly)::T
# just a normal field
lock::ReentrantLock
end
Thoughts? Reactions?
xgdgsc and frankier
Metadata
Metadata
Assignees
Labels
No labels