-
Notifications
You must be signed in to change notification settings - Fork 47
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
How Pattern C-struct could look like #13
Comments
I'll point out some details I've noticed and propose some alternatives (doesn't mean they are better, they are just ideas on the table):
[EDIT] Check out this example: https://gist.github.com/ffunenga/5744034 This doesn't compile in C++. The problem is the |
Seems like a reasonable solution. How do you plan to allocate |
Oh, right, we know number of children while we generate code, so we can allocate enough of them. That's better than having a linked list, or separate type for each parent. |
Some questions;
|
|
I've added a new section to the wiki: https://github.com/docopt/docopt.c/wiki#non-recursive-similar-to-pythonic-approach It might be easier to think about the required |
I think I've found a problem that complicates things in STPA... In python, it's simple to make a list and append things to it, since the the garbage collector will take care of it in the end (see here). So whenever an argv's element is not recognized as a Command (i.e. a possible Argument), we just append it to the list as an In C, this approach (list appending) is implemented by malloc'ing unidentified Arguments to a temporary list. We need to decide what is preferable:
What should the docopt.c algorithm do when an unidentified It just occured to me now, but can an
what should happen if I want to name a new ship in this program with the name "ship": $ ./program ship new ship The pattern seems respected because the order and number of elements are correct. Should this work @halst? |
I don't have an immediate opinion or solution to malloc problem. I would really love to avoid malloc at all. But we don't know argv length before run-time. So maybe we could avoid |
See initial structure: https://github.com/docopt/docopt.c/wiki#new-c-struct-ideas
Let's keep the discussion and brainstorming here rather than in wiki. Ideas can be added to wiki afterwards.
The text was updated successfully, but these errors were encountered: