Re: [ksh93u+m] Performance warning message

Liste des GroupesRevenir à cu shell 
Sujet : Re: [ksh93u+m] Performance warning message
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.unix.shell
Date : 28. Oct 2024, 01:21:17
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vfmldv$ll5i$1@dont-email.me>
References : 1
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 25.10.2024 06:46, Janis Papanagnou wrote:
For this command
 
  typeset -i indents=$(( level * indent_factor ))    ###
 
with two integer variables, 'level' and 'indent_factor', declared
I'm getting this nice warning message
 
  warning: line 28: indents=$(( level * indent_factor ))
      is slower than ((indents= level * indent_factor ))
 
I thought (to avoid the warning) I'd have to split the lines like
 
  typeset -i indents
  (( indents = level * indent_factor ))
 
but I noticed that we can also write
 
  (( typeset -i indents = level * indent_factor ))
 
(I wasn't aware about the 'typeset' command possible in arithmetic
expressions.)

Oops! - That's wrong. - I had just tested that only with 'ksh -n'.

ksh -n  had produced the above performance warning message, but it
did not produce an error message for the (( typeset ... )) syntax,
which I saw just now when invoking the shell regularly on the code.

This is really odd (shell-)behavior! (Reporting a warning but not
an error.) - Looks like a bug to me.[*]

So we have to either use the "non-performant" syntax marked '###'
or separate the statements on two lines.

 
Though I wonder why Ksh doesn't silently optimize the '###' marked
code since Ksh optimizes so many less obvious and much more complex
things.
 
Janis

[*] The man page says for option '-n':
    "Read commands and check them for syntax errors, [...]"
So the warning message is just an undocumented feature for free?
And the 'typeset' inside the arithmetic command is syntactically
okay and deserves no diagnostic message?


Date Sujet#  Auteur
25 Oct 24 * [ksh93u+m] Performance warning message4Janis Papanagnou
28 Oct 24 `* Re: [ksh93u+m] Performance warning message3Janis Papanagnou
3 Nov 24  `* Re: [ksh93u+m] Performance warning message2Martijn Dekker
3 Nov 24   `- Re: [ksh93u+m] Performance warning message1Janis Papanagnou

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal