Re: No permission to modify static procedure

"Richard A. O'Keefe" <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 20/01/2014, at 2:44 PM, Lumj wrote:
> I have no intention to redefine the built-in predicate, I just happen to pick 'write' as the name for the display predicate for my custom objects, and expect the system to resolve foo:write(foo). If I am not allowed to use the name used by built-in predicate, I have to name it something like 'foo_write'.

You could use some other language.  I've been known to use 'skribu'
(Esperanto for 'write!').  In English, possibilities include
'output', 'describe', 'report', or my big favourite, 'show'.

> Is there any reason for the system not to allow this name-hiding?

The traditional practice with Prolog modules is *NOT* to use a
module prefix.  This means that if your module can define write/1
and export it, it can be *called* as write(foo) in other modules.
That doesn't sound like a good idea.

In fact, for people trying to read Prolog code, it's really
helpful if the names of the ISO predicates are always used for
their ISO semantics; it would be just too confusing if
put_char(X) might delete a file...

If you want to think in terms of "objects", then you should
probably be using LogTalk, where you can do what you want to.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.