Open
Conversation
Member
Author
|
The weakness of this PR is the lack of unit tests. I had reservations over the unit test code I wrote last year though. So for the moment I am just moving forward anyway. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an initial version of keyword arguments for Pop-11. The objective is to create an easy-to understand, reasonably efficient, reasonably robust mechanism for defining functions with optional arguments. This feature is very helpful in designing clean interfaces and I am looking to make use of it in cleaning up some of the tech-debt I created with the findhelp subcommand.
The strategy I have utilized is to pass optional arguments in a distinctive "pile" of paired keyword and value items that look like this:
Note that TOP & BOTTOM are unique values that are dedicated to marking kwarg-piles. This design makes popping values in the callee reasonably quick when the paired arguments are unique and ordered and the syntax-words all enforce that ordering and non-duplication. This design leads to relatively compact code whilst also coping with situations such as the arguments being duplicated and out of order.
Aside: The main weak point of this design is that it is potentially fragile when dealing with buggy code that steals arguments.