sidef icon indicating copy to clipboard operation
sidef copied to clipboard

More support for reflection / introspection

Open catb0t opened this issue 5 years ago • 1 comments

Getting the list of candidate function-or-methods a name might refer to (and for Sidef FOMs, their argument list?), reading a Block's inner/surrounding comments, similar things.

and some of the other kinds of reflection like implemented in Python's inspect, like the current line number or the line number where a variable / overload was defined.

catb0t avatar Nov 11 '18 18:11 catb0t

also, it would be cool to have a method .code or something on Block and function-likes:

{ var a = 1; a += 2 }          # {|_| #`(__BLOCK__|94390607501168) ... }
{ var a = 1; a += 2 }.code     # {|_| var a = 1; a += 2 ... }

the {|_| #`(__BLOCK__|94390607501168) ... } form is good for debugging, but it doesn't allow the user to uniquely identify that block among any other in a program, because we don't know the refaddr in the source code.

For "Blocks" or callables with no Sidef source code, it could be {|_| #`([native code]) } (a sneaky reference to Chrome's JS console doing ƒ toString() { [native code] when showing the definition of a C++ function)

catb0t avatar Nov 12 '18 15:11 catb0t