[swift-evolution] [Pitch] Renaming sizeof, sizeofValue, strideof, strideofValue

Brent Royal-Gordon brent at architechies.com
Thu Jun 2 06:26:31 CDT 2016


> /// Returns the contiguous memory footprint of `T`.
> ///
> /// Does not include any dynamically-allocated or "remote" storage.
> /// In particular, `size(of: X.self)`, when `X` is a class type, is the
> /// same regardless of how many stored properties `X` has.
> public func size<T>(of: T.Type) -> Int
> 
> /// Returns the contiguous memory footprint of  `T`.
> ///
> /// Does not include any dynamically-allocated or "remote" storage.
> /// In particular, `size(of: a)`, when `a` is a class instance, is the
> /// same regardless of how many stored properties `a` has.
> public func size<T>(ofValue: T) -> Int
> 
> /// Returns the least possible interval between distinct instances of
> /// `T` in memory.  The result is always positive.
> public func spacing<T>(of: T.Type) -> Int
> 
> /// Returns the least possible interval between distinct instances of
> /// `T` in memory.  The result is always positive.
> public func spacing<T>(ofValue: T) -> Int
> 
> /// Returns the minimum memory alignment of `T`.
> public func align<T>(of: T.Type) -> Int
> 
> /// Returns the minimum memory alignment of `T`.
> public func align<T>(ofValue: T) -> Int

If `type(of:)` takes an instance, then I think `size(of:)`, `spacing(of:)` and `align(of:)` need to do the same, with `size(ofType:)`, `spacing(ofType:)`, and `align(ofType:)` handling the type side of things.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list