ID:2830735
 
Resolved
A new nameof() proc, operating only at compile-time, can be used to convert a proc reference into the name of the proc, solving a dilemma faced by multiple Space Station 13 codebases.
BYOND Version:515.1593
Operating System:Windows 10 Pro
Web Browser:Firefox 106.0
Applies to:DM Language
Status: Resolved (515.1594)

This issue has been resolved.
Descriptive Problem Summary:
Can't retrieve proc name for use in call while validating proc existence

Code Snippet (if applicable) to Reproduce Problem:
/mob/proc/funny()
world << "funny base"

/mob/second/funny()
world << "funny second"

/mob/verb/example1()
set name = "static example"

var/static/proc_ref = .proc/funny::name
var/mob/second/F = new()

call(F,proc_ref)()

/mob/verb/example2()
set name = "example"

var/proc_ref = .proc/funny::name
var/mob/second/F = new()

call(F,proc_ref)()


Expected Results:
example1: "funny second"
example2: "funny second"

Actual Results:
example1: runtime error: undefined proc or verb /mob/second/().
example2: runtime error: undefined proc or verb /mob/second/mob().

Workarounds:
Using (#X || type::##X()) and similar constructs but that's compile time expensive

Well, it appears my original thought that .proc/procname::name or type::procname()::name would work was woefully misguided, since the compiler is trying to evaluate name as a var rather than as a constant property.

I'm trying to work out a better way of handling this at the moment. I'll follow up when I have something.
Lummox JR resolved issue with message:
A new nameof() proc, operating only at compile-time, can be used to convert a proc reference into the name of the proc, solving a dilemma faced by multiple Space Station 13 codebases.
I've resolved this with nameof(./proc/funny), or nameof(src::funny()). The new nameof() proc can convert a proc reference to a proc name, so it can be used in call() as it was back in 514.

This also means the NAMEOF() macro can be simplified for vars.

#if DUNG_VERSION >= 515
#define NAMEOF_STATIC(datum, X) nameof(type::#X)
#else
#define NAMEOF_STATIC(datum, X) (#X || #datum.##x)
#endif