Skip to content

inheriting from disable_action and discard_input together #171

Answered by d-frey
Shaheen47 asked this question in Q&A
Discussion options

You must be logged in to vote

I think there are multiple points of confusion here:

  1. You don't need to avoid calling in.discard() for non-stream inputs (as Colin mentioned). It is an empty method that gets optimized away completely, there is no overhead, so don't be afraid to make our life easy.
  2. If you derive from disable_action and you provide your own apply(), the latter overwrites the former's apply()-method, hence disable_action::apply() is not used and the actions do not get disabled.
  3. Using discard_input as a base class is based on match, not based on apply - hence it will not be affected by disabling actions.
  4. If you plan on writing your own grammar, you can use the discard rule instead of using action class speci…

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by d-frey
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #171 on December 09, 2020 09:23.