bizarre type error

95 views
Skip to first unread message

Anne Ogborn

unread,
Oct 31, 2017, 9:17:54 PM10/31/17
to SWI-Prolog Mailing List
I have a predicate,

json_item/3

whose last argument is an options list (I'm not using the library 'options' definitions,
though I'm using option/2 so it's autoloading)

for convenience I'm making another public predicate, json_item/2, which does the obvious and usual

json_item(Term, JSON) :-
json_item(Term, JSON, []).

Which produces this cryptic compile time error

ERROR: [Thread pce] /usr/local/simularity/library/agent.pl:160:30: Type error: `callable' expected, found `[]' (an empty_list)


Changing it to:

json_item(Term, JSON) :-
length(L, 0), % I have *NO* idea why this is necessary!
json_item(Term, JSON, L).



fools the compiler, and life is good.

json_item is not defined as a meta_predicate

I've looked at the term_expansions, I've looked for it in the SWI libs.

I'm on 7.7.0

Advice on debugging would be appreciated. I assume I've borked something

::Annie is here, making Jan bang his head on his desk in frustration yet again::


P.S. I must ask, while looking for this I found

[ (:- json_convert:clear_cache) ].



which is just a tad odd.

Jan Wielemaker

unread,
Nov 1, 2017, 5:44:18 AM11/1/17
to Anne Ogborn, SWI-Prolog Mailing List
On 11/01/2017 02:17 AM, 'Anne Ogborn' via SWI-Prolog wrote:
> I have a predicate,
>
> json_item/3
>
> whose last argument is an options list (I'm not using the library 'options' definitions,
> though I'm using option/2 so it's autoloading)
>
> for convenience I'm making another public predicate, json_item/2, which does the obvious and usual
>
> json_item(Term, JSON) :-
> json_item(Term, JSON, []).
>
> Which produces this cryptic compile time error
>
> ERROR: [Thread pce] /usr/local/simularity/library/agent.pl:160:30: Type error: `callable' expected, found `[]' (an empty_list)
>
>
> Changing it to:
>
> json_item(Term, JSON) :-
> length(L, 0), % I have *NO* idea why this is necessary!
> json_item(Term, JSON, L).
>
>
>
> fools the compiler, and life is good.
>
> json_item is not defined as a meta_predicate
>
> I've looked at the term_expansions, I've looked for it in the SWI libs.

Quite likely something must somehow think this is a meta-argument. You
could try predicate_property/2 on it to check. Also, this originates
from the `pce` thread. Is this due to a compile command issued from the
editor or could it have to do with syntax highlighting?

Anyway, this is hard to tell without being able to reproduce. Contact
me if you can share (enough of) the code with me.

> I'm on 7.7.0
>
> Advice on debugging would be appreciated. I assume I've borked something
>
> ::Annie is here, making Jan bang his head on his desk in frustration yet again::

:)

Cheers --- Jan

Anne Ogborn

unread,
Nov 1, 2017, 6:24:48 PM11/1/17
to Jan Wielemaker, Anne Ogborn, SWI-Prolog Mailing List
>Quite likely something must somehow think this is a meta-argument. You
could try predicate_property/2 on it to check.

Doesn't say it is.

> Also, this originates
from the `pce` thread. Is this due to a compile command issued from the
editor or could it have to do with syntax highlighting?

I usually do C-c C-m from pceEmacs. That's what's making it come from pceEmacs thread.

It doesn't report the error on first program load (which is strange)
but we do several term_expansion games (but none seem involved).

>Anyway, this is hard to tell without being able to reproduce. Contact
me if you can share (enough of) the code with me.

It's proprietary code, but more to the point, it's some nightmarish system spread over 4 languages and zillions of dependencies. I really think I'm going to keep quietly spoofing the compiler.

I continue to be intimidated by

Jan Wielemaker

unread,
Nov 2, 2017, 5:46:42 AM11/2/17
to Anne Ogborn, SWI-Prolog Mailing List
I know. Sometimes a small snippet is enough though. The most likely
stuff affecting this are term/goal expansion rules and the code itself.

> I continue to be intimidated by
>
>> [ (:- json_convert:clear_cache) ].

I think it is inserted by compiling the conversion rules. The
system maintains a cache of optimized rules to convert json
objects to Prolog objects and if the rules change it is wise
to flush this cache.

Cheers --- Jan

Reply all
Reply to author
Forward
0 new messages