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

Reduce chirality to templates #121

Conversation

countvajhula
Copy link
Collaborator

@countvajhula countvajhula commented Nov 29, 2023

Summary of Changes

This reduces (implicit) chirality of forms as indicated by left- or right-threading to an explicit use of a blanket template (i.e. __) in the expander, as discussed in A Fine-grained Migraine. This simplifies the core language by eliminating the #%partial-application form, and should reduce the number of patterns we need to match in deforestation and other compiler optimizations.

Note that we still retain the concept of chirality in the compiler for handling clos, for now.

Public Domain Dedication

  • In contributing, I relinquish any copyright claims on my contribution and freely release it into the public domain in the simple hope that it will provide value.

(Why: The freely released, copyright-free work in this repository represents an investment in a better way of doing things called attribution-based economics. Attribution-based economics is based on the simple idea that we gain more by giving more, not by holding on to things that, truly, we could only create because we, in our turn, received from others. As it turns out, an economic system based on attribution -- where those who give more are more empowered -- is significantly more efficient than capitalism while also being stable and fair (unlike capitalism, on both counts), giving it transformative power to elevate the human condition and address the problems that face us today along with a host of others that have been intractable since the beginning. You can help make this a reality by releasing your work in the same way -- freely into the public domain in the simple hope of providing value. Learn more about attribution-based economics at drym.org, tell your friends, do your part.)

This simplifies the core language by eliminating the need for
`#%partial-application` as a core form. It also allows us to deal with
the concept of chirality only in the expander and largely deal only in
terms of explicit templates in the compiler.

The only place where we still need chirality in the compiler is in
`clos`, which is a way to pre-supply arguments at runtime rather than
at compile time. There's no obvious syntactic way to designate which
side the pre-supplied arguments should be placed on here. We could
introduce `clos` and `closr` core forms to differentiate these cases
but that doesn't really simplify it (although it would be another step
in the direction of making our core language explicit and not reliant
on syntax properties).
A comment in the code indicated that this wasn't supported for left
chiral forms, but that seems to have been outdated, as this test proves.
@countvajhula
Copy link
Collaborator Author

@dzoep This translates everything inside the compiler to use blanket templates instead of chirality (which by that point is already translated to a blanket template by the expander). It simplifies a lot of patterns, but I haven't modified the patterns for the producer yet, and not sure what kind of complex vindaloo you might be cooking up there. Should I just leave that unchanged in this PR if you are already working on that?

@dzoep
Copy link
Collaborator

dzoep commented Nov 29, 2023

I propose you merge it as-is, I will get my branch in sync and merge my current work with it. Shouldn't be a big problem.

@countvajhula countvajhula marked this pull request as ready for review November 29, 2023 09:05
@countvajhula countvajhula merged commit 5609e15 into drym-org:first-optimizations Nov 29, 2023
1 of 6 checks passed
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.

None yet

2 participants