Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: compatibility between record type and single-dimension array

compatibility between record type and single-dimension array 23 Apr 2003 07:41 #6474

  • Jacon_wang
  • Jacon_wang's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
  • Karma: 0
hi,all
In clause 6.7.2.2(ETSI 201 873 v2.2.1,the bottom of Page 38),it says that"Values of a record type also can be assigned to an instance of a record of type or a single-dimension array if no length restriction of the record of type is violated or the dimension of the array is more than or equals to the number of element of the record type.".
But in the following example 2:
type record HType {
integer a,
integer b optional,
integer c
}

var HType MyVarH := {1,omit,2};
var integer MyArrayVar[2];

Then:
MyArrayVar := MyVarH;
// is a valid assignment as type of MyArrayVar and HType are compatible

I think the statement MyArrayVar := MyVarH is a invalid assignment as type of MyArrayVar and HType are incompatible.Because the number of the single-dimension array MyArrayVar is 2,but the number of elements of the record type "HType" is 3.

I'm right?

With var integer MyArrayVar[5]; MyArrayVar := MyVarH given, what is assigned to MyArrayVar[3],MyArray[4]?

Thanks in advance.

             =A
1   ?003-04-23
--
Engineering is the art of making what you want from
things you can get.
The administrator has disabled public write access.

compatibility between record type and single-dimension array 23 Apr 2003 08:04 #6475

Hi Jacon,

first let me state that personally I think that this cross-compatibility between different TTCN-3 datatype kinds is something that I most dislike about the type system of TTCN-3. I see no good reason why one would want to use this feature and would strongly discourage using it because it is bound to lead to confusing code. Of course, this is just a matter of opinion.

Now to your question: if you continue to read the standard a littel bit further, there it is state that 'Optional elements missing in the recird value shall be assign as elements with undefined values'. In other words, coming to your examples:

The first assignmet is indeed not admissible because the array is restricted to contain two elements whereas the record has three fields.

In the second assignment, I would think that the resulting MyArrayVar will should contain {1,-,2,-,-} .

In gereral, this dealing with omitted fields as undefined values seems to be ill-designed to me, because, if we consider the following code:

type record RT {
integer x;
integer y optional;
integer z
}

var RT r := {1,omit,2}
var RT r1;
var integer a[3];

r1 := r;
a := r;
r := a;

Now r1 != r holds, because r = {1,-,2} and r1 = {1,omit,2}

This is very strange behaviour. I guess it would help do restrict cross-compatibility between records and arrays/record of's to records with no optional fields, but as I said in the beginning, I think that this whole issue is much more confusing than useful.

BR

Stephan Tobies

>
Original Message
> From: ext jacon wang [This email address is being protected from spambots. You need JavaScript enabled to view it.]
> Sent: 23. April 2003 08:41
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: compatibility between record type and single-dimension array
>
>
> hi,all
> In clause 6.7.2.2(ETSI 201 873 v2.2.1,the bottom of
> Page 38),it says that"Values of a record type also can be
> assigned to an instance of a record of type or a
> single-dimension array if no length restriction of the record
> of type is violated or the dimension of the array is more
> than or equals to the number of element of the record type.".
> But in the following example 2:
> type record HType {
> integer a,
> integer b optional,
> integer c
> }
>
> var HType MyVarH := {1,omit,2};
> var integer MyArrayVar[2];
>
> Then:
> MyArrayVar := MyVarH;
> // is a valid assignment as type of MyArrayVar and HType are
> compatible
>
> I think the statement MyArrayVar := MyVarH is a invalid
> assignment as type of MyArrayVar and HType are
> incompatible.Because the number of the single-dimension array
> MyArrayVar is 2,but the number of elements of the record type
> "HType" is 3.
>
> I'm right?
>
> With var integer MyArrayVar[5]; MyArrayVar := MyVarH given,
> what is assigned to MyArrayVar[3],MyArray[4]?
>
> Thanks in advance.
>
>                  2003-04-23
> --
> Engineering is the art of making what you want from
> things you can get.
>
The administrator has disabled public write access.
  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin