Skip to content
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

Do not use nilable Pointers #13710

Merged

Conversation

HertzDevil
Copy link
Contributor

These uses do not distinguish between a null pointer and nil, and dropping the Nil reduces the space used (every IO::Buffered now occupies 16 less bytes on 64-bit systems).

The same effect could also be achieved by supporting nilable pointers at the ABI level, similar to how Proc? has the same binary representation as Proc. That approach is not without its own problems:

proc = Proc(Nil).new(Pointer(Void).null, Pointer(Void).null)
proc                  # => #<Proc(Nil):0x0>
!!proc                # => true
proc.as(Proc(Nil)?)   # => nil
!!proc.as(Proc(Nil)?) # => false

@straight-shoota straight-shoota added this to the 1.10.0 milestone Aug 15, 2023
@straight-shoota straight-shoota merged commit d0ad027 into crystal-lang:master Aug 16, 2023
53 checks passed
@HertzDevil HertzDevil deleted the refactor/nilable-pointers branch August 24, 2023 12:23
Blacksmoke16 pushed a commit to Blacksmoke16/crystal that referenced this pull request Dec 11, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants