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

TOPIC: Referencing record and set elements

Referencing record and set elements 17 Mar 2009 11:56 #7547

  • Ra
  • Ra's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 12
  • Karma: 0
Hi,



IÂ’ve been reading the chapter 15.6.2 of core language (Referencing record
and set fields) and I have some doubts. What do you think about the
following example?



type record MyRecordTypeSymple {

integer f1 optional,

float f2

}

type record MyRecordType2Nested {

integer f1,

float f2,

MyRecordTypeSymple f3 optional

}

type record MyRecordType3Nested {

integer f1,

MyRecordType2Nested f2,

MyRecordTypeSymple f3,

float f4

}



var template MyRecordType3Nested v_t3_1 := { f1:=1, f2:=?, f3:=?,
f4:=1.5};

var template MyRecordType3Nested v_t3_2 := { f1:=1, f2:= { f1:=1, f2:=
2.4, f3:= { f1:=omit, f2:=3.5} } };



v_t3_2.f2.f3.f1 := v_t3_1.f2.f3.f1;





The question is: What will the value of v_t3_2 and v_t3_1 be after the
assignment?

I find several options:

1.- The value of v_t3_2 will be

{ f1:=1, f2:= { f1:=1, f2:= 2.4, f3:= { f1:=*, f2:=3.5} } }

and the value of v_t3_1 will be

{ f1:= 1, f2:= { f1:=?, f2:=?, f3:= { f1:=*, f2:=? } }, f3:=?, f4:= 1.5 }

2.- The value of v_t3_2 will be

{ f1:=1, f2:= { f1:=1, f2:= 2.4, f3:= { f1:=*, f2:=3.5} } }

and the value of v_t3_1 will be the
initial value because v_t3_1 donÂ’t change its value (itÂ’s at right hand
side)

{ f1:=1, f2:=?, f3:=?,
f4:=1.5 }

3.- The assignment is an error because when the structured field f2 is
expanded recursively the field “f2.f3” has the value AnyValueOrNone. That
is, when I try to get the template value of “f2.f3.f1”, f2 == ? (AnyValue),
so itÂ’s necessary expanded its template value and f2 template value must
have been { f1:=?, f2:=?, f3:=*} (f3 is optional). Then when I try to get
the field f1 of f2.f3 I couldn’t do it because “f2.f3” is AnyValueOrNone.





Thank you.



Regards,



Raúl Alfonso Quintana
The administrator has disabled public write access.

Referencing record and set elements 17 Mar 2009 12:33 #7548

Hi Raúl,

"What will the value of v_t3_2 and v_t3_1 be after the assignment?" ->

The better wording is, what will be the CONTENT of v_t3_1 and v_t3_2 be, as we do talk about templates (even if their content may be changed dynamically); i.e. they do not have a value:
v_t3_1 will contain { f1:=1, f2:=?, f3:=?, f4:=1.5}
v_t3_2 will contain { f1:=1, f2:= { f1:=1, f2:= 2.4, f3:= { f1:=omit, f2:=3.5} } }

E.g. the field f2 of v_t3_1 will match all legal values of MyRecordType2Nested; e.g. it will match { f1:= 0, f2:= 0.0, f3 := omit} as well as e.g.
{ f1:= 1, f2:= 1.1, f3 := { f1:=omit, f2 := 0.0}} as well as { f1:= 2, f2:= 2.2, f3 := { f1:=5, f2 := 1.1}} etc. In short, f2 := ? will match infinitely many values (as its type definition is not constrained).

Clause 15.6.2 is about REFERENCING the subfields within a template field with e.g. AnyValue. Obvious, that if the subfield is mandatory, it will match any legal value of its type that is the property of the AnyValue matching attribute. If the subfield is optional, it will also match a missing field, what it the property of the matching mechanism AnyValueOrNone. But again, these are not values, but matching mechnisms (wildcards).

BR, Gyorgy


________________________________

From: active_ttcn3 : mts stf133 ttcn version 3 - active members only [This email address is being protected from spambots. You need JavaScript enabled to view it.] On Behalf Of Raúl Alfonso Quintana
Sent: 2009-március-17 12:57
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Referencing record and set elements



Hi,



I've been reading the chapter 15.6.2 of core language (Referencing record and set fields) and I have some doubts. What do you think about the following example?



type record MyRecordTypeSymple {

integer f1 optional,

float f2

}

type record MyRecordType2Nested {

integer f1,

float f2,

MyRecordTypeSymple f3 optional

}

type record MyRecordType3Nested {

integer f1,

MyRecordType2Nested f2,

MyRecordTypeSymple f3,

float f4

}



var template MyRecordType3Nested v_t3_1 := { f1:=1, f2:=?, f3:=?, f4:=1.5};

