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

Final (?) perl improvements #439

Merged
merged 5 commits into from
Aug 4, 2019
Merged

Final (?) perl improvements #439

merged 5 commits into from
Aug 4, 2019

Conversation

bjh21
Copy link
Contributor

@bjh21 bjh21 commented Aug 4, 2019

I think I've reached the point where the changes I'm making to the perl implementation aren't actually making it any better, so here are the lest few that I think are actually good. I found a nicer way to implement keywords, eliminated the numbered variables in the special form switch, and documented things a little.

bjh21 added 5 commits August 3, 2019 20:10
Representing a keyword as a Mal::String with a magic first character was
beginning to annoy me, so instead create a proper Mal::Keyword class.
To support using both Mal::String and Mal::Keyword as hash keys,
overload stringification on all Mal::Scalar subclasses.

This means that now instead of a Mal::String stringifying to something
like "Mal::String=SCALAR(0x5744ea58)", it will stringify to something
more like "Mal::String abc", which is readable, has the correct
properties for a hash-map key, and is easy to convert back into a
Mal::String.

This turns out to work perfectly well, and entirely accidentally
arranges that 'keyword' now works properly when fed a keyword as input.
This means that most of the special forms have an assignment at the top
giving names to the members of @$ast.  I think this makes the code a
little more readable.
I feel that it's more perly to directly use Perl's array manipulation
functions.  It's certainly more consistent with the other special forms.
I don't think it's worked on perl 5.8 for a long time.
@kanaka kanaka merged commit e4171bf into kanaka:master Aug 4, 2019
@kanaka
Copy link
Owner

kanaka commented Aug 4, 2019

Looks good. Merged.

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