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

TOPIC: Comparison of templates

Comparison of templates 29 May 2007 12:29 #7112

Hello together,

Let me ask a further question about templates, just to check whether I
have the correct understanding:

Clause 7.1. of TTCN-3 part 1 defines operators on expressions.
Especially 7.1.c. defines relational operators, with equality '==' being
a very important one.
Clause 11.2, restriction b), prohibits the use of template variables on
the right hand side of assignments. Is it correct to conclude that it is
not possible to check two templates for equality? Assume that one of the
operands is a template variable or a subfield in a template variable of
a structured type. Is my understanding correct? Any comments are
appreciated.

Btw: this restriction does not exclude parameterized templates or
template computing functions as operands of expressions.

Best regards

Thomas
The administrator has disabled public write access.

Comparison of templates 29 May 2007 16:22 #7113

Hello Thomas,



Clause 11.2 defines that:



“Template variables may be used on the right hand side as well as on the
left hand side of assignments […]”.



So the use of template variables on the right side of assignments is not
forbidden.



“When used on the right hand side of assignments template variables shall
not be operands of TTCN-3 operators (see clause 7.1) and the variable on the
left hand side shall be a template variable too.”



I understand the clause 11.2 restriction b) points out is the fact that in
case of a template variable is on the right hand side of assignment:

a) The left hand side MUST be a template variable.

b) It can not be part of TTCN-3 operator (except the assignment
itself). It can not be an operand of TTCN-3 operators.



So you can assign a value/ template o variable template to a variable
template.



In the other hand, reading the NOTE 1 from clause 11.2 “[…] it is not
allowed to directly apply TTCN-3 operations to template variables, it is
allowed to use the dot notation and the index notation to inspect and modify
template variable fields [...]” we can conclude that this also affects the
relational operators, so it isnÂ’t possible to check two templates for
equality.



What I understand from all this is that you can not apply TTCN-3 operations
to template variables, but the assignment operation and the use of the
notation needed to inspect and modify template variable fields.



This my point of view, but maybe it is not correctÂ… Any more comments?





_____

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 Thomas Deiss
Enviado el: martes, 29 de mayo de 2007 14:29
Para: This email address is being protected from spambots. You need JavaScript enabled to view it.
Asunto: Comparison of templates



Hello together,

Let me ask a further question about templates, just to check whether I have
the correct understanding:

Clause 7.1. of TTCN-3 part 1 defines operators on expressions. Especially
7.1.c. defines relational operators, with equality '==' being a very
important one.

Clause 11.2, restriction b), prohibits the use of template variables on the
right hand side of assignments. Is it correct to conclude that it is not
possible to check two templates for equality? Assume that one of the
operands is a template variable or a subfield in a template variable of a
structured type. Is my understanding correct? Any comments are appreciated.

Btw: this restriction does not exclude parameterized templates or template
computing functions as operands of expressions.

Best regards

Thomas
The administrator has disabled public write access.

Comparison of templates 30 May 2007 12:03 #7118

Hi Thomas,





Clarification:



clause b) of 11.2 states something a bit different. Template variables can
be used on the RHS of an assignment, however they cannot be used as operands
of a TTCN-3 operator as defined in 7.1.



type T_1 // some type .





var template T_1 tem1, tem2, tem3;



Eg. tem1 := tem2; // OK



tem1 := ( tem2 + tem3);





NOTE: 11.2 b) should also state that the type of the LHS and the RHS
template variables should be compatible to one another.



QUESTION: Why is ':=' not defined as an operator as it is included in the
BNF definition related to Expressions in 7 of ES20187301?







Your assumption is incorrect. There are a few ways you can choose to verify
template equivalence. Albeit the methods are indirect. :-)



RESTRICTION: Method 1) only works if all fields of a template variable
contain specific values, that is, no matching mechanisms. So the solutions
offered below are limited. (see 15.9 a) Restrictions.



CLARIFICATION: What should happen when a valueof() operation is applied to
a template instance which uses matching mechanisms?