var template MyRecordType3Nested v_t3_2 := { f1:=1, f2:= { f1:=1, f2:= 2.4, f3:= { f1:=omit, f2:=3.5} } };



v_t3_2.f2.f3.f1 := v_t3_1.f2.f3.f1;





The question is: What will the value of v_t3_2 and v_t3_1 be after the assignment?

I find several options:

1.- The value of v_t3_2 will be

{ f1:=1, f2:= { f1:=1, f2:= 2.4, f3:= { f1:=*, f2:=3.5} } }

and the value of v_t3_1 will be

{ f1:= 1, f2:= { f1:=?, f2:=?, f3:= { f1:=*, f2:=? } }, f3:=?, f4:= 1.5 }

2.- The value of v_t3_2 will be

{ f1:=1, f2:= { f1:=1, f2:= 2.4, f3:= { f1:=*, f2:=3.5} } }

and the value of v_t3_1 will be the initial value because v_t3_1 don't change its value (it's at right hand side)

{ f1:=1, f2:=?, f3:=?, f4:=1.5 }

3.- The assignment is an error because when the structured field f2 is expanded recursively the field "f2.f3" has the value AnyValueOrNone. That is, when I try to get the template value of "f2.f3.f1", f2 == ? (AnyValue), so it's necessary expanded its template value and f2 template value must have been { f1:=?, f2:=?, f3:=*} (f3 is optional). Then when I try to get the field f1 of f2.f3 I couldn't do it because "f2.f3" is AnyValueOrNone.





Thank you.



Regards,



Raúl Alfonso Quintana
The administrator has disabled public write access.

Referencing record and set elements 18 Mar 2009 09:03 #7549

  • Ra
  • Ra's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 12
  • Karma: 0
Hi Gyorgy,



Thank you for your answer. I agree with you that the value word
is incorrect when we talk about templates. But my doubts are about the
recursive expanding that itÂ’s explained in clause 15.6.2. In the example, I
put a situation where IÂ’m not clear about what will be the content of v_t3_1
and v_t3_2 after the assignment. With the three options to my question
(“What will the value of v_t3_2 and v_t3_1 be after the assignment?”) I
wanted to clear up the following doubts:



- Is the content of variable template changed at the right hand
side when referencing a subfield within a structured field to which AnyValue
is assigned? --> Option 1 or 2

- The option 3 shows two steps in the recursive expanding. The
first step the content of v_t3_1 will be:

{ f1:=1, f2:={f1:=?,f2:=?,f3:=*}, f3:=?, f4:=1.5}

And in the second step I try referencing a structured
subfield which content is AnyValueOrNone, f2.f3, and this is an error. I
donÂ’t know if itÂ’s right.



Regards,



Raúl Alfonso Quintana



_____

De: active_ttcn3 : mts stf133 ttcn version 3 - active members only
[This email address is being protected from spambots. You need JavaScript enabled to view it.] En nombre de György Réthy
Enviado el: martes, 17 de marzo de 2009 13:34
Para: This email address is being protected from spambots. You need JavaScript enabled to view it.
Asunto: Re: Referencing record and set elements



Hi Raúl,



"What will the value of v_t3_2 and v_t3_1 be after the assignment?" ->



The better wording is, what will be the CONTENT of v_t3_1 and v_t3_2 be, as
we do talk about templates (even if their content may be changed
dynamically); i.e. they do not have a value:

v_t3_1 will contain { f1:=1, f2:=?, f3:=?, f4:=1.5}

v_t3_2 will contain { f1:=1, f2:= { f1:=1, f2:= 2.4, f3:= { f1:=omit,
f2:=3.5} } }



E.g. the field f2 of v_t3_1 will match all legal values of
MyRecordType2Nested; e.g. it will match { f1:= 0, f2:= 0.0, f3 := omit} as
well as e.g.

{ f1:= 1, f2:= 1.1, f3 := { f1:=omit, f2 := 0.0}} as well as { f1:= 2, f2:=
2.2, f3 := { f1:=5, f2 := 1.1}} etc. In short, f2 := ? will match infinitely
many values (as its type definition is not constrained).



Clause 15.6.2 is about REFERENCING the subfields within a template field
with e.g. AnyValue. Obvious, that if the subfield is mandatory, it will
match any legal value of its type that is the property of the AnyValue
matching attribute. If the subfield is optional, it will also match a
missing field, what it the property of the matching mechanism
AnyValueOrNone. But again, these are not values, but matching mechnisms
(wildcards).



BR, Gyorgy




_____


From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
[This email address is being protected from spambots. You need JavaScript enabled to view it.] On Behalf Of Raúl Alfonso Quintana
Sent: 2009-március-17 12:57
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Referencing record and set elements

Hi,



IÂ’ve been reading the chapter 15.6.2 of core language (Referencing record
and set fields) and I have some doubts. What do you think about the
following example?



type record MyRecordTypeSymple {

integer f1 optional,

float f2

}

type record MyRecordType2Nested {

integer f1,

float f2,

MyRecordTypeSymple f3 optional

}

type record MyRecordType3Nested {

integer f1,

MyRecordType2Nested f2,

MyRecordTypeSymple f3,

float f4

}



var template MyRecordType3Nested v_t3_1 := { f1:=1, f2:=?, f3:=?,
f4:=1.5};

var template MyRecordType3Nested v_t3_2 := { f1:=1, f2:= { f1:=1, f2:=
2.4, f3:= { f1:=omit, f2:=3.5} } };



v_t3_2.f2.f3.f1 := v_t3_1.f2.f3.f1;





The question is: What will the value of v_t3_2 and v_t3_1 be after the
assignment?

I find several options:

1.- The value of v_t3_2 will be

{ f1:=1, f2:= { f1:=1, f2:= 2.4, f3:= { f1:=*, f2:=3.5} } }

and the value of v_t3_1 will be

{ f1:= 1, f2:= { f1:=?, f2:=?, f3:= { f1:=*, f2:=? } }, f3:=?, f4:= 1.5 }

2.- The value of v_t3_2 will be

{ f1:=1, f2:= { f1:=1, f2:= 2.4, f3:= { f1:=*, f2:=3.5} } }

and the value of v_t3_1 will be the
initial value because v_t3_1 donÂ’t change its value (itÂ’s at right hand
side)

{ f1:=1, f2:=?, f3:=?,
f4:=1.5 }

3.- The assignment is an error because when the structured field f2 is
expanded recursively the field “f2.f3” has the value AnyValueOrNone. That
is, when I try to get the template value of “f2.f3.f1”, f2 == ? (AnyValue),
so itÂ’s necessary expanded its template value and f2 template value must
have been { f1:=?, f2:=?, f3:=*} (f3 is optional). Then when I try to get
the field f1 of f2.f3 I couldn’t do it because “f2.f3” is AnyValueOrNone.





Thank you.



Regards,



Raúl Alfonso Quintana
The administrator has disabled public write access.

Referencing record and set elements 18 Mar 2009 10:37 #7550

Hi Raúl,

Exactly these questions what I was driving at. The field MyRecordType2Nested.f3 is optional, i.e. gets "*" when referencing the f3 subfield of MyRecordType3Nested.f2. As subfields within "*" are not allowed to be referenced, it is clear that the line
v_t3_2.f2.f3.f1 := v_t3_1.f2.f3.f1;



shall cause an error. But reading the text of 15.6.2 I cannot find any ambiguity in this.



Regarding your question about changing the content of the *referenced* template, the standard says:

"when referencing a subfield within a structured field to which AnyValue is assigned, at the right hand side of an assignment, AnyValue shall be returned for mandatory subfields and AnyValueOrNone shall be returned for optional subfields."



So, there is no word about "expanding" or changing the content of the template on the rigth hand side. Therefore the content of v_t3_1 will not change whatever is referenced from it.



OK, let change your example:

v_t3_2.f2.f3.f1 := v_t3_1.f3.f1 //this will be legal now.



and the content of v_t3_2 after the assignment is:

v_t3_2 -> { f1:=1, f2:= { f1:=1, f2:= 2.4, f3:= { f1:=*, f2:=3.5} }, f3:=<undefined>, f4:=<undefined> }

Please note, that in this case there is no expansion, just the content of the referenced subfield is changed.



//and an example for the expansion of the left hand side template or field

v_t3_2 := ?

v_t3_2.f2.f3.f1 := v_t3_1.f3.f1

//will result

v_t3_2 -> { f1:=?, f2:= ?, f3:= { f1:=*, f2:=?} }, f3:=?, f4:=?}





BR, Gyorgy





________________________________

From: active_ttcn3 : mts stf133 ttcn version 3 - active members only [This email address is being protected from spambots. You need JavaScript enabled to view it.] On Behalf Of Raúl Alfonso Quintana
Sent: 2009-március-18 10:03
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Referencing record and set elements



Hi Gyorgy,



Thank you for your answer. I agree with you that the value word is incorrect when we talk about templates. But my doubts are about the recursive expanding that it's explained in clause 15.6.2. In the example, I put a situation where I'm not clear about what will be the content of v_t3_1 and v_t3_2 after the assignment. With the three options to my question ("What will the value of v_t3_2 and v_t3_1 be after the assignment?") I wanted to clear up the following doubts:



