Unexpected behavior of frozen/2
Asked Answered
W

1

11

I was playing around with the predicates freeze/2 and frozen/2:

?- freeze(X,a=a), frozen(X,Goal).
?- freeze(X,a=a), freeze(Y,b=b), X=Y, frozen(X,Goal).

(version 4.5.1 for x86_64) gave these answers:

| ?- freeze(X,a=a), frozen(X,Goal).
Goal = prolog:freeze(X,user:(a=a)),
prolog:freeze(X,user:(a=a)) ? ;
no
| ?- freeze(X,a=a), freeze(Y,b=b), X=Y, frozen(X,Goal).
Y = X,
Goal = (user:(a=a),prolog:freeze(X,user:(b=b))),
prolog:freeze(X,user:(a=a)),
prolog:freeze(X,user:(b=b)) ? ;
no

Now Goal = prolog:freeze(X,user:(a=a)) I did not expect!

What I did expect were answers like the ones given by version 8.0.3:

?- freeze(X,a=a), frozen(X,Goal).
Goal = user:(a=a),
freeze(X, a=a).
?- freeze(X,a=a), freeze(Y,b=b), X=Y, frozen(X,Goal).
X = Y,
Goal = (user:(a=a), user:(b=b)),
freeze(Y, a=a),
freeze(Y, b=b).

Arguably, both the SICStus answers and the SWI answers are correct...

But is there a deeper reason for the somewhat peculiar answer(s) given by SICStus?

Wallinga answered 17/11, 2019 at 20:43 Comment(10)
AFAIK in Sicstus the functionality for masking "last failure" is not implemented ` ? ; no`Lavine
For one, explicit qualification is preferable.Carlin
Up to 3.8.5 this problem does not exist. From 3.8.6 on it does exist.Carlin
@AntonDanilov. Okay. But I was actually referring to differences in the bold lines "Goal = ...".Wallinga
@false. What are you referring to when you're speaking of "explicit qualification" ?Wallinga
By explicit qualification I meant explicit module prefix. That is prolog: in place of nothing (as shown by SWI)Carlin
In any case: It seems no-one is using this interface any longer. And I would rather prefer two freeze/2 goals.Carlin
prolog: is the module for builtins. in SWI is no such moduleLavine
@AntonDanilov: In SWI there is a system module. Just say git grep system: in the sources.Carlin
Maybe @PerMildner will answer?Carlin
M
7

I don't know if there is any "deep" reason for the difference. Since frozen/2 is a general interface to attributed variables, it kind of makes sense to not special-case freeze/2 goals.

In fact, up to 4.5.1, SICStus tried, but sometimes failed, to special-case freeze/2 goals. This is why you see user:(a=a) for the first sub-goal. In the next release we have changed this so the result instead will become Goal = (prolog:freeze(X,user:(a=a)),prolog:freeze(X,user:(b=b))) (and we have also made some other improvements to frozen/2).

Menon answered 13/3, 2020 at 9:39 Comment(1)
up to 4,5,1 and after 3.8.5Carlin

© 2022 - 2024 — McMap. All rights reserved.