Jürgen, I submitted this patch in a slightly different form once before; it didn't make it into GNU APL.
After having lived with the patch for a while on my own system, I've updated it to the current form. The gist of the patch is to acknowledge redefinition of a ]usercmd with *identical* arguments as being successful rather than complaining about a "BAD COMMAND". The patch does not change the effect of the command, only the report. With the patch, GNU APL will report "User-defined command ]... installed" each time a command is defined with identical arguments. I think this is a better response than complaining "BAD COMMAND" in the same circumstance, given that the behavior actually succeeded. I hope that you'll apply this patch to GNU APL. Best wishes, David
Index: src/Command.cc =================================================================== --- src/Command.cc (revision 294) +++ src/Command.cc (working copy) @@ -837,6 +837,33 @@ return true; } //----------------------------------------------------------------------------- +bool +Command::check_redefinition(ostream & out, const UCS_string & cnew, + const UCS_string fnew, const int mnew) +{ + loop(u, user_commands.size()) + { + const UCS_string cold = user_commands[u].prefix; + const UCS_string fold = user_commands[u].apl_function; + const int mold = user_commands[u].mode; + + if (cnew != cold) continue; + + // user command name matches; so must mode and function + if (mnew != mold || fnew != fold) + { + out << "BAD COMMAND" << endl; + Workspace::more_error() + = UCS_string( + "conflict with existing user command definition" + " in command ]USERCMD"); + } + return true; + } + + return false; +} +//----------------------------------------------------------------------------- void Command::cmd_USERCMD(ostream & out, const UCS_string & cmd, vector<UCS_string> & args) @@ -922,8 +949,12 @@ #define cmd_def(cmd_str, _cod, arg) \ if (check_name_conflict(out, cmd_str, args[0])) return; #include "Command.def" - loop(u, user_commands.size()) - if (check_name_conflict(out, args[0], user_commands[u].prefix)) return; + if (check_redefinition(out, args[0], args[1], mode)) + { + out << " User-defined command " + << args[0] << " installed." << endl; + return; + } // check APL function name // Index: src/Command.hh =================================================================== --- src/Command.hh (revision 294) +++ src/Command.hh (working copy) @@ -121,6 +121,9 @@ static bool check_name_conflict(ostream & out, const UCS_string & cnew, const UCS_string cold); + static bool check_redefinition(ostream & out, const UCS_string & cnew, + const UCS_string fnew, const int mnew); + /// a helper struct for the )IN command struct transfer_context {