-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Action calls from parsers #151
Comments
One issue to consider is whether such actions can call exit. |
It seems perfectly reasonable that if actions can be called from parsers, then those actions should be limited to things that could be done within a parser, e.g. no return, no exit, no apply on tables, etc. Even with those restrictions, such an action seems useful in some scenarios, e.g. to give a name to that function, and enable using it in multiple places without copy & paste. |
As Mihai has pointed out several times, actions are P4's only function
construct. So this seems natural...
…-N
On Sat, Apr 1, 2017 at 2:13 PM, Andy Fingerhut ***@***.***> wrote:
It seems perfectly reasonable that if actions can be called from parsers,
then those actions should be limited to things that could be done within a
parser, e.g. no return, no exit, no apply on tables, etc.
Even with those restrictions, such an action seems useful in some
scenarios, e.g. to give a name to that function, and enable using it in
multiple places without copy & paste.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#151 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABwi0goefO29vtcLGw040WsSHkE9WHt5ks5rrr3lgaJpZM4MwSRi>
.
|
This should be on the agenda for the next design meeting. |
From a usability/code reuse perspective, it would be nice to know from the type of an action whether it can be used in a parser, rather than having to inspect the body of the action. But maybe this is a longer-term goal... |
In 2017-Apr-10 language design meeting, someone suggested keeping this issue, but changing the title to 'Add functions to P4' (some time after P4_16 first release in May). @mbudiu-vmw Do you have ability to change the title? I don't think I do. Also happy to close this one and open a new one if that is easier. Rationale for not allowing actions to be called from within parsers - actions are intended to be part of a match-action pipeline. It seems a bit too much of a hack to allow calling them from inside parsers. It would be preferable to add functions to P4 vs. using actions in places they were not intended. Below are what I think might be some properties of P4 functions. They have a heavy overlap with properties of actions. The main difference between actions and functions as I describe them below are that actions can have directionless parameters, but functions cannot, and functions can have return values. I realize that maybe my expectations of P4 functions are different than those of others.
|
Adding functions would also solve issue #51 |
@jafingerhut I think we resolved not to take this and think about adding proper functions down the road. If you agree, can we close this? If not, let's update the spec? |
@jnfoster I am perfectly fine with either of these: (a) rename this issue as 'Add functions to P4' and mark it as post P4_16, (b) close this issue and create a new one for adding functions to P4. |
Tagged as post P4_16. |
Since we have functions I think we can close this issue. |
Can parsers directly call actions?
The text was updated successfully, but these errors were encountered: