Skip to content
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

Simplify clasp text output customization. #490

Merged
merged 1 commit into from
Mar 20, 2024
Merged

Simplify clasp text output customization. #490

merged 1 commit into from
Mar 20, 2024

Conversation

BenKaufmann
Copy link
Contributor

  • Update clasp and simplify CustomTextOutput

Copy link
Member

@rkaminsk rkaminsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this up. However, I think it is not quite the same. This would break systems, which want to print something after clasp printed its model. Now they can only print something before if they want to use the default printer. Systems like clingcon or clingo-lpx won't be affected because there I took over printing completely but it is still a break.

@BenKaufmann
Copy link
Contributor Author

However, I think it is not quite the same. This would break systems, which want to print something after clasp printed its model. Now they can only print something before if they want to use the default printer. Systems like clingcon or clingo-lpx won't be affected because there I took over printing completely but it is still a break.

Hm, I'm obviously missing something then.

From my understanding, both versions should do the same.

  • Both the old and the new code only use CustomTextOutput if there is a printer, i.e. app_->has_printer() is true.
  • In the old code, CustomTextOutput directly replaced the base classe's printModel() function (with a nearly verbatim copy) and:
    1. only forwarded to the base version if there's no control object. Otherwise,
    2. checked whether the model should be printed and if so first invoked the printer and then afterwards in the (optionally invoked) callback forwarded to printValues() of the base class.
    3. Finally and only if x == optQ(), printMeta() of the base class was invoked
  • In the new code, the base class TextOutput gained a new virtual function printModelValues(), which is called from TextOutput::printModel() only after the "should we print this model" check returned true.
    1. CustomTextOutput` overrides this function and again first invokes the printer.
    2. Only if the printer invokes the callback, CustomTextOutput then calls printModelValues() of the base class, which (as previously) calls printValues().
    3. Finally and only if x == optQ(), printMeta() is invoked from the base class implementation of printModel().

Could you please help me figure out where I went wrong?

@BenKaufmann
Copy link
Contributor Author

BenKaufmann commented Mar 20, 2024

@rkaminsk Sorry for the noise. Postponing the call to printModelValues() to after the callback has finished is already a breaking change 😞

EDIT: I updated the PR. Does this address your concern?

@rkaminsk
Copy link
Member

Now it looks like it was before sans the copied code. I think it can be merged like this.

@rkaminsk rkaminsk self-requested a review March 20, 2024 07:47
@rkaminsk rkaminsk merged commit 3d2f2b6 into wip Mar 20, 2024
3 of 4 checks passed
@rkaminsk rkaminsk deleted the simplify-output branch June 20, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants