Replies: 1 comment
-
Logtalk linter checks occur when reading a source file and thus before the generated Prolog code is handed over the used Prolog backend. In this particular case, SWI-Prolog expansion of the dot notation occurs only when compiling the generated intermediate Prolog files and thus after the linter was run. As goals such as :- set_logtalk_flag(always_true_or_false_goals, silent) or using the corresponding compiler option in a loader goal, something like: logtalk_load(my_dicts_code, [always_true_or_false_goals(silent)]) Still, using SWI-Prolog dicts dot notation is not advised from Logtalk source code. See the Some of the advantages you mention for using dicts can be accomplished in a portable way. Logtalk parameter variables remove the dependency on argument position in the object (or category) identifier. Logtalk portable P.S. Thanks for the documentation bug report. Fixed and credited in the current git version. |
Beta Was this translation helpful? Give feedback.
-
Dear Mr. Moura and all discussion board members,
Playing around with the interaction between SWI prolog’s dicts and Logtalk, it would seem that the Logtalk compiler’s linter makes a mistake when analysing goals that make use of the ‘dot’ access mechanism for dict fields, BUT only when unification is done with compound terms and not when simply unified with a variable.
Here is a minimal example of what I mean:
And here are the corresponding queries that exemplify that it works as one would expect:
This leads me to pose the following set of questions:
(a) Is this something that could lead to unexpected failures of the code, or have unexpected side-effects?
(b) Is this due some strange interaction between the term expansion mechanism used for SWI’s Dict specific operators and goals with the Logtalk compiler?
(c) More importantly, what do you think of the use of SWI Dicts as the parameters of parametric objects? It would seem that one could have a powerful mechanism for (i) encapsulating a variable and not necessarily pre-specified number of parameters (leading to easier code evolution) and (ii) for removing the reliance on argument position in the object term allowing one to have a more expressive access mechanism as exemplified in the code?
I look forward to hearing your thoughts.
Kind Regards,
-K
P.S. Looking at Logtalk’s documentation, it would seem that the mode declared for the catch/3 built-in is incorrect (i.e. catch(?callable, ?term, ?term)) since, if I’m not mistaken, the third parameter should be a callable term as well, and not merely a term.
Beta Was this translation helpful? Give feedback.
All reactions