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

Refactor document classes using Penlight model #1065

Merged
merged 51 commits into from
May 10, 2022

Conversation

alerque
Copy link
Member

@alerque alerque commented Sep 22, 2020

This is long overdue work towards removing stdlib, in this case replacing the class model (the object oriented programming concept) used in SILE classes with Penlight classes.

In some ways this is a follow up to #1064 that started some much-needed code organization so that there would even be something regular to replace. See also #1062 and wiki documentation of this project.

@alerque
Copy link
Member Author

alerque commented Sep 22, 2020

Wow, talk about timing. Penlight 1.9.0 finally landed with a fix more multiple inheritance that this work is going to need!

@alerque alerque changed the title Refactor classes using Penlight model Refactor document classes using Penlight model Sep 22, 2020
@alerque alerque force-pushed the penlight-classes branch 2 times, most recently from fc4458c to 6963475 Compare September 24, 2020 14:20
Versions of Penlight prior to 1.9.0 suffered from issues with class
inheritance beyond one level and with scoping issues in calls to
self:super(). I had worked around these in much of the previous usage by
setting the base class manually and calling it directly in its own scope
rather than using the automated mechanism.

Since those workarounds are no longer needed, this reverts to as
original a generic a syntax as possible.

In the process it was revealed that my workaround was actually much
uglier under the hood than I realized. Rather than inheriting from
ClassC→ClassB→ClassA my workaround actually caused an artificial extra
degree of separation ClassC→plain→ClassB→plain→ClassA where each plain
object was a new class with inherited methods but not actual class
properties.

The final syntax here is verbose and ugly, but it's correct Penlight
class usage. I'm sure I'll eventually settle on a more elegant syntax
for the job, but for now working properly is more important.
@alerque alerque modified the milestones: v0.10.13, v0.11.0 Nov 30, 2020
BREAKING CHANGE: This changes the way classes are represented as Lua
objects and the mechanism used for inheritance. While shims will be in
place to catch most cases that use old syntax it is not possible to
grantee 100% API compatibility. If you have classes that do anything
remotely fancy (i.e. not just copy/paste from SILE examples) they may or
may not work at all; and even if they do they should be updated to
explicitly use the new API.
Having these in a Texlike typesetter at this particular location
introduces a race condition because the typesetter may not be
initialized. We could check for it, but we then limit how the class can
be used and in some use cases it is useful to initialize a class *then*
attach a typesetter to the class's default frame.
@alerque alerque force-pushed the penlight-classes branch from f571675 to 2d4d7c9 Compare May 10, 2022 09:05
@alerque alerque force-pushed the penlight-classes branch from 2d4d7c9 to 0c7b438 Compare May 10, 2022 10:01
@alerque alerque force-pushed the penlight-classes branch 2 times, most recently from 145a49d to 270b1ee Compare May 10, 2022 10:05
@alerque alerque force-pushed the penlight-classes branch from 270b1ee to 41ddeab Compare May 10, 2022 10:08
@alerque alerque force-pushed the penlight-classes branch from 41ddeab to 1ecd79a Compare May 10, 2022 10:26
@alerque alerque merged commit d129207 into sile-typesetter:master May 10, 2022
@alerque alerque deleted the penlight-classes branch May 10, 2022 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant