Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-12

operator in

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marcos Douglas

Why operator 'in' has a limit?

procedure TForm1.Button1Click(Sender: TObject);
var
  t,r1,r2: Integer;
begin
  t := 359;
  r1 := 252;
  r2 := 253;
  if r2 in [r1..t-1] then  // 252..359 so, 253 is include
    ShowMessage('Found')
  else
    ShowMessage('Not found');  // <<<<<<< not found
end;

Marcos Douglas

Jonas Maebe
to Marcos Douglas
Marcos Douglas wrote
Why operator 'in' has a limit?

Turn on range checking and you will get a range check error (turning on range checking when you get strange results should always be the first reflex). Sets are limited to 256 elements because of implementation reasons. One day, large sets may be supported, but that will probably not happen any time soon.

Jonas

Michael Van Canneyt
to Marcos Douglas: Why operator 'in' has a limit? procedure TForm1.Button1Click(Sender: TObject); var…
Marcos Douglas wrote
Why operator 'in' has a limit?

It is limited to byte-sized types, i.e, max 256 elements.

Michael.

Show quoted text 19 lines
procedure TForm1.Button1Click(Sender: TObject); var t,r1,r2: Integer; begin t := 359; r1 := 252; r2 := 253; if r2 in [r1..t-1] then // 252..359 so, 253 is include ShowMessage('Found') else ShowMessage('Not found'); // <<<<<<< not found end; Marcos Douglas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Marcos Douglas
to Jonas Maebe: Turn on range checking and you will get a range check error (turning on range checking…
Jonas Maebe wrote 7 lines
On 27 Dec 2011, at 13:41, Marcos Douglas wrote: > Why operator 'in' has a limit? Turn on range checking and you will get a range check error (turning on range checking when you get strange results should always be the first reflex). Sets are limited to 256 elements because of implementation reasons. One day, large sets may be supported, but that will probably not happen any time soon.

Ok, thank you.

Marcos Douglas