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

make sizeof a builtin #5406

Closed
StefanKarpinski opened this issue Jan 15, 2014 · 4 comments
Closed

make sizeof a builtin #5406

StefanKarpinski opened this issue Jan 15, 2014 · 4 comments
Assignees
Milestone

Comments

@StefanKarpinski
Copy link
Sponsor Member

Since the role of sizeof is to tell you the size of the representation of an object, it seems sensible to make it a builtin since the system itself is in the best position to know this. This is one of the few things that really should not be a generic function. In particular, it would be nice to be able to do things like sizeof((1,2//3)) and get a correct answer.

@JeffBezanson
Copy link
Sponsor Member

I agree, but sizeof has been extended to mean "size of canonical binary representation", in the sense of how many bytes write would write. This is most useful for strings.
So we probably need two functions: a builtin that operates on types and gives the size of the internal representation, and a generic function that operates on values.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jan 19, 2014

add Core.sizeof and leave Base.sizeof unaltered?

@JeffBezanson
Copy link
Sponsor Member

Yeah, we might have to do that. It's hard to accept any alternate names for this function. Maybe nbytes?

@StefanKarpinski
Copy link
Sponsor Member Author

I think I the core vs base distinction is ok and we could have the base version default to calling the core one.

@ghost ghost assigned JeffBezanson Jan 30, 2014
@JeffBezanson JeffBezanson added this to the 0.4 milestone Aug 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants