On 2016-10-14, Kenny McCormack <
gaz...@shell.xmission.com> wrote:
> In article <
201610141...@kylheku.com>,
> Kaz Kylheku <
221-50...@kylheku.com> wrote:
>>On 2016-10-14, Kenny McCormack <
gaz...@shell.xmission.com> wrote:
>>> In article <
20161014...@kylheku.com>,
>>> Kaz Kylheku <
221-50...@kylheku.com> wrote:
>>>>On 2016-10-14, Kenny McCormack <
gaz...@shell.xmission.com> wrote:
>>>>> I am 99% certain that I saw this as a recent addition to GAWK.
>>>>>
>>>>> That is, that you could do something like:
>>>>>
>>>>> re = @/foo/
>>>>
>>>>If you have intuition for programming language design, it
>>>>immediately strikes you that quoting a regex literal just
>>>>to make it an object is ridiculous; it ought to be
>>>>unnecessary.
>>>
>>> Kaz, usually your responses are logical and useful.
>>>
>>> This time, however, I have no idea what you're on about.
>>> Was this post intended to be at all useful or are you just flaming?
>>
>>Sorry; I got confused by a missing BEGIN in the code! Ha!
>>
>> re = /abc/
>>
>>of course stores, in re, the Boolean result of testing /abc/ against the
>>record.
>
> Right. That's basic AWK 101 - and also GAWK 101.
Yes; /RE/ is not a literal or value, but syntax denoting an operation
which produces a Boolean result.
By the way, given @/RE/, there is no need to call it a "strongly typed"
anything; just a regex literal. Given "STR", that isn't called a
"strongly typed string literal", right?
In principle, this could be supported: @/1.2/ + 3 yields 3.2.
There goes your "strongly typed". Yet, regex wise, it works as before.
> That's why the @ is in there. To tell it that this is a reg exp object to
> be parsed and stored for later use - not an immediate comparison against $0.
I just verified that the very last commit before that aforementioned
one elsewhere in the thread supports this:
$ ./gawk 'BEGIN { re = @/abc/ } $0 ~ re'
1
2
abc
abc
3
4
AFter that commit, it's a syntax error.
Very poor way to treat users.
Given that the @ isn't valid POSIX syntax, why remove it?
Whatever is conceptually wrong with @/RE/, it's hard to justify
replacing working use cases of it with an syntax error in your face!