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

16f OOP: Frames #40

Merged
merged 15 commits into from
May 3, 2022
Merged

16f OOP: Frames #40

merged 15 commits into from
May 3, 2022

Conversation

ngjunsiang
Copy link
Contributor

@ngjunsiang ngjunsiang commented May 3, 2022

Finally, we're down to the last dict ripe for conversion: the frame.

There's nothing wrong with a dict for a frame; what's going on is I'm tired of repeating helper functions for dealing with frames. These helper functions work primarily with frames and names, and it makes good sense to bundle them together so that we can use those functions wherever the frame goes.

Let's start with a Frame class:
https://github.com/nyjc-computing/pseudo/blob/c1ffed90f1bd74b3e3104c97d247b46cb5eca421/lang.py#L86-L133

@ngjunsiang
Copy link
Contributor Author

ngjunsiang commented May 3, 2022

Lets replace all the places where we treated frame as a dict, reworking them into method calls: [ac30c99], [8d39040], [f176202], [d7180d6]

@ngjunsiang
Copy link
Contributor Author

Yep, we are trying to eliminate all uses of the helper functions for frames; we have replaced them with frame methods.

Since the frame methods don't do type-checking, we still have to keep the error methods, and use them where appropriate. Still, that means we've managed to replace two sets of helper functions (in the resolver and interpreter) with one set of methods (in Frame). Overall, it's still a win for maintainability.

@ngjunsiang
Copy link
Contributor Author

And now we can remove the helpers: [69abe40], [626a343]

@ngjunsiang
Copy link
Contributor Author

ngjunsiang commented May 3, 2022

A couple quick bugfixes: [03b2ba5]

And a nice repr:
https://github.com/nyjc-computing/pseudo/blob/8b2de385fcd6b0e5561312261c94c8e522cb8571/lang.py#L114-L119

And we have a working Frame object 🖼️

@ngjunsiang ngjunsiang merged commit f51b4a0 into main May 3, 2022
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

1 participant