I would prefer that this produce a compilation error as this can be verified
statically. Alternatively, ( less desirable) an error verdict could be
assigned at runtime when the operation is attempted.





I ) Method: Use valueof



A simple solution to your problem is to first define value variables of the
same type as the templates you wish to compare,

Then use the valueof() operation ( 15.9 Valueof Operation) in ES20187301 on
both templates to convert the values to value instances. Thereafter these
two variables can be used with operators specified in 7.1 as you need.



Using the valueof() function simply removes any restrictions which apply to
templates and the use of operators. :-).





II) Method: Field by field conversion then use of valueof



As in solution 1), but takes more code, you can convert individual fields of
a template variable to a value, then use operators as ( ==) as needed.



III) Method: Roll your own template comparison function



Simply write your own function which does a field by field comparison of
values. This is likely to be the only method possible which gets around
restriction 15.9 a).





Note: The example specified in 15.9 is incomplete as it does not show the
value contained in RxValue ( kind of obvious, but. )







E.g.



RxValue { 1, true }





OK, that's my 2 (Euro) cents for the day.



Let me know if you have any questions.





Cheers,



Claude.





_____

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 Thomas Deiss
Sent: 29 May 2007 14:29
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Comparison of templates



Hello together,

Let me ask a further question about templates, just to check whether I have
the correct understanding:

Clause 7.1. of TTCN-3 part 1 defines operators on expressions. Especially
7.1.c. defines relational operators, with equality '==' being a very
important one.

Clause 11.2, restriction b), prohibits the use of template variables on the
right hand side of assignments. Is it correct to conclude that it is not
possible to check two templates for equality? Assume that one of the
operands is a template variable or a subfield in a template variable of a
structured type. Is my understanding correct? Any comments are appreciated.

Btw: this restriction does not exclude parameterized templates or template
computing functions as operands of expressions.

Best regards

Thomas
The administrator has disabled public write access.

Comparison of templates 31 May 2007 11:15 #7121

Hello Claude,

thanks for the clarifications.
Still, it seems there is no way in TTCN-3 to compare fields in a
template which are not values. For example, ther is no way to check
whether a field of a template is defined as the matching expression
AnyValue.

Best regards

Thomas


________________________________

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 Claude Desroches
Sent: Wednesday, 30. May 2007 14:04
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Comparison of templates





Hi Thomas,





Clarification:



clause b) of 11.2 states something a bit different. Template
variables can be used on the RHS of an assignment, however they cannot
be used as operands of a TTCN-3 operator as defined in 7.1.



type T_1 // some type ...





var template T_1 tem1, tem2, tem3;



Eg. tem1 := tem2; // OK



tem1 := ( tem2 + tem3);





NOTE: 11.2 b) should also state that the type of the LHS and the
RHS template variables should be compatible to one another.



QUESTION: Why is ':=' not defined as an operator as it is
included in the BNF definition related to Expressions in 7 of
ES20187301?







Your assumption is incorrect. There are a few ways you can
choose to verify template equivalence. Albeit the methods are indirect.
:-)



RESTRICTION: Method 1) only works if all fields of a template
variable contain specific values, that is, no matching mechanisms. So
the solutions offered below are limited. (see 15.9 a) Restrictions.



CLARIFICATION: What should happen when a valueof() operation is
applied to a template instance which uses matching mechanisms?

I would prefer that this produce a compilation error as this can
be verified statically. Alternatively, ( less desirable) an error
verdict could be assigned at runtime when the operation is attempted.





I ) Method: Use valueof



A simple solution to your problem is to first define value
variables of the same type as the templates you wish to compare,

Then use the valueof() operation ( 15.9 Valueof Operation) in
ES20187301 on both templates to convert the values to value instances.
Thereafter these two variables can be used with operators specified in
7.1 as you need.



Using the valueof() function simply removes any restrictions
which apply to templates and the use of operators. :-).





II) Method: Field by field conversion then use of valueof



As in solution 1), but takes more code, you can convert
individual fields of a template variable to a value, then use operators
as ( ==) as needed.



III) Method: Roll your own template comparison function



Simply write your own function which does a field by field
comparison of values. This is likely to be the only method possible
which gets around restriction 15.9 a).





Note: The example specified in 15.9 is incomplete as it does
not show the value contained in RxValue ( kind of obvious, but... )







E.g.



RxValue { 1, true }





OK, that's my 2 (Euro) cents for the day.



Let me know if you have any questions.





Cheers,



Claude.






________________________________


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 Thomas Deiss
Sent: 29 May 2007 14:29
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Comparison of templates



Hello together,

Let me ask a further question about templates, just to check
whether I have the correct understanding:

Clause 7.1. of TTCN-3 part 1 defines operators on expressions.
Especially 7.1.c. defines relational operators, with equality '==' being
a very important one.

Clause 11.2, restriction b), prohibits the use of template
variables on the right hand side of assignments. Is it correct to
conclude that it is not possible to check two templates for equality?
Assume that one of the operands is a template variable or a subfield in
a template variable of a structured type. Is my understanding correct?
Any comments are appreciated.

Btw: this restriction does not exclude parameterized templates
or template computing functions as operands of expressions.

Best regards

Thomas
The administrator has disabled public write access.

Comparison of templates 31 May 2007 11:21 #7124

You can match the template field against to different values, if both ok
=> has to be AnyValue in template.

________________________________

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 Thomas Deiss
Sent: den 31 maj 2007 13:15
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Comparison of templates


Hello Claude,

thanks for the clarifications.
Still, it seems there is no way in TTCN-3 to compare fields in a
template which are not values. For example, ther is no way to check
whether a field of a template is defined as the matching expression
AnyValue.

Best regards

Thomas


________________________________

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 Claude Desroches
Sent: Wednesday, 30. May 2007 14:04
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Comparison of templates





Hi Thomas,





Clarification:



clause b) of 11.2 states something a bit different. Template
variables can be used on the RHS of an assignment, however they cannot
be used as operands of a TTCN-3 operator as defined in 7.1.



type T_1 // some type ...





var template T_1 tem1, tem2, tem3;



Eg. tem1 := tem2; // OK



tem1 := ( tem2 + tem3);





NOTE: 11.2 b) should also state that the type of the LHS and the
RHS template variables should be compatible to one another.



QUESTION: Why is ':=' not defined as an operator as it is
included in the BNF definition related to Expressions in 7 of
ES20187301?







Your assumption is incorrect. There are a few ways you can
choose to verify template equivalence. Albeit the methods are indirect.
:-)



RESTRICTION: Method 1) only works if all fields of a template
variable contain specific values, that is, no matching mechanisms. So
the solutions offered below are limited. (see 15.9 a) Restrictions.



CLARIFICATION: What should happen when a valueof() operation is
applied to a template instance which uses matching mechanisms?

I would prefer that this produce a compilation error as this can
be verified statically. Alternatively, ( less desirable) an error
verdict could be assigned at runtime when the operation is attempted.





I ) Method: Use valueof



A simple solution to your problem is to first define value
variables of the same type as the templates you wish to compare,

Then use the valueof() operation ( 15.9 Valueof Operation) in
ES20187301 on both templates to convert the values to value instances.
Thereafter these two variables can be used with operators specified in
7.1 as you need.



Using the valueof() function simply removes any restrictions
which apply to templates and the use of operators. :-).





II) Method: Field by field conversion then use of valueof



As in solution 1), but takes more code, you can convert
individual fields of a template variable to a value, then use operators
as ( ==) as needed.



III) Method: Roll your own template comparison function



Simply write your own function which does a field by field
comparison of values. This is likely to be the only method possible
which gets around restriction 15.9 a).





Note: The example specified in 15.9 is incomplete as it does
not show the value contained in RxValue ( kind of obvious, but... )







E.g.



RxValue { 1, true }





OK, that's my 2 (Euro) cents for the day.



Let me know if you have any questions.





Cheers,



Claude.






________________________________


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 Thomas Deiss
Sent: 29 May 2007 14:29
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Comparison of templates



Hello together,

Let me ask a further question about templates, just to check
whether I have the correct understanding:

Clause 7.1. of TTCN-3 part 1 defines operators on expressions.
Especially 7.1.c. defines relational operators, with equality '==' being
a very important one.

Clause 11.2, restriction b), prohibits the use of template
variables on the right hand side of assignments. Is it correct to
conclude that it is not possible to check two templates for equality?
Assume that one of the operands is a template variable or a subfield in
a template variable of a structured type. Is my understanding correct?
Any comments are appreciated.

Btw: this restriction does not exclude parameterized templates
or template computing functions as operands of expressions.

Best regards

Thomas
The administrator has disabled public write access.

Comparison of templates 31 May 2007 13:29 #7125

Hello Mikael,

hey, that's clever.

Best regards

Thomas


________________________________

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 Mikael Rosberg XX
(KA/EAB)
Sent: Thursday, 31. May 2007 13:22
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Comparison of templates


You can match the template field against to different values, if
both ok => has to be AnyValue in template.

________________________________

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 Thomas Deiss
Sent: den 31 maj 2007 13:15
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Comparison of templates


Hello Claude,

thanks for the clarifications.
Still, it seems there is no way in TTCN-3 to compare fields in a
template which are not values. For example, ther is no way to check
whether a field of a template is defined as the matching expression
AnyValue.

Best regards

Thomas


<--- snip, TD --->
The administrator has disabled public write access.

Comparison of templates 31 May 2007 21:46 #7127

Well, does not quite work ... the match would also be ok for a template
of value list containing those two values ... there are also other
versions to get match agaings two values ...

Cheers, Ina

>
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 Thomas Deiss
> Sent: Thursday, May 31, 2007 3:30 PM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Comparison of templates
>
> Hello Mikael,
>
> hey, that's clever.
>
> Best regards
>
> Thomas
>
>
> ________________________________
>
> 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
> Mikael Rosberg XX (KA/EAB)
> Sent: Thursday, 31. May 2007 13:22
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Comparison of templates
>
>
> You can match the template field against to different
> values, if both ok => has to be AnyValue in template.
>
> ________________________________
>
> 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 Thomas Deiss
> Sent: den 31 maj 2007 13:15
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Comparison of templates
>
>
> Hello Claude,
>
> thanks for the clarifications.
> Still, it seems there is no way in TTCN-3 to compare
> fields in a template which are not values. For example, ther
> is no way to check whether a field of a template is defined
> as the matching expression AnyValue.
>
> Best regards
>
> Thomas
>
>
> <--- snip, TD --->
>
>
>
The administrator has disabled public write access.

Comparison of templates 01 Jun 2007 10:04 #7131

Hi Thomas,



No problems. You are correct in saying that only values can be compared. I
am not sure whether that was the original intent when the sizeof function
was defined.



By the way, is 'value' still a TTCN-3 keyword? (It is still listed as a
keyword in the CL standard.



Thanks ahead of time.



Cheers,



Claude.





Blue Cactus Consulting phone: +49 (0)30 9606 7985

Edinburger Str. 39 fax: +49 (0)30 9606 7987

13349 Berlin mobile: +49 (0)174 701 6792

Germany email: This email address is being protected from spambots. You need JavaScript enabled to view it.



_____

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 Thomas Deiss
Sent: 31 May 2007 13:15
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Comparison of templates



Hello Claude,



thanks for the clarifications.

Still, it seems there is no way in TTCN-3 to compare fields in a template
which are not values. For example, ther is no way to check whether a field
of a template is defined as the matching expression AnyValue.



Best regards



Thomas




_____


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 Claude Desroches
Sent: Wednesday, 30. May 2007 14:04
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Comparison of templates



Hi Thomas,





Clarification:



clause b) of 11.2 states something a bit different. Template variables can
be used on the RHS of an assignment, however they cannot be used as operands
of a TTCN-3 operator as defined in 7.1.



type T_1 // some type .





var template T_1 tem1, tem2, tem3;



Eg. tem1 := tem2; // OK



tem1 := ( tem2 + tem3);





NOTE: 11.2 b) should also state that the type of the LHS and the RHS
template variables should be compatible to one another.



QUESTION: Why is ':=' not defined as an operator as it is included in the
BNF definition related to Expressions in 7 of ES20187301?







Your assumption is incorrect. There are a few ways you can choose to verify
template equivalence. Albeit the methods are indirect. :-)



RESTRICTION: Method 1) only works if all fields of a template variable
contain specific values, that is, no matching mechanisms. So the solutions
offered below are limited. (see 15.9 a) Restrictions.



CLARIFICATION: What should happen when a valueof() operation is applied to
a template instance which uses matching mechanisms?

I would prefer that this produce a compilation error as this can be verified
statically. Alternatively, ( less desirable) an error verdict could be
assigned at runtime when the operation is attempted.





I ) Method: Use valueof



A simple solution to your problem is to first define value variables of the
same type as the templates you wish to compare,

Then use the valueof() operation ( 15.9 Valueof Operation) in ES20187301 on
both templates to convert the values to value instances. Thereafter these
two variables can be used with operators specified in 7.1 as you need.



Using the valueof() function simply removes any restrictions which apply to
templates and the use of operators. :-).





II) Method: Field by field conversion then use of valueof



As in solution 1), but takes more code, you can convert individual fields of
a template variable to a value, then use operators as ( ==) as needed.



III) Method: Roll your own template comparison function



Simply write your own function which does a field by field comparison of
values. This is likely to be the only method possible which gets around
restriction 15.9 a).





Note: The example specified in 15.9 is incomplete as it does not show the
value contained in RxValue ( kind of obvious, but. )







E.g.



RxValue { 1, true }





OK, that's my 2 (Euro) cents for the day.



Let me know if you have any questions.





Cheers,



Claude.






_____


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 Thomas Deiss
Sent: 29 May 2007 14:29
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Comparison of templates



Hello together,

Let me ask a further question about templates, just to check whether I have
the correct understanding:

Clause 7.1. of TTCN-3 part 1 defines operators on expressions. Especially
7.1.c. defines relational operators, with equality '==' being a very
important one.

Clause 11.2, restriction b), prohibits the use of template variables on the
right hand side of assignments. Is it correct to conclude that it is not
possible to check two templates for equality? Assume that one of the
operands is a template variable or a subfield in a template variable of a
structured type. Is my understanding correct? Any comments are appreciated.

Btw: this restriction does not exclude parameterized templates or template
computing functions as operands of expressions.

Best regards

Thomas
The administrator has disabled public write access.

Comparison of templates 01 Jun 2007 16:08 #7139

Hi Thomas,

Your understanding is correct. There is no way to check the "equality" of two templates directly. But this is not an obvious question. Templates are not values. Especially when used in receiving operations.

var template integer t_int1 := (1,2,3,4,5);
var template integer t_int2 := ?;

Both the above templates will match the integer value 5. So, are they equal? I think this is an invalid question; the answer is "Method 1)" using valueof, though it is imposing the limitation of having specific values in field of the templates.
"Btw: this restriction does not exclude parameterized templates or template computing functions as operands of expressions." -> the clause itself ($11.2) is about template variables; Use of functions returning templates in expressions are excluded by $7: "Functions used in expressions shall be value-returning functions". But templates seems to be not handled.



"NOTE: 11.2 b) should also state that the type of the LHS and the RHS template variables should be compatible to one another.

QUESTION: Why is ‘:=’ not defined as an operator as it is included in the BNF definition related to Expressions in 7 of ES20187301?"

-> It IS defined in $19.1. In particular "

a) The right‑hand side of an assignment shall evaluate to a value or template, which is type compatible with the variable at the left-hand side of the assignment.

"





"CLARIFICATION: What should happen when a valueof() operation is applied to a template instance which uses matching mechanisms?" -> $15.9 a) "Each field of the template shall resolve to a specific value"; shall it cause compile-time or run-time error?; it is a tooling issue. The standard intentionally does not deals with tool implementation issues (one aspect of being an abstract language). But, except that, in some cases it is checkable compile time (e.g. in templates) but in other cases checkable only in runtime (e.g. in template variables). So, there is no simple answer to this question.



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 Claude Desroches
Sent: Friday, 2007 June 01. 12:04 PM
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Comparison of templates





