开发者

Flora-2 diamond inheritance

开发者 https://www.devze.com 2023-02-21 04:58 出处:网络
Flora-2 is an eccentric language and I know this is a long shot b开发者_C百科ut I haven\'t found any active resources devoted to it so I\'m trying here.Its so popular... there is no stackoverflow tag

Flora-2 is an eccentric language and I know this is a long shot b开发者_C百科ut I haven't found any active resources devoted to it so I'm trying here. Its so popular... there is no stackoverflow tag for it. If you know anything about the status and future of Flora-2 and XSB Prolog, I'd love to hear that, too.

Can someone explain Flora-2 diamond-inheritance rules to me? The manual has an example but doesn't show the results of the example. The wording seems to be the opposite of what I see in the interpreter and in the diamond.flr demo. Here's the demo:

c[f*->g].
c1[f(a)*->a]::c.
c2[f(b)*->b]::c.
o:c1.
o:c2.

?- ?X[?Y->?Z].

(What I see happens with or without the base class c)

The manual says:

At the level of methods of arity > 1, a conflict is considered to have taken place if there are two non-overwritten definitions of the same method attached to two different superclasses. When deciding whether a conflict has taken place we disregard the arguments of the method. For instance, in

a:c. c[m(k)*->f]. a:d. d[m(u)*->f].

a multiple inheritance conflict has taken place even though in one case the method m is applied to object k, while in the other it is applied to object u.

(I'm pretty sure they mean arity >= 1 but the results are similar for arity 2 as well)

So I take that to mean that the inheritance of f has a conflict so its undefined (although I'm a bit confused about what 'undefined' means, in a related section it says "inheritance does not take place"). Here's what I get when I run the diamond:

?X = o
?Y = f
?Z = g

?X = o
?Y = f(a)
?Z = a

I expected only the first solution, although I'd think that the second solution would at least make some sense if it also had the solution

?X = o
?Y = f(b)
?Z = b

... but it didn't.

FYI, I'm using the latest stable XSB and the latest Flora-2 release... 0.95.


Stumbled upon this 2+ years after the question was asked. You should have asked it on the flora-users mailing list.

Anyway, this seems to have been a bug in that version of Flora-2. I see that the current version gives a correct answer

?X = o

?Y = f

?Z = g

That is, the two conflicting inheritances canceled each other out, as the manual describes.


I'm not familiar with Flora-2 syntax but I have a smilar example of the well-known diamond-inheritance problem in Logtalk. You can find it here:

https://github.com/LogtalkDotOrg/logtalk3/tree/master/examples/diamonds

See the NOTES.txt and source file comments for information on semantics, default inheritance rules, and user-overriding of default inheritance rules. You can run the example using the latest CVS version of XSB. See the SCRIPT.txt file for sample queries.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号