Re: predutils package available (Re: PAC library for develop version available)

Jan Wielemaker <[email protected]> Thu, 2 Oct 2014 16:23:39 +0200
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 10/02/2014 02:31 PM, Kuniaki Mukai wrote:
>>> Writing libraries is a different thing than writing a program in user
>>> space ...  I hope this helps

> Deep words. I feel I have seen something of library builder's invisible efforts
> for others happy life.

On the other hand, writing libraries isn't too different from writing
large application where you need code structuring.   Once you get the
hang of it, the extra structuring rules help you more than they hinder
you.

> By the way, I would like to ask you an urgent and maybe stupid
> question about module.  I thought exported names can be used from any
> oother contexts, i.e., globally, like builtin append/3.  But a simple
> experiment shows that it is not the case. So my question is: in
> what contexts an exported name can be used without putting module
> prefix before the name ? I have read the recommended document, but I am
> afraid I have missed the point again.

For most Prolog systems, a use_module/1 means you can use the code from
the module you are importing from only.  SWI-Prolog modules have a notion
of `default modules`: if a predicate cannot be found in a module, it will
try its default module (recursively).  All modules default to `user`, while
`user` defaults to `system`.  So, code that you write in (or import into)
user is visible in all modules, but can be locally overruled.  B.t.w.,
system library files default directly to `system`, so you cannot modify
their behaviour by writing things in `user`.  Operator inheritance follows
the same rules.

The defaulting scheme can be modified, which allows for defining other
visibility and reuse models.

	Cheers --- Jan