Feature suggestion: while matching

Hello,
What do you think about implementing a “while matching” loop?

For example, the following code:

while matching Item := NextItem do ...;

will compile to:

loop begin
  var Item := NextItem;
  if not assigned (Item) then
    break;
  ...
end;

This can be very handy if we need to process elements until we receive a null value.

1 Like

Me like. potentially with an explicit type.

while matching Item: String := NextItem do ...;

would compile to:

loop begin
  var Item := NextItem;
  if not Item is String then
    break;
  ...
end;

Thanks, logged as bugs://84802

I think it should be:

loop begin
  var Item := String (NextItem);
  if not assigned (Item) then
    break;
  ...
end;

So to avoid a double casting

Sorry, yes. Item would be strongly typed ofc.