|
1564 | 1564 | on_set_value(Note,N,true). % true |
1565 | 1565 | on_set_value(Note,N,'False'):- nocut, |
1566 | 1566 | on_set_value(Note,N,false). % false |
| 1567 | + |
| 1568 | +on_set_value(_Note,noninteractive,true):- nocut, ignore(noninteractive),!. |
| 1569 | +on_set_value(_Note,abort_trace,true):- nocut, ignore(abort_trace),!. |
1567 | 1570 | on_set_value(_Note,abolish_trace,true):- nocut, ignore(abolish_trace),!. |
1568 | 1571 |
|
1569 | 1572 | on_set_value(_Note,show, Value):- |
|
2722 | 2725 | % Mark that the prescan has been executed. |
2723 | 2726 | assert(has_run_cmd_args), |
2724 | 2727 | % Perform the prescan using `do_cmdline_load_metta/1`. |
2725 | | - do_cmdline_load_metta(prescan). |
| 2728 | + do_cmdline_load_metta(prescan), setup_show_hide_debug. |
2726 | 2729 |
|
2727 | 2730 | %! run_cmd_args is det. |
2728 | 2731 | % |
|
3110 | 3113 | if_phase(Phase, execute, catch_abort(['-G', Str], ignore(call_sexpr('!', Self, Str, _S, _Out)))), !, |
3111 | 3114 | cmdline_load_metta(Phase, Self, Rest). |
3112 | 3115 |
|
3113 | | -% Handle file loading when the argument does not start with `-`. |
3114 | | -cmdline_load_metta(Phase, Self, [Filemask | Rest]) :- |
3115 | | - symbol(Filemask), |
3116 | | - \+ symbol_concat('-', _, Filemask), !, |
3117 | | - if_phase(Phase, execute, cmdline_load_file(Self, Filemask)), !, |
3118 | | - cmdline_load_metta(Phase, Self, Rest). |
3119 | 3116 | % Handle command-line options by setting their corresponding values. |
3120 | 3117 |
|
3121 | 3118 | cmdline_load_metta(Phase, Self, [Skip, _ | Rest]) :- skip_cmdarg(Skip), !, |
3122 | 3119 | cmdline_load_metta(Phase, Self, Rest). |
3123 | 3120 |
|
| 3121 | +% forces whatver is after -D to bve treated as flag-like |
3124 | 3122 | cmdline_load_metta(Phase, Self, ['-D', M | Rest]) :- !, |
3125 | | - process_flag(M), !, |
| 3123 | + process_as_flag(M), !, |
3126 | 3124 | cmdline_load_metta(Phase, Self, Rest). |
| 3125 | + |
| 3126 | +% picks up on name=value |
3127 | 3127 | cmdline_load_metta(Phase, Self, [M | Rest]) :- |
3128 | 3128 | process_flag(M), !, |
3129 | 3129 | cmdline_load_metta(Phase, Self, Rest). |
| 3130 | +% Handle file loading when the argument does not start with `-`. |
| 3131 | +cmdline_load_metta(Phase, Self, [Filemask | Rest]) :- |
| 3132 | + symbol(Filemask), |
| 3133 | + \+ symbol_concat('-', _, Filemask), !, |
| 3134 | + if_phase(Phase, execute, cmdline_load_file(Self, Filemask)), !, |
| 3135 | + cmdline_load_metta(Phase, Self, Rest). |
3130 | 3136 | % Handle unrecognized command-line options by logging a warning. |
3131 | 3137 | cmdline_load_metta(Phase, Self, [M | Rest]) :- |
3132 | 3138 | format('~N'), |
|
3965 | 3971 | % % Execute a goal and trace errors: |
3966 | 3972 | % ?- rtrace_on_error(writeln('Hello, World!')). |
3967 | 3973 | % |
| 3974 | + |
| 3975 | +rtrace_on_error(G):- is_user_repl, !, call(G). |
3968 | 3976 | rtrace_on_error(G):- !, call(G). |
3969 | 3977 | %rtrace_on_error(G):- catch(G,_,fail). |
3970 | 3978 | rtrace_on_error(G):- |
|
4440 | 4448 | % |
4441 | 4449 | metta_atom_added(X, Y) :- nocut, |
4442 | 4450 | % Check if the atom was explicitly asserted. |
4443 | | - metta_atom_asserted(X, Y). |
| 4451 | + metta_atom_asserted_ocw(X, Y). |
4444 | 4452 | metta_atom_added(X, Y) :- nocut, |
4445 | 4453 | % Check if the atom is associated with a file. |
4446 | 4454 | metta_atom_in_file(X, Y). |
|
4452 | 4460 | % Check if the atom was recently asserted. |
4453 | 4461 | metta_atom_asserted_last(X, Y). |
4454 | 4462 |
|
| 4463 | + |
| 4464 | +metta_atom_asserted_ocw(X, Y):- |
| 4465 | + woct(metta_atom_asserted(X, Y)). |
| 4466 | + %clause_occurs_warning(metta_atom_asserted(X, Y)). |
| 4467 | + |
4455 | 4468 | %! metta_atom(+Space, -Atom) is nondet. |
4456 | 4469 | % |
4457 | 4470 | % Retrieves atoms associated with a given space or knowledge base (`Space`). |
|
4490 | 4503 | metta_atom0(Inherit,X, Y) :- maybe_into_top_self(X, TopSelf), !, metta_atom0(Inherit,TopSelf, Y). |
4491 | 4504 |
|
4492 | 4505 |
|
4493 | | -metta_atom0(_Inherit,KB, Atom) :- metta_atom_added(KB, Atom). |
| 4506 | +metta_atom0(_Inherit,KB, Atom) :- woce(metta_atom_added(KB, Atom)). |
4494 | 4507 |
|
4495 | 4508 |
|
4496 | 4509 |
|
|
6056 | 6069 | eval_H(_StackMax, _Self, Term, Term) :- |
6057 | 6070 | % If the `compile` option is set to `save`, return the term unchanged. |
6058 | 6071 | fast_option_value(compile, save), !. |
6059 | | -eval_H(StackMax, Self, Term, X) :- |
| 6072 | +eval_H(StackMax, Self, Term, XO) :- |
| 6073 | + copy_term(Term+X,CTerm+CX), |
6060 | 6074 | % Otherwise, perform evaluation with error handling, passing the stack limit. |
6061 | | - woc(catch_metta_return(eval_args('=', _, StackMax, Self, Term, X), X)). |
| 6075 | + woc(catch_metta_return(eval_args_stack_max('=', _, StackMax, Self, CTerm, CX), CX)), |
| 6076 | + CX\=='Empty', |
| 6077 | + CTerm=Term,CX=X, |
| 6078 | + XO=CX. |
| 6079 | + |
| 6080 | +eval_args_stack_max('=', _, StackMax, Self, Term, X):- |
| 6081 | + eval_args('=', _, StackMax, Self, Term, X). |
6062 | 6082 | /* |
6063 | 6083 | eval_H(StackMax,Self,Term,X). |
6064 | 6084 |
|
|
7198 | 7218 | % is allowed, it handles modifications to `system:notrace/1` to customize its behavior. |
7199 | 7219 | % |
7200 | 7220 |
|
7201 | | -nts1 :- !. % Disable redefinition by cutting execution. |
| 7221 | +%nts1 :- !. % Disable redefinition by cutting execution. |
7202 | 7222 | %nts1 :- is_flag(notrace),!. |
7203 | 7223 | nts1 :- no_interupts(nts1r). |
7204 | 7224 | nts1r :- |
|
7213 | 7233 | meta_predicate(system:notrace(0)), |
7214 | 7234 | % Define the new behavior for `system:notrace/1`. |
7215 | 7235 | % The redefined version executes the goal (`G`) with `once/1` and succeeds deterministically. |
7216 | | - asserta(( system:notrace(G) :- (!, unotrace(G),! ))). |
| 7236 | + asserta(( system:notrace(G) :- (!, once(G),! ))). |
| 7237 | + %asserta(( system:notrace(G) :- (!, unotrace(G),! ))) |
7217 | 7238 | nts1r :- |
7218 | 7239 | % Ensure that further redefinitions of `nts1` are not allowed after the first. |
7219 | 7240 | !. |
|
0 commit comments