Hi Thomas,



No problems. You are correct in saying that only values can be compared. I am not sure whether that was the original intent when the sizeof function was defined.



By the way, is ‘value’ still a TTCN-3 keyword? (It is still listed as a keyword in the CL standard.



Thanks ahead of time.



Cheers,



Claude.





Blue Cactus Consulting phone: +49 (0)30 9606 7985

Edinburger Str. 39 fax: +49 (0)30 9606 7987

13349 Berlin mobile: +49 (0)174 701 6792

Germany email: This email address is being protected from spambots. You need JavaScript enabled to view it.




________________________________


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 Thomas Deiss
Sent: 31 May 2007 13:15
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Comparison of templates



Hello Claude,



thanks for the clarifications.

Still, it seems there is no way in TTCN-3 to compare fields in a template which are not values. For example, ther is no way to check whether a field of a template is defined as the matching expression AnyValue.



Best regards



Thomas




________________________________


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 Claude Desroches
Sent: Wednesday, 30. May 2007 14:04
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Comparison of templates



Hi Thomas,





Clarification:



clause b) of 11.2 states something a bit different. Template variables can be used on the RHS of an assignment, however they cannot be used as operands of a TTCN-3 operator as defined in 7.1.



type T_1 // some type …





var template T_1 tem1, tem2, tem3;



Eg. tem1 := tem2; // OK



tem1 := ( tem2 + tem3);





NOTE: 11.2 b) should also state that the type of the LHS and the RHS template variables should be compatible to one another.



QUESTION: Why is ‘:=’ not defined as an operator as it is included in the BNF definition related to Expressions in 7 of ES20187301?







Your assumption is incorrect. There are a few ways you can choose to verify template equivalence. Albeit the methods are indirect. :-)



RESTRICTION: Method 1) only works if all fields of a template variable contain specific values, that is, no matching mechanisms. So the solutions offered below are limited. (see 15.9 a) Restrictions.



CLARIFICATION: What should happen when a valueof() operation is applied to a template instance which uses matching mechanisms?

I would prefer that this produce a compilation error as this can be verified statically. Alternatively, ( less desirable) an error verdict could be assigned at runtime when the operation is attempted.





I ) Method: Use valueof



A simple solution to your problem is to first define value variables of the same type as the templates you wish to compare,

Then use the valueof() operation ( 15.9 Valueof Operation) in ES20187301 on both templates to convert the values to value instances. Thereafter these two variables can be used with operators specified in 7.1 as you need.



Using the valueof() function simply removes any restrictions which apply to templates and the use of operators. :-).





II) Method: Field by field conversion then use of valueof



As in solution 1), but takes more code, you can convert individual fields of a template variable to a value, then use operators as ( ==) as needed.



III) Method: Roll your own template comparison function



Simply write your own function which does a field by field comparison of values. This is likely to be the only method possible which gets around restriction 15.9 a).





Note: The example specified in 15.9 is incomplete as it does not show the value contained in RxValue ( kind of obvious, but… )







E.g.



RxValue { 1, true }





OK, that’s my 2 (Euro) cents for the day.



Let me know if you have any questions.





Cheers,



Claude.






________________________________


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 Thomas Deiss
Sent: 29 May 2007 14:29
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Comparison of templates



Hello together,

Let me ask a further question about templates, just to check whether I have the correct understanding:

Clause 7.1. of TTCN-3 part 1 defines operators on expressions. Especially 7.1.c. defines relational operators, with equality '==' being a very important one.

Clause 11.2, restriction b), prohibits the use of template variables on the right hand side of assignments. Is it correct to conclude that it is not possible to check two templates for equality? Assume that one of the operands is a template variable or a subfield in a template variable of a structured type. Is my understanding correct? Any comments are appreciated.

Btw: this restriction does not exclude parameterized templates or template computing functions as operands of expressions.

Best regards

Thomas
The administrator has disabled public write access.
  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin