1. apply() flawed?

I think the standard library function apply() could be improved. It demands that the target function (the one to be applied) take two parameters, the second being "userdata", but this makes it not useful for applying any arbitrary function to the elements of a sequence, which I think is kinda the point. Instead of userdata, it should take a sequence of optional additional parameters to be sent to the target function which are simply concat'd to the first parameter (which means that it will also work with target functions that only take one parameter when the additional parameters are set to an empty sequence. As long as the caller knows how many parameters there should be, there is no problem.

Also note this change could be implemented without even breaking the current version, and will serve the same purpose but with more flexibility. Thoughts?

On a side note, something I'd really like to see in a future version of Eu is:

A) Default parameters to work when calling a function via routine_id() -- it appears that in the present version that you must provide all parameters even when defaults are specified in the function being called.

B) In line with this, a built-in that would take a routine_id() (or a name) and tell you how many parameters are expected for that function (and even the types if possible, but that would be tricky with custom types, although it could just call any custom type an object I guess).

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu