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

TOPIC: Referencing record/set fields of template variables

Referencing record/set fields of template variables 10 Nov 2006 09:32 #6962

Hi all

It seems that the second example in section 14.3.1.2 is not correct. Here it
is:

type record R1 {
integer f1 optional,
R2 f2 optional
}
type record R2 {
integer g1,
R2 g2 optional
}

var template R1 t_R1 := {f1:=0, f2:=?};
var template R2 t_R2 := t_R1.f2.g2;

Standards says that "after the assignment t_R2 will be {g1:=?, g2:=*}" but
shouldn't it simply be "*"?

Assuming that example is correct how g2 field should be instantiated if it
has other type than record (e.g. recordof)?

Best regards,
/Pavel
The administrator has disabled public write access.

Referencing record/set fields of template variables 10 Nov 2006 10:11 #6963

Hi,

First, IMHO the field g1 can not be (implicitly) "*", because of the facts that:
(a) this field is not "optional", it must have under all circumstances a value (in this case an unknown one), and
(b) the first assignment "var template R1 t_R1 := {f1:=0, f2:=?};" is saying that for "f2" will be an unknown value (and _not_ a probably missing one).

Second, could you describe more precisely how you would define and use a "record of" in this case? E.g. "type record of R2 R2array;" or something like that..?

Best Regards,

Michael Mzik


Dipl.-Inf. (FH) Michael Mzik
System Designer / Software Engineering
communication & systems group
University Of Applied Sciences Braunschweig/Wolfenbüttel
Salzdahlumer Str. 46/48
Germany - 38302 Wolfenbüttel
Tel.: +49 5331 939-6619
Fax: +49 5331 939-6602
Web: www.cs-group.de
Email: This email address is being protected from spambots. You need JavaScript enabled to view it.

Disclaimer ****
The information in this email may be confidential.
It is intended only for the use of the named recipient.
If your are not the intended recipient please notify us immediately.
You should not disclose the contents to any other person, nor take any copies. Thank you.


Ursprüngliche Nachricht
Von: 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.] Im Auftrag von Pavel Yakovenko
Gesendet: Freitag, 10. November 2006 10:32
An: This email address is being protected from spambots. You need JavaScript enabled to view it.
Betreff: Referencing record/set fields of template variables

Hi all

It seems that the second example in section 14.3.1.2 is not correct. Here it
is:

type record R1 {
integer f1 optional,
R2 f2 optional
}
type record R2 {
integer g1,
R2 g2 optional
}

var template R1 t_R1 := {f1:=0, f2:=?};
var template R2 t_R2 := t_R1.f2.g2;

Standards says that "after the assignment t_R2 will be {g1:=?, g2:=*}" but
shouldn't it simply be "*"?

Assuming that example is correct how g2 field should be instantiated if it
has other type than record (e.g. recordof)?

Best regards,
/Pavel
The administrator has disabled public write access.

Referencing record/set fields of template variables 10 Nov 2006 11:16 #6964

Hi

Yes, "g1" is mandatory field but I'm talking about "g2" field.
After first assignment that is
"var template R1 t_R1 := {f1:=0, f2:=?};"
t_R1.f2 has AnyOne value thus it may be dereferenced according to the
specified rule.

"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."

Since "g2" is optional field AnyValueOrNone (*) is returned for t_R1.f2.g2
and assigned to "t_R2" template variable.

If (as defined in the standard example) we need to instantiate "g2" field
and return filled template of "R2" type (that is the type of "g2" field)
like {?, *} then my question was what are the rules for instantiating fields
of other types.

Suppose "g2" field has type "record of integer" then how many values should
we put into instantiated template variable: zero, one, more?

type record R1 {
integer f1 optional,
R2 f2 optional
}
type record R2 {
integer g1,
R3 g3 optional
}

type record of integer R3

var template R1 t_R1 := {f1:=0, f2:=?};
var template R3 t_R3 := t_R1.f2.g3;

What value will receive t_R3 in this example?

Best regards,
/Pavel

Original Message
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 Michael Mzik
Sent: Friday, November 10, 2006 1:11 PM
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: AW: Referencing record/set fields of template variables

Hi,

First, IMHO the field g1 can not be (implicitly) "*", because of the facts
that:
(a) this field is not "optional", it must have under all circumstances a
value (in this case an unknown one), and
(b) the first assignment "var template R1 t_R1 := {f1:=0, f2:=?};" is saying
that for "f2" will be an unknown value (and _not_ a probably missing one).

Second, could you describe more precisely how you would define and use a
"record of" in this case? E.g. "type record of R2 R2array;" or something
like that..?

Best Regards,

Michael Mzik


Dipl.-Inf. (FH) Michael Mzik
System Designer / Software Engineering
communication & systems group
University Of Applied Sciences Braunschweig/Wolfenbüttel
Salzdahlumer Str. 46/48
Germany - 38302 Wolfenbüttel
Tel.: +49 5331 939-6619
Fax: +49 5331 939-6602
Web: www.cs-group.de
Email: This email address is being protected from spambots. You need JavaScript enabled to view it.

Disclaimer ****
The information in this email may be confidential.
It is intended only for the use of the named recipient.
If your are not the intended recipient please notify us immediately.
You should not disclose the contents to any other person, nor take any
copies. Thank you.


Ursprüngliche Nachricht
Von: 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.] Im Auftrag von Pavel Yakovenko
Gesendet: Freitag, 10. November 2006 10:32
An: This email address is being protected from spambots. You need JavaScript enabled to view it.
Betreff: Referencing record/set fields of template variables

Hi all

It seems that the second example in section 14.3.1.2 is not correct. Here it
is:

type record R1 {
integer f1 optional,
R2 f2 optional
}
type record R2 {
integer g1,
R2 g2 optional
}

var template R1 t_R1 := {f1:=0, f2:=?};
var template R2 t_R2 := t_R1.f2.g2;

Standards says that "after the assignment t_R2 will be {g1:=?, g2:=*}" but
shouldn't it simply be "*"?

Assuming that example is correct how g2 field should be instantiated if it
has other type than record (e.g. recordof)?

Best regards,
/Pavel
The administrator has disabled public write access.

Referencing record/set fields of template variables 10 Nov 2006 13:43 #6965

  • Antti Hyrkk
  • Antti Hyrkk's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 43
  • Karma: 0
Hi Pavel

> Suppose "g2" field has type "record of integer" then how many values should
> we put into instantiated template variable: zero, one, more?
>
> type record R1 {
> integer f1 optional,
> R2 f2 optional
> }
> type record R2 {
> integer g1,
> R3 g3 optional
> }
>
> type record of integer R3
>
> var template R1 t_R1 := {f1:=0, f2:=?};
> var template R3 t_R3 := t_R1.f2.g3;
>
> What value will receive t_R3 in this example?

Hopefully I didn't completely get lost in this, but I put my
bet on that

var template R3 t_R3 := t_R1.f2.g3;

is equal to assignment

var template R3 t_R3 := *;

since

t_R1.f2 == ?

and thus t_R1.f2.g1 == ?
and t_R1.f2.g3 == *;


The value of t_R3 template variable would therefore be AnyValueOrOne,
that matches with: omitted list, empty list, list of any number
of elements containing any values.

But I'm not sure if that's legal assignment or not.

It if is illegal, could I justify that by saying that the template
variable t_R3 does not have the "optional" property, but the field
I'm trying to assign does have. And since the field has value
AnyValueOrNone, the template variable t_R3 is not compatible with the
field value I'm trying to assign into it.

If it is not illegal, should the "*" be converted to "?" in the assignment ?

Again, if it is illegal, does it also mean that
I can use "*" only for the fields, not for the surrounding type.
I mean this:

type record of integer MyRecOfInt;
type record MyRec
{
integer field1 optional
}

/* Is this illegal? */
template MyRecOfInt mw_myIntAnyValueOrNone := *;

template MyRec mw_Rec() :=
{
/* This would then be the same as assigning := * */
field1 := myIntAnyValueOrNone;
}

The same question with "omit".


In the standard they say on AnyValueOrNone that "It can be used on
values of all types, provided that the template field is declared as
optional." That might exclude it from being used for other than fields.

B.1.2.4 Any value or none

The matching symbol "*" (AnyValueOrNone) is used to indicate that
any valid incoming value, including omission of that value, is
acceptable. It can be used on values of all types, provided that the
template field is declared as optional.

There's also Table 6: TTCN-3 Matching Mechanisms, that contains note
on AnyValueOrNone

NOTE 1: When used, shall be applied to optional fields of record and
set types only (without restriction on the type of
that field)

Why is the same note not used also for the OmitValue value?

>
Original Message
> 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 ext Pavel Yakovenko
> Sent: 10. marraskuuta 2006 13:17
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Referencing record/set fields of template variables
>
> Hi
>
> Yes, "g1" is mandatory field but I'm talking about "g2" field.
> After first assignment that is
> "var template R1 t_R1 := {f1:=0, f2:=?};"
> t_R1.f2 has AnyOne value thus it may be dereferenced according to the
> specified rule.
>
> "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."
>
> Since "g2" is optional field AnyValueOrNone (*) is returned for t_R1.f2.g2
> and assigned to "t_R2" template variable.
>
> If (as defined in the standard example) we need to instantiate "g2" field
> and return filled template of "R2" type (that is the type of "g2" field)
> like {?, *} then my question was what are the rules for instantiating fields
> of other types.
>
> Suppose "g2" field has type "record of integer" then how many values should
> we put into instantiated template variable: zero, one, more?
>
> type record R1 {
> integer f1 optional,
> R2 f2 optional
> }
> type record R2 {
> integer g1,
> R3 g3 optional
> }
>
> type record of integer R3
>
> var template R1 t_R1 := {f1:=0, f2:=?};
> var template R3 t_R3 := t_R1.f2.g3;
>
> What value will receive t_R3 in this example?
>
> Best regards,
> /Pavel
>
>
Original Message
> 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 Michael Mzik
> Sent: Friday, November 10, 2006 1:11 PM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: AW: Referencing record/set fields of template variables
>
> Hi,
>
> First, IMHO the field g1 can not be (implicitly) "*", because of the facts
> that:
> (a) this field is not "optional", it must have under all circumstances a
> value (in this case an unknown one), and
> (b) the first assignment "var template R1 t_R1 := {f1:=0, f2:=?};" is saying
> that for "f2" will be an unknown value (and _not_ a probably missing one).
>
> Second, could you describe more precisely how you would define and use a
> "record of" in this case? E.g. "type record of R2 R2array;" or something
> like that..?
>
> Best Regards,
>
> Michael Mzik
>
>
> Dipl.-Inf. (FH) Michael Mzik
> System Designer / Software Engineering
> communication & systems group
> University Of Applied Sciences Braunschweig/Wolfenbüttel
> Salzdahlumer Str. 46/48
> Germany - 38302 Wolfenbüttel
> Tel.: +49 5331 939-6619
> Fax: +49 5331 939-6602
> Web: www.cs-group.de
> Email: This email address is being protected from spambots. You need JavaScript enabled to view it.
>
> Disclaimer ****
> The information in this email may be confidential.
> It is intended only for the use of the named recipient.
> If your are not the intended recipient please notify us immediately.
> You should not disclose the contents to any other person, nor take any
> copies. Thank you.
>
>
>
Ursprüngliche Nachricht
> Von: 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.] Im Auftrag von Pavel Yakovenko
> Gesendet: Freitag, 10. November 2006 10:32
> An: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Betreff: Referencing record/set fields of template variables
>
> Hi all
>
> It seems that the second example in section 14.3.1.2 is not correct. Here it
> is:
>
> type record R1 {
> integer f1 optional,
> R2 f2 optional
> }
> type record R2 {
> integer g1,
> R2 g2 optional
> }
>
> var template R1 t_R1 := {f1:=0, f2:=?};
> var template R2 t_R2 := t_R1.f2.g2;
>
> Standards says that "after the assignment t_R2 will be {g1:=?, g2:=*}" but
> shouldn't it simply be "*"?
>
> Assuming that example is correct how g2 field should be instantiated if it
> has other type than record (e.g. recordof)?
>
> Best regards,
> /Pavel
The administrator has disabled public write access.

Referencing record/set fields of template variables 10 Nov 2006 17:08 #6966

Hi Antti

Well, if we strictly follow standard then AnyValueOrNone is legal only for
optional record/set fields and thus both following assignments should result
in compile/runtime error:
template MyRecOfInt mw_myIntAnyValueOrNone := *;
var template R3 t_R3 := t_R1.f2.g3;

However, personally I do not see any danger in using "*" for values (not
fields) and this gives more flexibility to the developer. Otherwise I always
have to keep in mind which fields are mandatory and which are optional.

Why cannot I write the following code?
type record REC {
integer f optional
}
template REC mytmpl(template integer p) := {f := p}

var template integer tvi := *; //Error here?
var template REC tvr := mytmpl(tvi);

By the way, as you may notice the comment to table 6 was added in the last
revision of the standard while several examples still violate it, e.g.
example in the section 20.1.0 contains code "[] L1.receive(DL_REL_CO:*) {"

Moreover, we may find violation of the a-m rule in the examples that were
added in the 3.1.1 revision. In the last example to the section 14.3.1.3 we
may find:

type record of integer RoI;

var template RoI t_RoI;
var template integer t_Int;

t_RoI := {permutation(0,1,3,?),2,*}
t_Int := t_RoI[5];
// after the assignment t_Int will be * (AnyValueOrNone)

Best regards,
/Pavel

Original Message
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 Antti Hyrkkanen
Sent: Friday, November 10, 2006 4:44 PM
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Referencing record/set fields of template variables

Hi Pavel

> Suppose "g2" field has type "record of integer" then how many values
should
> we put into instantiated template variable: zero, one, more?
>
> type record R1 {
> integer f1 optional,
> R2 f2 optional
> }
> type record R2 {
> integer g1,
> R3 g3 optional
> }
>
> type record of integer R3
>
> var template R1 t_R1 := {f1:=0, f2:=?};
> var template R3 t_R3 := t_R1.f2.g3;
>
> What value will receive t_R3 in this example?

Hopefully I didn't completely get lost in this, but I put my
bet on that

var template R3 t_R3 := t_R1.f2.g3;

is equal to assignment

var template R3 t_R3 := *;

since

t_R1.f2 == ?

and thus t_R1.f2.g1 == ?
and t_R1.f2.g3 == *;


The value of t_R3 template variable would therefore be AnyValueOrOne,
that matches with: omitted list, empty list, list of any number
of elements containing any values.

But I'm not sure if that's legal assignment or not.

It if is illegal, could I justify that by saying that the template
variable t_R3 does not have the "optional" property, but the field
I'm trying to assign does have. And since the field has value
AnyValueOrNone, the template variable t_R3 is not compatible with the
field value I'm trying to assign into it.

If it is not illegal, should the "*" be converted to "?" in the assignment ?


Again, if it is illegal, does it also mean that
I can use "*" only for the fields, not for the surrounding type.
I mean this:

type record of integer MyRecOfInt;
type record MyRec
{
integer field1 optional
}

/* Is this illegal? */
template MyRecOfInt mw_myIntAnyValueOrNone := *;

template MyRec mw_Rec() :=
{
/* This would then be the same as assigning := * */
field1 := myIntAnyValueOrNone;
}

The same question with "omit".


In the standard they say on AnyValueOrNone that "It can be used on
values of all types, provided that the template field is declared as
optional." That might exclude it from being used for other than fields.

B.1.2.4 Any value or none

The matching symbol "*" (AnyValueOrNone) is used to indicate that
any valid incoming value, including omission of that value, is
acceptable. It can be used on values of all types, provided that the
template field is declared as optional.

