trealla-prolog / trealla

A compact, efficient Prolog interpreter written in plain-old C.
MIT License
274 stars 13 forks source link

Confusing 'module' behaviour #581

Closed flexoron closed 2 months ago

flexoron commented 2 months ago

v2.55.24

$ tpl
?- [user].
m:x.
a :- m:b.
b.
b.

?- a.
   true  % ?
;  true. % ?

?- [user].
m:b.

?- a.
   true.  % missing two from above? 
?- 
guregu commented 2 months ago

Maybe it's a little too strict now? I think it was useful to be able to implicitly create modules with assertz or just loading a file. Scryer and SWI allow it.

% ./tpl
?- assertz(foo:bar).
   true.
?- foo:bar.
   throw(error(existence_error(module,foo),(:)/2)).

Scryer, for comparison

% scryer-prolog
?- [user].
foo:bar(123).
^D
?- foo:bar(X).
   X = 123.
?- assertz(test:hello).
   true.
?- test:hello.
   true.
infradig commented 2 months ago

If you had a real need for it sure, but just using it for namespace sake seems overkill.

On Fri, 30 Aug 2024, 15:21 guregu, @.***> wrote:

Maybe it's a little too strict now? I think it was useful to be able to implicitly create modules with assertz or just loading a file. Scryer and SWI allow it.

% ./tpl?- assertz(foo:bar). true.?- foo:bar. throw(error(existence_error(module,foo),(:)/2)).

Scryer, for comparison

% scryer-prolog?- [user].foo:bar(123).^D?- foo:bar(X). X = 123.?- assertz(test:hello). true.?- test:hello. true.

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/581#issuecomment-2320090433, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEVNO7IW5WS3CK2PT7DZT76PPAVCNFSM6AAAAABNCQQAFGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRQGA4TANBTGM . You are receiving this because you commented.Message ID: @.***>

guregu commented 2 months ago

My main uses for it are pretty weird (and can be worked around). There's probably a better way so I'll make a new issue for it.

flexoron commented 2 months ago

Still I've a problem with behaviour

$ tpl
?- [user].
m:x.
a :- m:b.
b.
b.
   true.
?- a.
   throw(error(existence_error(module,m),(:)/2)).
?- module(m).
Info: created module 'm'
   true.

?- a.
   true   % this is b.
;  true.  % this is b.

?- [user].
m:b.
   true.

?- a.
   true. % this is m:b.? and b. is gone but why? It has been 'found' before? Overwritten?
?- b.
   true
;  true.
?- 
flexoron commented 2 months ago

cont. #584