mlliarm / ia

An interval arithmetic library in Logtalk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with predicates?

mlliarm opened this issue · comments

Hello @pmoura !

I started writing some examples but it seems that something is broken. Can you help?

I'll assign this to you if that's okay.

Here's what I did:

?- A = new(1,2).
A = new(1, 2).

?- mid(A, Mid).
ERROR: Unknown procedure: mid/2 (DWIM could not correct goal)
?- midpoint(A, Mid).
ERROR: Unknown procedure: midpoint/2 (DWIM could not correct goal)
?- A = [1,2].
A = [1, 2].

?- midpoint(A, Mid).
ERROR: Unknown procedure: midpoint/2 (DWIM could not correct goal)

?- magnitude(A, M).
ERROR: Unknown procedure: magnitude/2 (DWIM could not correct goal)

I see that the predicates work only with a representation of the Interval as a list [a,b]. So they don't work with the new predicate, for now.

Question: will the user have access to the shorthands of the predicates, eg mid?

Thanks, and apologies for not having started earlier.

There's a big misunderstanding here. Assuming you have loaded the library, the predicates are available by sending messages to the interval_arithmetic object:

?- logtalk_load(loader).
...

?- interval_arithmetic::new(1,2,Interval).
Interval = ...

I.e. Logtalk is not based on an import/export semantics that you find with Prolog modules. In the code you wrote, loading the library doesn't make the predicates available for calling without reference to the library objects as in your sample queries.

You can use implicit message sending from within an object using the uses/2 directive.