Recent

Author Topic: Not in & is not  (Read 998 times)

bytebites

  • Hero Member
  • *****
  • Posts: 751
Not in & is not
« on: September 13, 2025, 08:59:43 pm »
Delphi 13 introduced "not in" and "is not" operators, which are one more pain for the parser.

AlexTP

  • Hero Member
  • *****
  • Posts: 2615
    • UVviewsoft
Re: Not in & is not
« Reply #1 on: September 13, 2025, 11:53:35 pm »
'not in' allows to remove brackets-level: not (a in v_set).
It is good idea.
Same for other one, maybe.

Bart

  • Hero Member
  • *****
  • Posts: 5610
    • Bart en Mariska's Webstek
Re: Not in & is not
« Reply #2 on: September 14, 2025, 01:52:50 am »
What's next: not =?, not <? not is not in?

Bart

Thaddy

  • Hero Member
  • *****
  • Posts: 18304
  • Here stood a man who saw the Elbe and jumped it.
Re: Not in & is not
« Reply #3 on: September 14, 2025, 07:23:12 am »
Links: https://docwiki.embarcadero.com/RADStudio/Florence/en/What%27s_New#Updates_to_the_Delphi_Compiler
https://docwiki.embarcadero.com/RADStudio/Florence/en/Expressions_(Delphi)#The_is_not_and_not_in_Operators

They also finally copied our {$push}{$pop} with a slightly different syntax of course....

I like the new option that lets you specify the long name of a compiler define in {$ifopt}
« Last Edit: September 14, 2025, 07:42:46 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

AlexTP

  • Hero Member
  • *****
  • Posts: 2615
    • UVviewsoft
Re: Not in & is not
« Reply #4 on: September 14, 2025, 02:35:51 pm »
What's next: not =?, not <? not is not in?

'not =' is the same as '<>'.
'not <' is the same as '>='. In these cases 'not' is unneeeded.

Bart

  • Hero Member
  • *****
  • Posts: 5610
    • Bart en Mariska's Webstek
Re: Not in & is not
« Reply #5 on: September 14, 2025, 10:09:36 pm »
'not <' is the same as '>='. In these cases 'not' is unneeeded.
I was aware of this.
I was just trying to express my dismay about this abomination.

Bart

Leledumbo

  • Hero Member
  • *****
  • Posts: 8831
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Not in & is not
« Reply #6 on: September 14, 2025, 11:17:54 pm »
Just a syntactic sugar, has no real value. However, I've been on sugar free diet for almost 2 years now, never feel better, so I have no support for the idea. Maybe if someone is interested in implementing, keep it under {$mode delphi}.

Warfley

  • Hero Member
  • *****
  • Posts: 2020
Re: Not in & is not
« Reply #7 on: September 14, 2025, 11:44:58 pm »
The "is not" is certainly a breaking change, as the following is completely valid pascal (even though if you ever write something like this you should probably question your life choices):
Code: Pascal  [Select][+][-]
  1. type
  2.   TTest =record end;
  3.  
  4. function Test: TTest; begin end;
  5.  
  6. operator not(x:TTest): TClass;
  7. begin
  8.   Result:=TStrings;
  9. end;
  10.  
  11. begin
  12.   if TStringList.Create is not Test then
  13.     WriteLn('Oopsie');
  14. end.

The not-in on the other hand would be easily implementable, even though it would be quite an unecessary change. If it can be overloaded seperately from the in operator it could be used to implement some more efficient lookups for hashsets or something something bloom filter, but outside a few edge cases it wouldn't serve much purpose

Edit: Just fired up D12 and this also compiles as expected:
Code: Pascal  [Select][+][-]
  1. type
  2.   TTest = record
  3.     class operator LogicalNot(x: TTest): TClass;
  4.   end;
  5.  
  6. class operator TTest.LogicalNot(x: TTest): TClass;
  7. begin
  8.   Result:=TStrings;
  9. end;
  10.  
  11. function Test: TTest; begin end;
  12.  
  13. begin
  14.   if TStringList.Create is not Test then
  15.     WriteLn('Oopsie');
  16. end.
« Last Edit: September 15, 2025, 12:10:02 am by Warfley »

LeP

  • Jr. Member
  • **
  • Posts: 57
Re: Not in & is not
« Reply #8 on: September 15, 2025, 11:59:01 am »
Edit: Just fired up D12 and this also compiles as expected:
This doesn't work anymore in D13.
« Last Edit: September 15, 2025, 12:07:34 pm by LeP »

 

TinyPortal © 2005-2018