- Is the content of variable template changed at the right hand side when referencing a subfield within a structured field to which AnyValue is assigned? --> Option 1 or 2

- The option 3 shows two steps in the recursive expanding. The first step the content of v_t3_1 will be:

{ f1:=1, f2:={f1:=?,f2:=?,f3:=*}, f3:=?, f4:=1.5}

And in the second step I try referencing a structured subfield which content is AnyValueOrNone, f2.f3, and this is an error. I don't know if it's right.



Regards,



Raúl Alfonso Quintana




________________________________


De: active_ttcn3 : mts stf133 ttcn version 3 - active members only [This email address is being protected from spambots. You need JavaScript enabled to view it.] En nombre de György Réthy
Enviado el: martes, 17 de marzo de 2009 13:34
Para: This email address is being protected from spambots. You need JavaScript enabled to view it.
Asunto: Re: Referencing record and set elements



Hi Raúl,



"What will the value of v_t3_2 and v_t3_1 be after the assignment?" ->



The better wording is, what will be the CONTENT of v_t3_1 and v_t3_2 be, as we do talk about templates (even if their content may be changed dynamically); i.e. they do not have a value:

v_t3_1 will contain { f1:=1, f2:=?, f3:=?, f4:=1.5}

v_t3_2 will contain { f1:=1, f2:= { f1:=1, f2:= 2.4, f3:= { f1:=omit, f2:=3.5} } }



E.g. the field f2 of v_t3_1 will match all legal values of MyRecordType2Nested; e.g. it will match { f1:= 0, f2:= 0.0, f3 := omit} as well as e.g.

{ f1:= 1, f2:= 1.1, f3 := { f1:=omit, f2 := 0.0}} as well as { f1:= 2, f2:= 2.2, f3 := { f1:=5, f2 := 1.1}} etc. In short, f2 := ? will match infinitely many values (as its type definition is not constrained).



Clause 15.6.2 is about REFERENCING the subfields within a template field with e.g. AnyValue. Obvious, that if the subfield is mandatory, it will match any legal value of its type that is the property of the AnyValue matching attribute. If the subfield is optional, it will also match a missing field, what it the property of the matching mechanism AnyValueOrNone. But again, these are not values, but matching mechnisms (wildcards).



BR, Gyorgy




________________________________


From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
[This email address is being protected from spambots. You need JavaScript enabled to view it.] On Behalf Of Raúl Alfonso Quintana
Sent: 2009-március-17 12:57
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Referencing record and set elements

Hi,



I've been reading the chapter 15.6.2 of core language (Referencing record and set fields) and I have some doubts. What do you think about the following example?



type record MyRecordTypeSymple {

integer f1 optional,

float f2

}

type record MyRecordType2Nested {

integer f1,

float f2,

MyRecordTypeSymple f3 optional

}

type record MyRecordType3Nested {

integer f1,

MyRecordType2Nested f2,

MyRecordTypeSymple f3,

float f4

}



var template MyRecordType3Nested v_t3_1 := { f1:=1,
f2:=?, f3:=?, f4:=1.5};

var template MyRecordType3Nested v_t3_2 := { f1:=1, f2:=
{ f1:=1, f2:= 2.4, f3:= { f1:=omit, f2:=3.5} } };



v_t3_2.f2.f3.f1 := v_t3_1.f2.f3.f1;





The question is: What will the value of v_t3_2 and v_t3_1 be after
the assignment?

I find several options:

1.- The value of v_t3_2 will be

{ f1:=1, f2:= { f1:=1, f2:= 2.4, f3:= { f1:=*,
f2:=3.5} } }

and the value of v_t3_1 will be

{ f1:= 1, f2:= { f1:=?, f2:=?, f3:= { f1:=*, f2:=? }
}, f3:=?, f4:= 1.5 }

2.- The value of v_t3_2 will be

{ f1:=1, f2:= { f1:=1, f2:= 2.4, f3:= { f1:=*,
f2:=3.5} } }

and the value of v_t3_1 will be
the initial value because v_t3_1 don't change its value (it's at right hand side)

{ f1:=1, f2:=?, f3:=?, f4:=1.5 }

3.- The assignment is an error because when the structured field f2
is expanded recursively the field "f2.f3" has the value AnyValueOrNone. That is, when I try to get the template value of "f2.f3.f1", f2 == ? (AnyValue), so it's necessary expanded its template value and f2 template value must have been { f1:=?, f2:=?, f3:=*} (f3 is optional). Then when I try to get the field f1 of f2.f3 I couldn't do it because "f2.f3" is AnyValueOrNone.





Thank you.



Regards,



Raúl Alfonso Quintana
The administrator has disabled public write access.
  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin