I've got an object where I would like the compiler to fail if I accidentally
try to copy an instance of it. Overloading proc = seems to be the way to do
this, but I'm struggling to get the exact incantation to also allow for
instantiation. Here is my starting point:
type Person = object
first, last: string
proc newPerson(first, last: string): Person =
result.first = first
result.last = last
proc `=`*[T](d: var Person; src: Person) {.error.} =
discard
let person = newPerson("John", "Doe")
echo person.first, " ", person.last
This blows up on let person = because, as you might have guessed, that calls =.
What is the approach I should take here? And thanks for any help you can offer.