Make it possible to run program from stdin or args
In python, you can write python -c 'print(42)' to start an interpreter on the input. Similarly, it would be nice to be able to write futhark run -c 'iota 42' or echo "iota 42" | futhark run - to run the interpreter on some simple input.
This should be pretty easy - I'd look at the implementation of futhark repl to see how to type-check and run arbitrary expressions.
Actually, upon further consideration, we should probably not allow the echo "iota 42" | futhark run - form, since standard input is usually used for input to the program being run.
Yes. Also, using - for stdin is a relic of (never-existent?) primordial times; we have a word for stdin: /dev/stdin.
But anyway, just -c exp is what we should support (too bad -e is already taken for something else).
[from chat on gitter] since futhark run completely changes behaviour when -c is provided, futhark eval is a possible subcommand this functionality can come under.
For this hypothetical futhark eval, I suggest that it optionally takes a file to load before evaluating expressions, and then any number of expressions. Usage examples:
$ futhark eval '2+2'
4
$ futhark eval '2+2' '1+1'
4
2
$ futhark eval -f foo.fut 'some_function_from_foo 2'
1.41421356237
I don't like that futhark eval differs from futhark run and futhark eval (and pretty much every other command) in taking the file as a named option instead of a positional one. Perhaps the file should be positional and the expressions passed as options?
Would it make sense to have a --backend argument to futhark eval?
I don't like that
futhark evaldiffers fromfuthark runandfuthark eval(and pretty much every other command) in taking the file as a named option instead of a positional one. Perhaps the file should be positional and the expressions passed as options?
I think in this case it is reasonable enough to take the file as a named option. Surely, passing expressions is the norm, while passing files is the exception?
Would it make sense to have a --backend argument to futhark eval?
It uses the interpreter.
Surely, passing expressions is the norm, while passing files is the exception?
Is the norm to use exclusively the builtin prelude? I don't know.
Is the norm to use exclusively the builtin prelude? I don't know.
I'm thinking with respect to futhark eval. The purpose of that function is the take an expression as an argument and evaluate it, right? Then it would seem weird to hide the passing of that expression behind a flag, I think?
which flags should futhark eval support?
I am currently assuming it takes arguments of form futhark eval options... <exprs...>. I suggest:
--no-warnings, same asfuthark run's option--load, load a file before executing the expressions
I would prefer --file instead of --load, mostly because the short option can then be -f.