-
Notifications
You must be signed in to change notification settings - Fork 134
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
Move argv/1 to library(os) #2263
Conversation
@@ -1,5 +1,4 @@ | |||
:- module('$toplevel', [argv/1, | |||
copy_term/3]). | |||
:- module('$toplevel', [copy_term/3, started/0]). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is started/0
exported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loader.pl
uses it and I thought of leaving it as explicit as before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think loader.pl
uses the module-qualified version, so there seems no need to export such a "normal" (i.e., prone to naming conflicts, even though no program likely needs it) name?
I think this might be wrong in case the list of arguments contains more than one instance of E.g. $ cargo run --release -- -f -- -t -- hello
Finished release [optimized] target(s) in 0.12s
Running `target/release/scryer-prolog -f -- -t -- hello`
?- os:argv(V).
V = ["-t","--","hello"].
?- os:argv(["-t"|_]).
true.
?- os:argv(["--"|_]).
false.
?- os:argv(["hello"|_]).
true. %% unexpected
?- |
@@ -23,6 +23,6 @@ fn main() -> std::process::ExitCode { | |||
|
|||
runtime.block_on(async move { | |||
let mut wam = machine::Machine::new(Default::default()); | |||
wam.run_top_level(atom!("$toplevel"), (atom!("$repl"), 1)) | |||
wam.run_module_predicate(atom!("$toplevel"), (atom!("$repl"), 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great change, and paves the way to flexibly specifying the goal that should run as toplevel, for example with -t Goal
on the command line. We could then run scripts with:
$ scryer-prolog -t halt -g Goal
and ensure that Scryer Prolog halts after goal succeeds or fails or raises an exception!
By moving
argv/1
tolibrary(os)
, this predicate can be found and documented just like any other predicate. In addition, special code to handle the arguments in the top-level has been simplified.