You could do it that way. But that doesn't change the fact that flag_value() ignores "junk" arguments.

And you could fix it your way, but it doesn't change the fact that testing a string for flag names is a silly way to decide whether or not it's a command. ;)

In my humble shoddy-hack artist opinion ;), I don't think it is a good coding practice to allow "junk" arguments to be ignored without at the

Short circuiting flag_value on bad flags isn't shoddy or hackish. It might be a very good idea. I just don't think it fixes this particular problem, it only hides it. My code would work fine with your code.

In fact, I should probably make a new function that does short circuit. But not until I have the time to clean up error reporting when it returns NO_FLAG. I'd have to make a new function because I use flag_value for a lot of things, like reading area files. I'd like that to fail gracefully if I remove a flag or something.

--Palrich.

----- Original Message ----- From: "Snafu Life. (Jonathan L. Potter)" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, December 05, 2004 6:58 PM
Subject: Re: REDIT: north name door bug, searching archives...


I am sorry I should have explained my bug and code a little better. It's been a long time since i wrote here. My apologies.

Mike Barton wrote:
We put in a "<direction> flag <flags>" command.

You could do it that way. But that doesn't change the fact that flag_value() ignores "junk" arguments.


flag_value() accepts multiple flags, ignores anything that is not a flag, and doesn't return NO_FLAG as long as at least one argument is a flag.

What I did was force it to bail if the first argument is not a flag which more than likely means it's a command argument _not_ a flag, i.e. name, key and dig. Depending on how other code is written it could affect other areas of the code as well, I just didn't bother testing to find out. It is broke, fix it. ;)


There is some thought that snips should contain at least one error, so that people understand what the code is doing. I really don't feel that is the way to do it. I would rather give a fix that works (with a better explanation next time) and leave some ideas, which follow...

Mike Barton wrote:
> I'm not sure short circuiting flag_value is the best solution.

very least, logging it so you can find out it is happening. I also would not advise allowing the code to make any changes at all as long as there are junk arguments. In other words, don't short circuit flag_value, change it so that it checks for junk arguments first, bailing if there is one or more, and if there are no junk arguments, go back and start changing things.


Reply via email to