Ok..maybe I didn't address my question clearly enough.
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'. Is there any reason for the system not to allow this name-hiding?
------------------ Original ------------------
From: "Jan Wielemaker";<***@vu.nl>;
Date: Mon, Jan 20, 2014 00:33 AM
To: "Lumj"<***@lumjsoft.com>; "SWI-Prolog"<swi-***@lists.iai.uni-bonn.de>;
Subject: Re: [SWIPL] No permission to modify static procedure
Post by LumjIs it possible to write a module in which there's a predicate write/1?
When I try to do this, I got the 'No permission to modify static procedure' error. What I intend to do is to have a write/1 in my module and the system:write/1 remain where it is.
:-module(m,[write/1]).
write(x).
Am I missing anything?
ISO doesn't allow for redefining system predicates. There is a good
reason for it: it
would not be able to perform any kind of optimization to ISO predicates.
For example,
several predicates are mapped directly to virtual machine instructions.
If the
definition was not fixed, this would be impossible.
There is a directive redefine_system_predicate/1 that overrules this (if
it still works).
That was mostly added to redefine stuff to gain compatibility to older
versions or
other systems. I doubt you can export such modified versions though.
If you do not
use redefine_system_predicate/1 in the receiving module, you get the
same check and
if you do, I think you'll also running into trouble. At least, there is
no guarantee
for the future.
For short, I think you are on the wrong track for healthy usage of
Prolog. What are you
after?
Cheers --- Jan
-------------- next part --------------
HTML attachment scrubbed and removed