It would be very useful to associate meta-data with functions.
For example, in web frameworks, a page request is usually handled by function in the controller.
Elsewhere, the mapping between URLs and functions is specified.
It would be very useful to be able to write something like this:
sub object_list {
... # page rendering code
} = {
handles_url => '/objects', # the URL this function handles
is_action => 1, # False if this is just a utility function
requires_login => 1, # True if a login is required to access this action
}
The advantages of this are:
- you have all the info about the function in one place
- reviewing the code for correctness is easier.
- things like login checking and sanity checking can be easier.
I'm just curious if:
- you think this sort of function meta data would be useful.
- Has anyone come up with a reasonable way to do it in Perl?
- Are there any other languages that do this sort of thing?