0
votes

I am starting to learn CLIPS at the moment and asked myself when is it better to use symbols and when strings?

On first sight it seems to me, that symbols are favorable because they are easier to compare than strings.

(eq test test)

is faster than

(= (str-compare "test" "test") 0)

Is there a downside to it too?

1

1 Answers

1
votes

The advantage of symbols compared to strings is that you have to enter two fewer characters (the quotation marks). The disadvantage of symbols compared to strings is that some delimiters aren't allowed (notably the space characters). The str-compare function is primarily provided for alphabetic sorting. For equality testing, you can use eq:

CLIPS> (eq "test" "test")
TRUE
CLIPS> (eq "test" "nottest")
FALSE
CLIPS>