Ability to pass to $exec over stdin
Currently all parameters to $exec are passed as command line args. Command line arguments have a lot of trickiness around shell escaping etc.
The ability to also pass values over stdin to $exec would simplify this and would allow to pass binary data.
The data passed over stdin and as args can also be used for different things e.g. type information over stdin and the names of resulting types as args.
would love to work on this issue, and as I'm new to this repo, would love to know if their are any in-depth docs, might take little time to walkthrough projectt
Nothing in-depth. Style guide and then roughly the code is:
sema*.c - semantic checking
llvm_codegen*.c - codegen
parse*.c parsing
$exec happens during semantic checking.
Things happen in order, so roughly main -> compiler.c -> parsing -> semantic checking -> codegen -> compiler.c -> end
If one wants to look at this, then it's really only the semantic check and parsing, as it is completely folded in the semantic stage.
@Himasnhu-AT are you looking at this, otherwise I'll probably fix it.
If you wish you can go ahead. As I'll take some more time to got through repo
There is one unsolved question though, and that is how to fit this nicely into the current syntax. So currently, $exec is $exec(<script name>, <arg1>, <arg2>, ...). There is no clear way define what is going to go into stdin.
While we can imagine $exec("foo.c3", 23, "hello", .stdin = "okfeokfekf"), it violates the behaviour of other compile time functions, as they never use named parameters.
However, we have the option to parse $exec in a completely unique way, so for example
$exec("foo.c3", "arg1" : "to_stdin"); is possible or even something like $exec("foo.c3", "arg1", < "to_stdin"); or $exec("foo.c3", "arg1") < "to_stdin"; although it's a bit gross.
We can also consider attributes: $exec("foo.c3", "arg1") @stdin("to_stdin") or $exec("foo.c3", "arg1", "to_stdin" @stdin)
None of these alternatives are super attractive though, so I am open to suggestions.
There is now $exec("foo", { "arg1", "arg2" }, "stdin data"), try it out and if it works well – close this.
Okay ill do it. Currently went through project. Will see if their a better way we can implement this functionality
I wanted to avoid fork, which would be the "correct" way to setting up two-way pipes. Putting it in a file could use a temp file instead though.
We can do it these ways:
- Using special delimiter: $exec("foo.c3", "arg1", "arg2" | "to_stdin")
- Named Parameter convention: $exec("foo.c3", "arg1", "arg2", .stdin = "to_stdin")
- Using attributes: $exec("foo.c3", "arg1", "arg2") @stdin("to_stdin")
- Different function: $exec_with_stdin("foo.c3", "arg1", "arg2", "to_stdin")
- inline stdin specification: $exec("foo.c3", "arg1", "arg2" < "to_stdin")
I've implemented it with $exec("foo.c3", { "arg1", "arg2" }, "to_stdin") already, it seems good enough.
okay
@DrSloth is the feature completed as expected?
I'm going to close this because I think it was finished.