rhombus-prototype icon indicating copy to clipboard operation
rhombus-prototype copied to clipboard

Make RFC to rename functions related to boxes

Open gus-massa opened this issue 6 years ago • 4 comments

For historical reasons the functions related to box have inconsistent names with other things like hash or vectors. What about renaming them:

unbox -> box-ref

set-box! -> box-set!

new function? -> box-set

make-weak-box -> weak-box

weak-box-value -> weak-box-ref

make-ephemeron -> ephemeron

ephemeron-value -> ephemeron-ref (?)

new function? -> ephemeron-key (Is there a good reason to avoid this?)

gus-massa avatar Jul 21 '19 00:07 gus-massa

I find it useful to use a make- prefix to distinguish between constructors that are generative (multiple calls with same arguments return different values) and constructors that aren't. So I like names like make-box and make-weak-box for mutable boxes. What do you think of this pattern?

jackfirth avatar Jul 21 '19 02:07 jackfirth

There are a few useful naming conventions like this in the docs, and I'm not sure if they're all documented. Should we RFC a catalog of official naming conventions?

dedbox avatar Jul 21 '19 02:07 dedbox

I'm drafting one right now.

sorawee avatar Jul 21 '19 03:07 sorawee

I think the general trend is to remove the make- prefix, like in the constructors in struct definitions, (box x), (vector 1 2 3), ...

gus-massa avatar Jul 21 '19 14:07 gus-massa

Boxes have a value field that can be updated with :=. Following the general convention for mutable fields, Box.value can be used with one argument as an accessor or two arguments as a mutator (i.e., an alternative to :=).

mflatt avatar Nov 21 '24 14:11 mflatt