p4lang / p4-spec

Apache License 2.0
177 stars 80 forks source link

Allow compile-time concatenation of strings #1297

Open vlstill opened 3 months ago

vlstill commented 3 months ago

Currently the spec does not allow any operations on string. I think it would be useful to relax this a little bit and allow compile-time concatenation of strings.

I can see two options for syntax for this:

I believe the first option is superior, even though the second could be a little more CPP-friendly, but personally I find it quite peculiar.

In compiler, this could be handled by constant folding. It would also impact type checking.

jonathan-dilorenzo commented 3 months ago

Discussed in the P4 LDWG. Generally supportive of this suggestion. We are planning to go with option 1.

@vlstill will write a PR to support this in the compiler and a suggestion for amending the spec accordingly.