Closed tueda closed 2 years ago
Now setup parameters are supported. Example:
cat <<END | form -stdin
#:workspace 1234K
#:wtimestats on
On setup;
S x;
L F = (1+x)^2;
P;
.end
END
Squashed into one commit. Ready to merge (once the others agree).
Possible improvement: currently the stdin is read one by one, for simplicity, by ReadFile(stream->handle,&c,1)
in ReadFromStream
.
Normally for stdin as file input - is used, if - must be given as parameter to program it's -- -.
Can -stdin be replaced by - for consistency among other command line software? so it should just be form -
I think -
for stdin is a reasonable choice.
By the way, the PADXXX
macros are useless, memory inefficient, and moreover hard to merge two changes! (Now this branch is non-trivially conflicting with the master...)
Now the filename -
means stdin.
Is this change still ready to be merged?
It seems that there are no conflicts with the current master branch (though the current master fails to pass the tests and travis-ci.org is dead), but probably it has conflicts with 5.0 via PADXXX
, I guess.
I've changed the pull request so that the banner is printed first and the line echoing is disabled. Now form can be used pretty cleanly from the command line as if it were an interpreter! I imagine this may be useful when teaching form.
@tueda can you check if moving the header print is safe for parFORM? If so ,we can merge it :)
We can ignore ParFORM for now because MPI doesn't automatically broadcast stdin (see, for example, https://stackoverflow.com/q/49016638) so it doesn't work anyway. I have added an error message for the case where -
is specified in ParFORM.
You can use "Rebase and merge" (or "Squash and merge" if you want).
I've moved the printing of the header, even when we don't use stdin mode. I think it's safe (MsgPrint
needs to be initialized, etc).
36f5536 causes tform's header to always state "-1 workers", by the way.
Right, I've confirmed that git revert 36f5536
fixes "-1 workers".
If PrintHeader
is called before DoTail
, then any command-line options like -w4
are not processed yet (i.e., AM.totalnumberofthreads
is 0
), so tform
has to print "-1 workers", I guess.
Actually, this also breaks the -q
option, the header prints regardless.
Maybe a solution would be:
PrintHeader(1)
back to just before IniVars()
, andAM.silent = 1
(as the -q
option) instead of AC.NoShowInput = 1
for -
(stdin),though I'm not sure what is the exact differences between AM.silent = 1
and AC.NoShowInput = 1
.
A safer option:
PrintHeader(1)
,AC.NoShowInput = 1
for -
(stdin), andPrintHeader(1)
if AM.FromStdin
is 1
.By the way, if FORM always doesn't print the version header for the stdin case, how can one know the exact version of FORM running? Currently, parsing the version header is the only way to know that.
form
has a -v
option to only print its version and exit?
@tueda I'll push your latest suggestion. I've tested it and it seems to work. Running form without any arguments or with -v
still prints the version.
form has a -v option to only print its version and exit?
Yes, indeed this seems to be enough. The user program may run FORM twice, form -v
to check the version and then form -
for the main program. (For python-form
, I wrote code checking the version and running the main program in one-go, without the stdin mode.)
I'll push your latest suggestion. I've tested it and it seems to work. Running form without any arguments or with -v still prints the version.
Nice! Go ahead.
Work in progress. This is an experimental implementation of #264. Example:
Setup parameters (
#:...
) are not supported yet.It also works with Windows (an binary available in AppVeyor: https://ci.appveyor.com/project/tueda/form/build/job/5ndaxgejblwqa4ho/artifacts).