nim-works / nimskull

An in development statically typed systems programming language; with sustainability at its core. We, the community of users, maintain it.

Home Page:https://nim-works.github.io/nimskull/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

what size should an empty object be?

theSherwood opened this issue · comments

Should empty objects be of size 0? Maybe in some contexts that won't even work.

Example

type
  Empty = object
  Wrapper*[K, V] = object
    node*: (K, V)
echo sizeof(Empty)
echo sizeof(Wrapper[uint8, Empty])

Actual Output

1
2

Expected Output

0
1

Possible Solution

Additional Information

References

It's possible to implement empty objects/tuples/arrays having a size of 0, but I personally don't think it's worth the added compiler/language complexity.