ID:2764475
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
We already have the ability to iterate child procs of objects

/datum/proc/p1()
return

/datum/proc/p2()
return

/datum/proc/p3()
return

/datum/proc/p4()
return

/datum/proc/p5()
return

/proc/main() // Treat this as world/new()
var/list/L = typesof(/datum/proc)
world.log << json_encode(L)


Which will output:
["/datum/proc/p1","/datum/proc/p2","/datum/proc/p3","/datum/ proc/p4","/datum/proc/p5"]


What I think would be cool is the ability to put custom annotations above procs. Say for example

@CustomEventHandler
/datum/proc/mything()
return

/proc/main()
var/datum/D = new()
// Iterate the list of procs. This is just a lazy one for typing sake.
if(D.procs.mything.HasAnnotation("CustomEventHandler"))
D.mything() // Call it since it has the annotation


This would allow developers to easily "mark" procs as ones that can be executed at specific events. Maybe I have been spoiled by Java things, but decorators/annotations would be great, even if it required "typing" of procs or something similar.
had a discussion on this - this would be weird for relative proc pathing because it could be confusing or hard on the parsing side

Consider the alternative:
/datum/proc/yourthing() @CustomEventHandler
    return
/mob/proc/mything() as null|num @CustomEventHandler
return
In response to Zewaka
Zewaka wrote:
had a discussion on this - this would be weird for relative proc pathing because it could be confusing or hard on the parsing side

Consider the alternative:
> /datum/proc/yourthing() @CustomEventHandler
> return
> /mob/proc/mything() as null|num @CustomEventHandler
> return
>



How about this?
datum
proc
@CustomEventHandler
mything()


Alternatively, path your codebase properly :P