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

Mostly doc updates. And macro improvements. #263

Merged
merged 17 commits into from
Aug 21, 2024
Merged

Mostly doc updates. And macro improvements. #263

merged 17 commits into from
Aug 21, 2024

Conversation

gilch
Copy link
Owner

@gilch gilch commented Aug 21, 2024

Still insufficient documentation/tests for a release, but I need to sync this branch up.

Added hissp..refresh# and hissp..subrepl# convenience tags. These are meant for interactive use in the REPL. Only manually tested, but worked.

Reworded lambda text layout. Resolves #262. I found a balance between readability and simplicity I'm reasonably happy with. It sure broke a lot of tests though. I improved the Sybil doctest error messages to make these kinds of test fixes easier.

New deftypeonce replaces deftype. It no longer accepts attributes directly, but can take once-decorators (meaning they don't run again on a reload), which could add attributes, if necessary. Most attributes should be added externally instead, using define or the new defun, which can now target attr paths, not just globals. (This makes set@ feel a little redundant, but that returns the value. define/defun don't.) This setup will patch in method changes to existing instances on a module reload, which makes it feel more like CLOS. The decorator tag @## now works on methods, if made with defun. It can work on deftypeonce as well, but be careful with those. They will re-run on reload, so make sure they're idempotent. set@/zap@ are now based on define, so they can now also target globals. zap@ is good for applying decorators post-definition.

Reworked defmacro in terms of new macro fun, which is a named lambda with optional docstring. (Naturally, defun was also based on this.) Python puts names in three different places for some reason. Adding all those attributes in line is kind of verbose compared to a simple lambda, but is probably worth it for top-level definitions. A defun can also define a function in the _macro_ namespace, if it exists. This makes defmacro feel a little redundant, but it will create a _macro_ for you if you don't have one.

Renamed <<# to <#, enabling the more compact aligned style now recommended in the style guide.

gilch added 17 commits August 14, 2024 19:58
Sphinx likes to generate a few files for inclusion with documentation source with normal usage, but they don't include copyright and license information, so they probably don't care to enforce it. (Just being thorough.)
The macroexpand_all() documentation is more clear this way than for a couple of opaque lambdas as before.
I don't think you'll need a link to document a builtin here. The alternatives might be `globals` or `globals()<globals>`, which seem even more confusing.
This is closer to GitHub's icon for it.
Linter wants me to use \ instead, but I think this is more legible.
Increase gensym prefix separation for legibility
fix inconsistent indent
Simplify Compiler.body
Add drop for lambda as default edge case
fix README
fix whirlwind tour
fix primer
fix compiler doctest
fix inner gensym test
fix test_cmd
fix macro_tutorial
fix macros docstrings
Compile lambda params on one line in simple cases
fix lissp_whirlwind_tour.rst
fix README.md
fix macro_tutorial.rst
fix primer.rst
fix Compiler.function docstring
fix macros.lissp docstrings
And rewrite in readerless.
Add Shadowing subsection
Add Prefer Shorter Definitions subsection
Add Newlines subsection
Expand Comment Styles intro and rationale
ParseLissp error messages now show full compiled output without genysm normalization (in addition to the normed diff), to make doctest updates easier.
Methods should now be defined after the class in most cases. This allows module reloads to patch in existing instaces.

`define` and derivatives (bundled macros beginning with `def`) can now define attributes anywhere, not just globals.

 `set@` and `zap@` can now define globals as well. Unlike a def, they return the value assigned.

 The decorator tag `@#` is now compatible with methods, but not classes, but `once-defftype` has a body of decorators to be applied once and reloadable class decorators can be applied afterward using `zap@`.
Now in terms of the more correct `fun`.
Use a SimpleNamespace for hissp.macros._macro_
Rename once-deftype to deftypeonce
Rename once-define to defonce again
Enables a more compact style that's still aligned.

Use "tag" in place of "reader macro" in definitions
@gilch gilch changed the title Mostly doc updates. And Macro improvements. Mostly doc updates. And macro improvements. Aug 21, 2024
@gilch gilch merged commit dddc0b1 into master Aug 21, 2024
1 of 3 checks passed
@gilch gilch deleted the doc-updates branch August 21, 2024 21:59
@gilch
Copy link
Owner Author

gilch commented Aug 21, 2024

Yep, losing coverage percentage. Mosty due to new features. I think they're working from manual tests, but I'll fix this before the next release.

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.

Compiled lambda text layout could be improved
1 participant