[fpc-devel] is not operator
Martin Frb
lazarus at mfriebe.de
Sat Sep 12 12:57:04 CEST 2026
On 12/09/2026 12:12, Marco van de Voort via fpc-devel wrote:
>
> Op 12-9-2026 om 00:12 schreef Mattias Gaertner via fpc-devel:
>>
>>
>> Orthogonality can be confusing, when it makes the language harder to
>> learn, or it creates ambiguous cases, e.g. due to precedence levels.
>> That's not the case for "is not", or "not in". Even non Pascal
>> programmers immediately understand them (Granted, my test sample is
>> small 😉).
>>
> But since the normal math like syntax not (x is a) is as
> comprehensive, it does not really add much except a few
> keystrokes. And it is not common enough to really make saved
> keystrokes add up.
Its not common enough... Well, maybe its avoided a lot? Chicken or egg?
Btw, FPC (331, few month old) has over 910 of them.
Regex: \bnot\s*\([^(]\s*\S*\s*is\s
And that even excludes any where the 1st arg to "is" has spaces (such as
result of a function call with params, or inlined comment, or array
index with space // array indexed elem exists as arg to "is" )
It does more than saving the keystrokes.
It also save on bracket nesting levels. Which translates to: it reduces
code obfuscation.
"is" (or "not is") is often in boolean expressions,
if (a is TBase) and ( (not (a is TFoo)) or (not (a is TBar)) ) then ...
Ok usually only one of those is an "is", but then there are other
conditions next to the "is", and the "not (.. is ..)" needs one more
bracket level, and the start/end of each nest level become harder to find.
(rewriting to have the not further out is possible, but then the
original indent is no longer expressed, and that too is obfuscation)
real example from fpc
While (I>=0) and (Not ((Components[i] is ModuleClass) and
(TCustomHTTPModule(Components[i]).Kind<>wkOneShot))) do
The not actually does not apply to the "is" => but you need to look
twice at least, to spot the double "((" that expresses this.
(this is excluded from the count at the start, as the regex insists on a
single opening "(")
More information about the fpc-devel
mailing list