Skip to content

Order of operations in SET #28

Open

Description

@mzuenni

In which order are the arguments of SET evaluated, if we have something like this: SET(a=2,b=a+a)?

  1. first all right hand sides are evaluated and then the assigned, i.e., like this python code: a,b=2,a+a
  2. from left to right like this python code: a=2; b=a+a

It seems like the current implementation behaves like 2. even though 1. would be more natural. Checked with this snipped:

SET(a=1)
SET(a=2,b=a+a)
ASSERT(b==2)

Activity

  1. changed the title [-]Order of operations[/-] [+]Order of operations in SET[/+] on Mar 7, 2026
  2. eldering commented on Mar 14, 2026

    @eldering
    Member

    The second is the current behaviour indeed, see https://github.com/DOMjudge/checktestdata/blob/main/libchecktestdata.cc#L271-L273.

    I'd be inclines to say that the order is implementation defined, so if you want to make sure that SET(a=2,b=a+a) behaves as you expect, you write it as two separate SET commands.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions