Shouldn't JOIN { } return DEE ?

This forum is to report technical problems with Rel.
Post Reply
blambeau
Posts: 4
Joined: Thu Jan 30, 2014 5:01 pm

Shouldn't JOIN { } return DEE ?

Post by blambeau »

It seems that it returns a single TUPLE{} for now.

Also JOIN{} = DEE returns the following error: ERROR: Operator 'OP_EQUALS(TUPLE {}, RELATION {}) RETURNS BOOLEAN' has not been defined.

Am I misunderstanding something here?
Dave
Site Admin
Posts: 372
Joined: Sun Nov 27, 2005 7:19 pm

Re: Shouldn't JOIN { } return DEE ?

Post by Dave »

The JOIN operator is overloaded to support both tuple join and relation join. As JOIN {} is ambiguous as to whether it means tuple join or relation join, it arbitrarily defaults to tuple join. Thus, the result of JOIN {} is TUPLE {}, so JOIN {} = TUPLE {} returns true, but JOIN {} = DEE fails because there is no definition for the '=' operator that permits comparing the tuple result of JOIN {} with the relation that is DEE.

Admittedly, this is perhaps a violation of the Principle of Least Surprise. I probably should make JOIN {} mean relation join.
blambeau
Posts: 4
Joined: Thu Jan 30, 2014 5:01 pm

Re: Shouldn't JOIN { } return DEE ?

Post by blambeau »

Interresting. Thanks for the explanation.

For the record, I was actually reading Hugh's book because I use it, and Rel, with the students at the University of Louvain. The example, and expectation, comes from what's written in the book. In that context, I would certainly say that it's a violation of the Principle of Least Surprise.
Dave
Site Admin
Posts: 372
Joined: Sun Nov 27, 2005 7:19 pm

Re: Shouldn't JOIN { } return DEE ?

Post by Dave »

I wasn't aware it contradicted Hugh's book. That makes it unquestionably a violation of the Principle of Least Surprise!

I've made an entry in my "to do" list to change this for the next update.
HughDarwen
Posts: 124
Joined: Sat May 24, 2008 4:49 pm

Re: Shouldn't JOIN { } return DEE ?

Post by HughDarwen »

Tutorial D grammar doesn't include <n-adic tuple join>, so JOIN { } has to be a relation join, yielding DEE. What about UNION { }? That has to be an <n-adic tuple union> because if it were a relation union it would need a heading to be specified.

But apparently Rel doesn't yet support UNION { }, which is indeed defined to yield TUP{ }. Another one for the to-do list?

Hugh
HughDarwen
Posts: 124
Joined: Sat May 24, 2008 4:49 pm

Re: Shouldn't JOIN { } return DEE ?

Post by HughDarwen »

Further to my reply just posted, I've just come across the point in my book where n-adic tuple join is indeed defined. But we didn't even have that in TD/V1, so my book has been in error all this time. Deepest apologies!

Hugh
Post Reply