p4-spec icon indicating copy to clipboard operation
p4-spec copied to clipboard

Side effects in select expressionList

Open jafingerhut opened this issue 5 years ago • 2 comments

By select expressionList, I mean the expression list e1, e2, ... in transition select (e1, e2, ...) { .... }.

If we follow the clarification in the spec made with PR #834, then side effects should be explicitly allowed in the expression list e1, e2, ..., and all side effects of e(i) should take effect before e(I+1) begins evaluation.

Otherwise, we could consider instead disallowing side effects in these expressions, as was proposed in PR #831

I do not believe there is any urgency to resolve this before spec version 1.2.1 is released, if we want to bring it up in a LDWG meeting before deciding which way this should go.

jafingerhut avatar May 07 '20 07:05 jafingerhut

Perhaps we should pick up this issue again in the design working group.

mihaibudiu avatar Jan 21 '22 01:01 mihaibudiu

I thought all lists/arguments are evaluated left to right? I was going to treat it like a list so it just works correctly.

Adding this makes sense:

The `expressionList` just like a `{}` list is evaluated from left to right prior to the invocation of the select itself.

Right after:

In a `select` expression, if the `expressionList` has type `tuple<T>`,
then each `keysetExpression` must have type `set<tuple<T>>`.

This is just like all other expressions and all.

apinski-cavium avatar May 19 '22 04:05 apinski-cavium

In the interest of tidying up the set of active issues on the P4 specification repository, I'm marking this as "stalled" and closing it. Of course, we can always re-open it in the future if there is interest in resurrecting it.

jnfoster avatar Nov 11 '23 12:11 jnfoster