ID:2534755
 
Resolved
A new "assign-into" operator := has been added, which can be overloaded. This allows more flexibility in advanced datum types.
Applies to:DM Language
Status: Resolved (514.1543)

This issue has been resolved.
Obviously we can't overload the standard = assignment operator because it would be a horrendous mess and probably the assumption of assignment actually changing the value stored in a variable instead of modifying an object stored in that variable is a deeply-embedded assumption in the code. As an alternative, could we get some sort of additional operation that takes on this role, something like := or <- or something like that? Then we could do something like
var/Unsigned32/int = new

// Stores the value '123456' (whatever "stores" should be
// taken to mean for the object in question) instead of
// the int variable having that value.
int <- 123456
// or
int := 123456

world << ((int == 123456) ? "True" : "False") // "False"
world << ((int ~= 123456) ? "True" : "False") // "True"
I get the use case you're going for: you want something like where a datum can take an assignment and update its internal values, much like you can assign a char const* to a user-defined string type in C++ and it'll make the necessary arrangements under the hood.

I suppose adding an operator for this purpose might be possible, but it's basically no more than syntactic sugar for a proc call. It'd end up being equivalent to object.AssignSomething() since it'd just be looking up the appropriate operator proc and executing that.
Yeah, I'm aware. I'm more interested in making the object behaving as a "pseudo-variable" more transparent, even though it is very much just syntactic sugar.
What about a property-like syntactic sugar? (Slightly different purpose, I'm aware, but similar in use I think.)

// Better syntax TBD.

/mytype/var/__age

/mytype/proc/__get_age()
return __age

/mytype/proc/__set_age(age)
if (!isnum(age) || age < 0 )
throw // ...
__age = age

// Usage.

var/mytype/m = new
m.age = -1 // Throws.
In response to Hiead
Hiead wrote:
What about a property-like syntactic sugar? (Slightly different purpose, I'm aware, but similar in use I think.)

> // Better syntax TBD.
>
> /mytype/var/__age
>
> /mytype/proc/__get_age()
> return __age
>
> /mytype/proc/__set_age(age)
> if (!isnum(age) || age < 0 )
> throw // ...
> __age = age
>
> // Usage.
>
> var/mytype/m = new
> m.age = -1 // Throws.
>

That would be insanely useful.
In response to Hiead
Properties have been something I've wanted for years. They're incredibly helpful.
I design systems where reassignment of variables directly have consequences. This means I need to train anyone who uses my code how the library or snippet works at a deep level, and field lots of questions as to why my code breaks when you use it in a way the documentation explicitly tells you not to.

This would make Ter a happy bear, able to hibernate in his cave with less disturbances.
This is implemented for BYOND 514. The issue will be closed when the first beta is released.
In response to Lummox JR
What exactly is implemented here?
In response to Kaiochao
There's a new overloadable := operator, which has overload procs defined for some of the built-in datums but for others you'll have to define it yourself. This is called the "assign into" operator.
Lummox JR resolved issue with message:
A new "assign-into" operator := has been added, which can be overloaded. This allows more flexibility in advanced datum types.