ID:2311490
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
This would be useful so when you have a list as a default value you can add to the list instead of having to copy the whole thing or add to it in New()

Possible example syntax
/mob
name = "Foo"
var/list/eye_colors = list("black", "brown", "green")

/mob/special
name = "[name] the weird"
eye_colors = eye_colors + list("red", "purple", "gold")
You should be doing it in New()
(Or, since this is most likely about SS13 code, Initialize())

The hidden .init() proc is bad.
In that case initial(special_mob.eye_colors) would return the parent default value. If you want a default value to have a list the same as the parent's but with additional entries you need to duplicate the entire list in the child.

The compiler already handles default class values, this would just extend that functionality a bit.
Well first of all initial(special_mob.eye_colors) is nothing, because you can't get an initial value of objects/lists.

Secondly, what would your new eye_colors = eye_colors + list("red", "purple", "gold") definition do? It wouldn't do anything you can't already write:
/mob/special/New() //(or /Initialize() for SS13)
..()
eye_colors += list("red", "purple", "gold")

This FR just seems like needless sugar.
It extends the list of the parent type, vars that are default as of compile time don't take extra memory or require processing time in new.

The fact initial doesn't get lists is irrelevant here, the point was to illustrate that default vars are different than just setting the var after creation.

This method is more in line with good oop practice than setting the whole list in the class definition as it extends the older default value rather than completely overriding it.
In response to Ninjanomnom
The ability to override initial values of inherited members is pretty unique to DM. I wouldn't really call it "good OOP practice" to extend it further instead of using New() like everyone else.
In response to Ninjanomnom
You don't want the processing time in New()?
Yet you want it in the definition, which has to create and call a proc called init() (this proc is where all definition defined initialisations happen, including lists)

new /type/path () -> /type/path.init() -> /type/path.New()

You've eliminated nothing, just moved it.
^

DM's syntax basically is designed to allow you to avoid boilerplate like initializing things in New().

That's not to say though, that it's a complete solution or that it always should be avoided.