Do we already have some mechanism to get implicit/automatic documentation of function(parameter)s?
How about supporting something like this:
mixed `->(function(...:mixed), string) Then if there is a sample function:
void foo(int a, string b) { }
Then using foo->doc would return a mapping or string describing the function and/or its parameters (if known and available). Alternately, one could create a function describe(foo) that does the same.
In case of the Google API, it can immediately peruse the discovery information/documentation.
For functions that we do not have any information stored/attached, Pike could simply show the function declaration(s).
Then using foo->doc would return a mapping or string describing the function and/or its parameters (if known and available). Alternately, one could create a function describe(foo) that does the same.
I am not a fan of the suggested f->doc syntax, what would be the reason to start using -> in this entirely new way for this one thing only?
Tobias S. Josefowitz @ Pike developers forum wrote:
Then using foo->doc would return a mapping or string describing the function and/or its parameters (if known and available). Alternately, one could create a function describe(foo) that does the same.
I am not a fan of the suggested f->doc syntax, what would be the reason to start using -> in this entirely new way for this one thing only?
Well, not that I strongly advocate it, but it would relieve pressure from the global namespace in case you decide to create a new function call as describe() which might conflict with existing code. I just happened to notice that function-> is complete unused, as such.
Well, not that I strongly advocate it, but it would relieve pressure from the global namespace in case you decide to create a new function call as describe() which might conflict with existing code. I just happened to notice that function-> is complete unused, as such.
Right, I see, but I would argue this is pretty much a non-issue. If you happen to have preexisting code that has a describe() in scope, that one will take precedence, and if you want to call the global one you can always do so via predef::describe(), and you'd only have to do that in new code using the new global describe() anyway.
If you want to introduce a function called describe() in code where you already use the global describe(), I think having to search and replace describe() with predef::describe() is actually quite an acceptable "burden". But normally you probably simply would not get the idea to call a function the same as one that you already use.
If you want to introduce a function called describe() in code where you already use the global describe(), I think having to search and replace describe() with predef::describe() is actually quite an acceptable "burden". But normally you probably simply would not get the idea to call a function the same as one that you already use.
Also if this direction is your concern, you could also call it, for example, Pike.describe(), and that way it can even work for non-functions, i.e. say programs etc, where p->doc would be an issue as that currently would for example access "constant" members called doc and since a "constant doc" is really not unfathomable to exist in user code, could be problematic as well with the -> scheme.
pike-devel@lists.lysator.liu.se