-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support alignof
and instance_alignof
#14087
Support alignof
and instance_alignof
#14087
Conversation
This will become invalid syntax: def alignof(x)
end
alignof(1) This is a breaking change no matter which Crystal version we release it. I see two ways out:
|
There's no feasible way to exclude minor risks of breakage when changing just about anything. If we wanted to avoid accidentally overriding any user-defined features when adding new stuff to the compiler or stdlib, we'd need to take a lot more care and have more frequent major releases to get things out properly. Or we'd need to reserve namespaces for exclusive stdlib use. We don't have any of that and I don't think we need it. In this case, the names are very specific and pretty clearly pointing towards something that you would expect as a compiler feature. I think it's totally fine to proceed with this PR. |
The thing about |
@HertzDevil Your commitment to BC is applaudable. In this case though I think it's an acceptable risk, given how much effort would be needed to do it "safely" and the low probability of the name clash due to the very technical term. GitHub search shows only 7 files containing that phrase and none of it seem to be problematic (in that sense). |
Third way out: allow |
I think it's best to avoid the gymnastics to avoid any breakage and let it be. As said, there aren't many occurrences of the word in the wild, so I don't think we need to be that overcautious here. If we get a report we can revert it for 1.11.1 and consider an alternative. |
Resolves part of #14033 (does not include support for members within aggregates).
They are direct analogs of
sizeof
andinstance_sizeof
for the most part, so these nodes' implementations should equally be similar in the compiler. The only difference is thatLLVMABIAlignmentOfType
returns aLibC::UInt
rather thanLibC::ULongLong
forLLVMABISizeOfType
. On the other hand, note thatLLVMAlignOf
does produce a 64-bit LLVM value likeLLVMSizeOf
.