Skip to content

Conversation

@StefanSosic
Copy link

image

image

image

image

image

@mexby
Copy link

mexby commented Sep 10, 2025

With the "new" continue statement, I think we could go a step further and maybe say "use early exit/continue wherever possible".
In this case, we should only have a single query, and we do want to process its result whenever possible.
Using your example:

internal procedure FindSetWithoutIsEmpty()
var
    Customer: Record Customer;
    i: Integer;
begin
    for i := 1 to 10 do begin
        Customer.SetRange("Country/Region Code", 'RS');
        if not Customer.FindSet() then
           continue;
       // Now we definitely have data we can process
       // ...
    end;
end;

Another example:

internal procedure ProcessDECustomers()
var
    Customer: Record Customer;
begin 
    Customer.SetRange("Country/Region Code", 'DE');
    if not Customer.FindSet() then
        exit;

    repeat
        // Process data here...
    until Customer.Next() = 0;
end;

What do you think?

@KOTRET
Copy link

KOTRET commented Sep 24, 2025

@mexby using early exit like this is horrible for me, but maybe you'd better post this question in the right thread: #253

Related to this PR: maybe it should be more clear that not IsEmpty() + FindSet() is an antipattern, the title of this best practice indicates the opposite.

@JeremyVyska
Copy link
Collaborator

This one is well crafted, but maybe we should do a chat sometime and reconcile with the Discussion thread on it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants