updated description for Boxing from Zulip discussion

This commit is contained in:
Luke Boswell 2022-10-25 17:20:27 +11:00
parent d85a493abd
commit 74a337d508
No known key found for this signature in database
GPG key ID: 0E908525B2C7BD68

View file

@ -2,14 +2,15 @@ interface Box
exposes [box, unbox]
imports []
## Allocate a value on the heap. Boxing is an expensive processes as it copies
## the value from the stack to the heap.
## Allocate a value on the heap. Boxing is an expensive process as it copies
## the value from the stack to the heap. This may provide a performance
## optimization for advanced use cases with large values. A platform may require
## that some values are boxed.
##
## expect Box.unbox(Box.box "Stack Faster") == "Stack Faster"
box : a -> Box a
## Return a value to the stack. Unboxing is an expensive processes as it copies
## the value from the heap to the stack.
## Returns a boxed value.
##
## expect Box.unbox(Box.box "Stack Faster") == "Stack Faster"
unbox : Box a -> a
@ -21,4 +22,4 @@ unbox : Box a -> a
# boxed
# |> Box.unbox
# |> transform
# |> Box.box
# |> Box.box