Open jemc opened 7 years ago
Marking this a medium-priority bug, blocked until #1410 is implemented.
Changing the name of the ticket, since this applies not only to Array
, but all other collections with a clone
method as well (List
, Map
, Set
, etc...). Noticed this because my original PR for this issue (#279) included them all.
This is currently blocked
I've written a somewhat lengthy explanation in Zulip about what's going on with the signature of Array.clone
. Maybe it will be helpful to someone reading this ticket, so I'll link to it here: https://ponylang.zulipchat.com/#narrow/stream/189985-beginner-help/topic/Debug.28.29ing.20an.20iso.20passed.20through/near/236037204
It's a quite common pain point in Pony that arrays of
#share
able objects (val
ortag
) cannot beclone
d toiso
orval
, as would be expected (and is the case withString.clone
). This isn't possible because doing so would be unsafe whenA
is not#share
able.This violates principle of least surprise for a lot of our users and we've received three PRs so far of users who were so surprised that they filed a PR to change it (including me, when I was first getting involved with the project). See #279, #1360, #1782.
However, once we have specialization (#1410) we can implement
Array.clone
so that it returnsiso
whenA <: Any #share
, orref
otherwise (as it does now). Doing so would seamlessly resolve the issue for users in the least surprising way.