Closed iynehz closed 1 year ago
The problem is that default arguments are expressions, not values. When you do something like
fun foo($x = bar()) {}
foo(42);
, the bar()
expression is never evaluated (since the default argument is not used) and bar
is never called. The only thing you could potentially get is the source code of the expression in string form, but I'm not sure how I'd even do that. F:P doesn't know how long a default argument is or where it ends; it just calls back into the perl parser, which consumes an unpredictable amount of source code and returns an optree fragment.
Looks like now it can get only the arguments names, but not defualt values in case of optional argument. I would be interested in having that feature. For example, it can be used to generate from a function a string for its complete function signature, which can be used in automatic generating the function's doc POD, useful in mid-to-large scale projects.