ID:1678505
 
Not Feasible
Applies to:DM Language
Status: Not Feasible

Implementing this feature is not possible now or in the foreseeable future
I think there should be a proc on /datum level that's called whenever a variable is about to be queried or about to be set.

The purpose would be to intercept and change the behavior of a variable through code, much like how getters and setters are used in other languages.

Default functionality:

/datum/get(variable) return src.vars[variable]
/datum/set(variable, value) src.vars[variable] = value


This (little?) piece of functionality could solve a lot of issues at once by soft-coding them.

The only problem I see with this functionality is that additional overhead is introduced with the call of a proc before every get/set. I'm not sure how it would impact larger projects which query a lot of variables.

Idea: A cached check if the developer has actually overridden the proc could be used to prevent slow-down in projects that don't use it?

An example of a request that could be soft-coded using this feature: http://www.byond.com/forum/?post=1678390
I sure would like this. :)
I'd rather see variable-specific getters and setters; something like /datum/var/MyVar/get() (or set(newValue)). Global getter/setters would be horrendous for performance and tracking down software bugs.
In response to Topkasa
Topkasa wrote:
I'd rather see variable-specific getters and setters; something like /datum/var/MyVar/get() (or set(newValue)). Global getter/setters would be horrendous for performance and tracking down software bugs.

Agreed. That said a way to override on a global scope would be nice too, for purposes of debugging and logging of generic variable modifications.
I suggested this before - is there any way to feasibly do this?

The main purpose here is to catch when a variable is being accessed or modified, and override its value.
Lummox JR resolved issue (Not Feasible)