Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createLiteral parenthesis check #124

Open
driacats opened this issue Feb 26, 2025 · 1 comment
Open

createLiteral parenthesis check #124

driacats opened this issue Feb 26, 2025 · 1 comment

Comments

@driacats
Copy link

driacats commented Feb 26, 2025

While working with JaCaMo, I found this bug: there is no validation in createLiteral to check whether the given string is actually acceptable. If you try the following code:

Literal a = createLiteral("a(b)");

The code creates a literal with the functor a(b). I know that parseLiteral also exists, and given the same string, it correctly creates the literal, but I find it strange that createLiteral does not throw an exception in such cases.

Additionally, from the Mind Inspector's graphical interface, there is (obviously) no visual difference between a(b) (where the entire string is the functor) and a(b) (where a is the functor and b is the argument). This leads to an unpleasant debugging situation where the beliefs contain a(b) (or multiple instances of it, since for some reason also equal functors are not viewed as equals from the point of view of the agent BeliefBase), and a plan like the one below does not get executed:

+!hello
     : a(b)
    <- .print( "Hello!" ).

Perhaps parentheses are not the only characters that should be checked, but I consider them the most important because, theoretically, the functor should not be able to create functors with parentheses at all.

In case you find this issue interesting but don't have time to address it, I am available to try to implement this validation.

Thank you for your work!

@jomifred
Copy link
Contributor

jomifred commented Mar 6, 2025

Hi Andrea, thanks for commenting on this subject.

The idea of having two methods, createLiteral and parseLiteral, is to give to user the freedom to use whatever functor he/she wants. If checks are necessary, parseLiteral should be used. For an example, in some application, empty space "" could be used as functor to have a kind of tuples :-)

Another note, any string can be used (and parsed!) as functor when enclosed by ` and `. For example, what follows is syntactically valid code:

 +!`4(5)`(a,b) <- act.

in this case, the functor of the goal is "4(5)".

thanks again.

Jomi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants