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

ARGC + ARGV words for pforth scripting #188

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

guberathome
Copy link
Contributor

@guberathome guberathome commented Jan 1, 2025

Shows how to access any argument after '--' on the Pforth command line
as a custom code solution.

notes:

@philburk
Copy link
Owner

philburk commented Jan 2, 2025

Let's defer this until after we decide to do the custom C demo.
Otherwise we will get too many merge conflicts.

@guberathome
Copy link
Contributor Author

Let's defer this until after we decide to do the custom C demo. Otherwise we will get too many merge conflicts.

Fair enough.

Just wondering whether it's ok to implement (ARGC, ARGV) words as a custom hack and not as standard words:
My next custom "example" (sockets demo) will need the ability to pass parameters from the commandline...

@guberathome guberathome marked this pull request as draft January 2, 2025 06:36
@philburk
Copy link
Owner

philburk commented Jan 4, 2025

My next custom "example" (sockets demo)

We have not established the need for these examples. I am mainly interested in bug fixes or improving standard compliance. One problem with examples is that they are often not portable and also require maintenance by me moving forward. You may want to start your own repository of "pforth-examples". I can link to it from my READMEs.

@guberathome
Copy link
Contributor Author

guberathome commented Jan 4, 2025

We have not established the need for these examples.

Fair point.
After all it will be your decision in the end.

Still let me give a quick background of why I'm submitting this series of PRs and finally a quick pitch why I believe this to be beneficial for PForth.

Background:
I dug out an old example (using PForth from shell to send files over sockets) and tried to polish it. So the PRs are submitted sort of "backwards" from my pov.

Pitch:
Documentation is good. A coherent, working (!) example however is priceless.
What I hoped to demonstrate upto this point (even ignoring the somewhat silly socket stuff):

  1. How to pass parameters via TOS (ints in the best case).
  2. How to pass several parameters in and out.
  3. Show that C functions expect zero-terminated-strings, whereas Forth has quasi-Pascal-strings (yes, the length is separate and does not precede the string directly) and how to handle this.
  4. How to build a custom PForth without tears.
  5. One possible way to separate custom and vanilla PForth code
  6. How to see at first glance whether custom code is present in a compiled executable (that's the purpose of the silly f4711 function).

Yes, there is some documentation on how to extend PForth with custom code. But not yet to this extend.
Nothing new, just a slight improvement on what's already here.

I am mainly interested in bug fixes or improving standard compliance

Ok, so doing ARG+ARGV as custom code is the way to do it.

You may want to start your own repository of "pforth-examples"

Frankly that's a bit more than what I had in mind.
Let's call it a last resort and try another solution first.

Edit: One more thing that is shown is how to mitigate different names for gnu make on different systems.
It was however NOT moved to platforms/unix though, since there are other Unixes which I have not tested (e.g. OpenIndiana, OpenBSD).

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