Re: [Module::Build] ask() and you will receive
Status: Beta
Brought to you by:
kwilliams
From: John P. <jpe...@ro...> - 2006-04-18 20:33:20
|
Randy W. Sims wrote: > (b) is not possible. If the user presses <enter> or <ctrl-d> without > typing anything, then the default will be used. So it's not an indicator > of an unattended build. I thought that M::B already knew whether or not the Build.PL was running unattended or not. AFAIUI, there are three modes: 1) the user types something - it has to match one of the entries in @options (and ask() helpfully prompts with the list of allowed values); 2) the user types nothing (<enter> or <ctrl-d>) - the value of default (or "" if none is set) is returned; 3) the script is running unattended - same effect as #2. If M::B can know whether it is executing in mode #3, then the code can differentiate between #2 and #3 already. What is the use case for a default value being something other than one of the prompted values if not to determine whether the script is unmanned or the user wants the code to make it's best guess (which should be the same thing)? > IIUC, Ken's original point was that the 'default' argument could be > mistyped. Requiring the argument to 'default' to also appear in the > 'options' array is a safeguard and requires the author to verify or > explicitly allow the differing value. I strongly agree with this; I like > "safe" APIs. Having been the unwitting victim of Cut/Paste error before, I don't give much weight to "type the same [possibly long] string here, too" types of constraints. > The union of 'default' and 'options' does constitute the exclusive list > of permissible values. It's just that 'default' must be explicitly > declared to be different if it is not a member of 'options'. That's the leap I'm not making. If the author set a default value that represents a "best guess" option that is different than one of the manually typed options, why does there need to be a flag that indicates that this is a valid value too. A simple comparison between the members of @options and $default already indicates that something else is going on. John -- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4501 Forbes Boulevard Suite H Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5748 |