Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

prolog - No permission to modify static procedure `(-)/1'

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...