There's also Table 6: TTCN-3 Matching Mechanisms, that contains note
on AnyValueOrNone

NOTE 1: When used, shall be applied to optional fields of record and
set types only (without restriction on the type of
that field)

Why is the same note not used also for the OmitValue value?

>
Original Message
> 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 ext Pavel Yakovenko
> Sent: 10. marraskuuta 2006 13:17
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Referencing record/set fields of template variables
>
> Hi
>
> Yes, "g1" is mandatory field but I'm talking about "g2" field.
> After first assignment that is
> "var template R1 t_R1 := {f1:=0, f2:=?};"
> t_R1.f2 has AnyOne value thus it may be dereferenced according to the
> specified rule.
>
> "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."
>
> Since "g2" is optional field AnyValueOrNone (*) is returned for t_R1.f2.g2
> and assigned to "t_R2" template variable.
>
> If (as defined in the standard example) we need to instantiate "g2" field
> and return filled template of "R2" type (that is the type of "g2" field)
> like {?, *} then my question was what are the rules for instantiating
fields
> of other types.
>
> Suppose "g2" field has type "record of integer" then how many values
should
> we put into instantiated template variable: zero, one, more?
>
> type record R1 {
> integer f1 optional,
> R2 f2 optional
> }
> type record R2 {
> integer g1,
> R3 g3 optional
> }
>
> type record of integer R3
>
> var template R1 t_R1 := {f1:=0, f2:=?};
> var template R3 t_R3 := t_R1.f2.g3;
>
> What value will receive t_R3 in this example?
>
> Best regards,
> /Pavel
>
>
Original Message
> 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 Michael Mzik
> Sent: Friday, November 10, 2006 1:11 PM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: AW: Referencing record/set fields of template variables
>
> Hi,
>
> First, IMHO the field g1 can not be (implicitly) "*", because of the facts
> that:
> (a) this field is not "optional", it must have under all circumstances a
> value (in this case an unknown one), and
> (b) the first assignment "var template R1 t_R1 := {f1:=0, f2:=?};" is
saying
> that for "f2" will be an unknown value (and _not_ a probably missing one).
>
> Second, could you describe more precisely how you would define and use a
> "record of" in this case? E.g. "type record of R2 R2array;" or something
> like that..?
>
> Best Regards,
>
> Michael Mzik
>
>
> Dipl.-Inf. (FH) Michael Mzik
> System Designer / Software Engineering
> communication & systems group
> University Of Applied Sciences Braunschweig/Wolfenbüttel
> Salzdahlumer Str. 46/48
> Germany - 38302 Wolfenbüttel
> Tel.: +49 5331 939-6619
> Fax: +49 5331 939-6602
> Web: www.cs-group.de
> Email: This email address is being protected from spambots. You need JavaScript enabled to view it.
>
> Disclaimer ****
> The information in this email may be confidential.
> It is intended only for the use of the named recipient.
> If your are not the intended recipient please notify us immediately.
> You should not disclose the contents to any other person, nor take any
> copies. Thank you.
>
>
>
Ursprüngliche Nachricht
> Von: 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.] Im Auftrag von Pavel Yakovenko
> Gesendet: Freitag, 10. November 2006 10:32
> An: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Betreff: Referencing record/set fields of template variables
>
> Hi all
>
> It seems that the second example in section 14.3.1.2 is not correct. Here
it
> is:
>
> type record R1 {
> integer f1 optional,
> R2 f2 optional
> }
> type record R2 {
> integer g1,
> R2 g2 optional
> }
>
> var template R1 t_R1 := {f1:=0, f2:=?};
> var template R2 t_R2 := t_R1.f2.g2;
>
> Standards says that "after the assignment t_R2 will be {g1:=?, g2:=*}" but
> shouldn't it simply be "*"?
>
> Assuming that example is correct how g2 field should be instantiated if it
> has other type than record (e.g. recordof)?
>
> Best regards,
> /Pavel
The administrator has disabled public write access.
  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin