p4lang / p4-spec

Apache License 2.0
178 stars 80 forks source link

Should we allow even more operations on strings? #1306

Open vlstill opened 2 months ago

vlstill commented 2 months ago

This follows on #1297. It is also connected to p4lang/p4c#4837. Currently strings can only be literals and the string type can only be used to declare extern arguments. With #1297, the concatenation of strings will be allowed. I wonder if we should allow even more operations, turning strings into more "standard" types, although existing still only at compile time (like int!).

Some things that could be allowed:

The first two seem very safe to me.

jonathan-dilorenzo commented 2 months ago

I would generally like the first one.

If we have a real use case for 2 or 3, I suppose I could be convinced, but I suspect enums are better for anything that 2 might be used for and I have trouble imagining where I'd care to use 3.