mlliarm / ia

An interval arithmetic library in Logtalk
Apache License 2.0
2 stars 0 forks source link

Issue with predicates? #14

Closed mlliarm closed 2 years ago

mlliarm commented 2 years ago

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.

pmoura commented 2 years ago

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.

mlliarm commented 2 years ago

Oh yes !!!

Thanks for the correction!

It's been a while and I forgot many. Closing, thanks !


Michail L. Liarmakopoulos, MSc

On Tue, Jan 18, 2022, 11:22 Paulo Moura @.***> wrote:

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 https://logtalk.org/manuals/refman/directives/uses_2.html directive.

— Reply to this email directly, view it on GitHub https://github.com/mlliarm/ia/issues/14#issuecomment-1015269995, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMQENUCBCLNZCQRXOV34ULUWU5PLANCNFSM5MGN5TYQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>