Get current method name?
BlitzMax Forums/BlitzMax Programming/Get current method name?
| ||
Is it possible to get the name of the current method/function that is running using reflection? If so how? To clarify Method GreatMethod() Print "Method name " +AmazingGetMethodNameFunction() End Method Would return: "Method name GreatMethod" Thanks! |
| ||
I can't see how this can be done other than the obvious : method greatmethod() print "Method name greatmethod()" end method |
| ||
There is no reason to know from within which method you call through reflection, as you ARE within the method and know it actually. Reflection is only needed if you have an object and want to know what functionality it offers. |
| ||
That's fine - it wasn't a big issue, just wondered if it was possible. I was looking for a way to make my error logging routines more generic. In the same vein, it would have been especially nice if I could have used reflection to offer up the name of the caller (ie, the method that called this method). |
| ||
If you create a debuglog system which adds a 'Function/method nnn entered' and 'Function/method nnn exited' you can get a debug trace. Maybe a profiler with different levels of support : 1 = Perfo, 2 = Trace, 1+2 = Both? |
| ||
Yes Tony that's what I've already got. Trying to save some typing and neaten it up, that's all :-) Perhaps some pre-processor/macro system would serve me better here, but I'm not quite sure I'd like to go there at this point. |
| ||
As long time ago I used that method to add statements to the Bmax source and got some really good information on the workflow. There is another thread somewhere asking if it can be added to the IDE (or somebody's IDE). |