What is the `[user]` command on the top level? How do I find docs for it?

A user trying out the Python MQI library does the following at the top level (which I’ve never seen before):

?- [user].
|: fruit(mango).
|: fruit(apple).
|: ^D% user://1 compiled 0.01 sec, 2 clauses
true.

?- fruit(mango).
true.

Can someone describe what this feature is and maybe point me at the docs so I can understand how to translate it to something that can be run through the Python MQI library?

It looks like a shortcut to asserting clauses into the user module, but I’d like to know more details.

What is the [user] command on the top level?

It looks like a shortcut to asserting clauses into the user module, but I’d like to know more details.

That is correct.

See: Getting started quickly - Specifically: Adding rules from the console
Also: User Top-level Manipulation


Since Ctrl-D or ^D is not always understood there is end_of_file/0

Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.28-20-g6f8a68f2b)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
...

?- [user].
|: hello :- format('Hello world~n').
|: end_of_file.

% user://1 compiled 0.00 sec, 1 clauses
true.

?- hello.
Hello world
true.

Not quite.

It’s equivalent to consult(user), and user is special for the consult/1 predicate – it reads from the user’s terminal.

1 Like

Thanks.

I changed it before your reply posted. I was more focused on getting the docs in place then reviewing.

Perfect. Thank you!