bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: interpreting a strongly typed regexp constant variable as literal re


From: Manuel Collado
Subject: Re: interpreting a strongly typed regexp constant variable as literal regular expression?
Date: Mon, 1 Jun 2020 11:41:25 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

El 31/05/2020 a las 23:12, pjfarley3@earthlink.net escribió:
ISTM that it is the requirement for the "case" part of the switch
statement to be a *constant* that drove at least part of the
misunderstanding here.

I just reviewed the relevant sections of the gawk 5.0 documentation
myself, and in the section on "strongly typed" regular expressions in
section 6.1.2.2 there is a link to the switch statement section, but
nowhere in the documentation of the switch statement is there an
example of the use of a strongly typed regular expression as a "case"
constant value.  Perhaps there should be such an example there.

Section "7.4.5 The switch Statement"

"Each case contains a single constant, be it numeric, string, or regexp.
The switch expression is evaluated, and then each case’s constant is
compared against the result in turn. The type of constant determines
the comparison: numeric or string do the usual comparisons. A regexp
constant does a regular expression match against the string value of
the original expression."

Please note the explicit mention of the behavior of a regexp constant as a case label.

HTH.
--
Manuel Collado - http://mcollado.z15.es



reply via email to

[Prev in Thread] Current Thread [Next in Thread]