DEE and DUM

This forum is for any questions about the language Tutorial D or the Rel implementation of it.
Post Reply
Chris Walton
Posts: 76
Joined: Sat Aug 18, 2012 2:13 pm

DEE and DUM

Post by Chris Walton » Thu Jan 09, 2014 8:53 pm

I have not got the usage of DEE and DUM sorted out. How do I amend the following examples to initialise a relvar to empty?

Code: Select all

VAR Test BASE RELATION { A0 INT } INIT ( RELATION { TUPLE { A0 999 } } ) KEY { A0 };
Ok.
VAR Test1 BASE RELATION { A0 INT } INIT ( DEE ) KEY { A0 };
ERROR: Variable of type RELATION {A0 INTEGER} cannot be initialised with an expression of type RELATION {}
Line 1
VAR Test2 BASE RELATION { A0 INT } INIT ( DUM ) KEY { A0 };
ERROR: Variable of type RELATION {A0 INTEGER} cannot be initialised with an expression of type RELATION {}
Line 1

Dave
Site Admin
Posts: 368
Joined: Sun Nov 27, 2005 7:19 pm

Re: DEE and DUM

Post by Dave » Tue Jan 14, 2014 5:32 pm

Defining relvars initialises them to empty, so you can omit the "INIT (...)" clause. Alternatively, you could do:

Code: Select all

DELETE Test;
DELETE Test1;
DELETE Test2;

Chris Walton
Posts: 76
Joined: Sat Aug 18, 2012 2:13 pm

Re: DEE and DUM

Post by Chris Walton » Thu Jan 23, 2014 6:31 pm

I was not clear enough about what I was trying to do. I was trying to insert, into a relvar which has a RVA, values which contained an empty relation for the RVA. After some experimentation I have found the following works.

Code: Select all

VAR T1 BASE RELATION { A0 CHAR, R0 RELATION { B1 INT, B2 CHAR } } KEY { A0 };
Ok.
INSERT T1 RELATION { TUPLE { A0 "Test", R0 RELATION { B1 INT, B2 CHAR } { } } };
NOTICE: Inserted 1 tuple.
Ok.

Post Reply