On Thu, 13 May 2010 22:19:23 Henk Langeveld wrote:
> Hi Andrew,
>
> Relax.
>
Oh I am relaxed. It was gently pointed out to me before Christmas that
(( )) has benefits, and it's taken me this long to choose to put in the
effort. I believe the poster rather politely pointed out that it's a pet
peeve of his when [[ ]] is over-used "15 years after (( )) has been
added" or something to that effect. I could see the point he was trying
to make.
> > I'm way overdue for changing my habit of using [[ ]] and replacing
> > it with use of (( )) where appropriate.
>
> You're not. You will use both, and each has its own purpose.
> For this exercise in particular, [[ ]] is sufficient.
>
Until I learn the power and weakness of (( )) I won't know when to use
it. I literally haven't used it in the 15 years I've been using ksh. I
do think I'm overdue. Lots of things are turning up in ksh that I
haven't begun to look at: discipline functions, compounds, .... In the
next few years I plan to set myself little goals to learn about these
things ;-) In a very relaxed manner of course!
> > But neither could be considered neat, clean or simpler to read than
> > the original. Generally my scripts never work hard enough to care
> > about microseconds of efficiency, so cleaner more readable code
> > wins nearly every time. Better efficiencies are to be had with
> > algorithm or paying attention to I/O in my kind of script.
>
> The basic problem is one of complexity and clarity.
>
> You're trying to combine three tests into one.
>
Which is fairly reasonable in programming. Sometimes a test is more than
if a > b
> As usual, it would be good to know the context; what is
> the problem you're trying to solve?
>
The expression says, if a list is is asked for, OR there's more than one
argument AND we're really talking to a terminal, then .........
I need to check it's talking to a terminal because this is a function
for programmers off the command line but it is also used in cron scripts
to pick settings. If it's not a terminal then it has to be quiet and not
prompt for things.
> Without that knowledge, the best we can do is explain *what* we test
> for, but not *why*. A bit of analysis and (re)naming of bits goes
> a long way, though.
>
I feel the original expression stands alone as an "exercise" for the
purposes of learning.
> We're still left with '$list' and if the only possible values
> are '' or 1, I guess it is not properly named.
>
It's assigned from a -l option off the command line, and I admit it is
badly named. My usual convention is different. This flag requests a
listing of certain items.
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users