ID:2860684
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
On tg we have the idea of an abstract datum. For example, we have /datum/antagonist, which represents all antagonists. All antagonists must implement get_preview_icon(), or else our preferences menu will not look correct. We currently throw a runtime in the base and have an external lint to make sure ..() is not called, and then we validate this in testing.

However, this approach does not work for everything, as we can't guarantee that these procs are called in testing. Right now I am adding a similar preview icon to teams, but I can't create every team in a test without more code, as some teams will want to use their members as part of the icon, or some other round state, which won't be defined/be inaccurate or null.

It would be cool if we could avoid these hacks and use something like virtual T proc() = 0; in C++, or abstract in Java.

I don't care about the syntax, but something like set must_override = TRUE would be good enough.

Ideally this would also stack, so that we can add more abstract subtypes. For example:

/datum/antagonist/proc/get_preview_icon()
set must_override = TRUE

/datum/antagonist/traitor/get_preview_icon()
// my code

// /datum/antagonist/team_based isn't a concrete type, and so we are okay with it not implementing get_preview_icon() as long as its own subtypes do.
/datum/antagonist/team_based/get_preview_icon()
set must_override = TRUE


Instantiating a datum that doesn't override the proc, and then calling it anyway should probably just run whatever is inside the proc body anyway, since we ideally still want ..() to work.
I suggest "set abstract"

The common term for this is an abstract method.

But yeah, I love this.
Boy, this will be a tough one to figure out. Proc overrides effectively look backwards, but there isn't anything in place that could look for procs that weren't overridden. I'll have to give this a lot of thought.
Thank you!