No permission to modify static procedure

跟風遠走 提交于 2019-12-18 09:26:48

问题


When i do an assert like:

assert(-color(red)).

it gives me the error:

ERROR: assert/1: No permission to modify static procedure `(-)/1'

so i change -color to dynamic:

dynamic -color/4.

and now it gives me the error:

ERROR: dynamic/1: Type error: `atom' expected, found `-color'

Any ideas?


回答1:


First off, as Prolog itself is telling you, it is reading -color(foo) as -(color(foo)). That's why it's complaining about (-)/1 and not -color. You cannot begin an atom with a hyphen.

Second, you want asserta/1 or assertz/1, not assert/1.

Third, when you declare a dynamic predicate with arity 4, you should use it with arity 4, not arity 1. In other words, your dynamic should either read :- dynamic color/4 and be used asserta(color(Red,Green,Blue,Alpha)) or it should read :- dynamic color/1 and be used asserta(color(red)). The combination /4 with /1 is not what you mean.



来源:https://stackoverflow.com/questions/16284177/no-permission-to-modify-static-procedure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!