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

TOPIC: Parameterization of modified templates

Parameterization of modified templates 11 Sep 2003 02:37 #6506

  • Xdji
  • Xdji's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 10
  • Karma: 0
Hi all,
I have some questions about parameterization of modified templates,please
give me some help.

1. Clause 14.6.1 says the derived template should contain all parameters
defined in the base templates. Should these parameters must be defined in
derived template with the same types, names and sequence in base template? For
example:

template MyRecord T1 (integer par1,charstring par2) :=
{
field1 := par1,
field2 := par2
}
template MyRecord T2 (charsring par2, integer par1) modifies T1 :=
{...}

template MyRecord T3 (integer MyPar1, charstring MyPar2) modifies T1 :=
{...}

T2 and T3 are correct or not?


2. Subclause b of 14.6.1 says :" base template fields containing parameterized
templates shall not be modified or explicitly omitted in a modified template."
What does it mean?

Thanks a lot!



Ji XiangDong
Univ. of Science & Technology of China
86-551-3606124
This email address is being protected from spambots. You need JavaScript enabled to view it.
2003-09-11 10:19:07
The administrator has disabled public write access.

Parameterization of modified templates 11 Sep 2003 05:33 #6507

Hi,

please see below for comments.

BR

Stephan

>
Original Message
> From: ext xdji [This email address is being protected from spambots. You need JavaScript enabled to view it.]
> Sent: 11. September 2003 04:37
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Parameterization of modified templates
>
>
> Hi all,
> I have some questions about parameterization of modified
> templates,please give me some help.
>
> 1. Clause 14.6.1 says the derived template should contain
> all parameters defined in the base templates. Should these
> parameters must be defined in derived template with the same
> types, names and sequence in base template? For example:

Same names, same types, same order.

>
> template MyRecord T1 (integer par1,charstring par2) :=
> {
> field1 := par1,
> field2 := par2
> }
> template MyRecord T2 (charsring par2, integer par1)
> modifies T1 :=
> {...}

Incorrect - changed order of parameters.

>
> template MyRecord T3 (integer MyPar1, charstring
> MyPar2) modifies T1 :=
> {...}

Incorrect - different names.

The first restriction is really more for compiler convenience - as long as the parameters are there with the same names and the same types, order is not so relevant. Semantically, it would still make sense. On the order hand, order is really not relevant so one might as well require the same order for both templates.

The different names are a different story: Consider this example:

type record Rec {
integer a,
integer b
}

template Rec temp1(integer p_a, integer p_b) := { a := p_a, b := p_b };

template Rec temp2(integer p_A, integer b_B) modifies temp1 := { a := p_A };

When resolving the 'modifies' in temp2, we get

template Rec temp2(integer p_A, integer b_B) modifies temp1 := { a := p_A, b := p_b };

p_b is an undefined name in temp2, due to the changed of names. Enforcing the same parameter names stops this problem.



> 2. Subclause b of 14.6.1 says :" base template fields
> containing parameterized templates shall not be modified or
> explicitly omitted in a modified template." What does it mean?

It means that, if you are modifying a template, you may not overwrite those fields that contain parameterized templates:

template a_int(integer x) := 2*x;

template Rec temp3(integer x) := { a := x, b := a_int(x) };

template Rec temp4(integer x) modified temp3 := { b := 1 };

The definition of temp4 modifies field b of the base template, which contains a parameterized template -> this is not allowed.

When implementing the whole 'modifies' stuff in our compiler, I found that all of these restrictions for 'modifies' did make sense, but I have forgotten why this particular restriction was there.

>
> Thanks a lot!
>
>
>
> Ji XiangDong
> Univ. of Science & Technology of China
> 86-551-3606124
> This email address is being protected from spambots. You need JavaScript enabled to view it.
> 2003-09-11 10:19:07
>
The administrator has disabled public write access.

Parameterization of modified templates 11 Sep 2003 08:45 #6508

  • Xdji
  • Xdji's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 10
  • Karma: 0
Hi all,

Thanks for Stephen's input.

More questions about template:

1.Is there any restriction on the types of base template, e.g.,should be a
structured type?

template integer T1 := ?;
template integer T2 modifies T1 := (10..20);

T2 is syntactically correct, but deos it still make sense semantically?

2.There was once a discussion about partial template, but I cannot find the
complete record, please forgive
me if my question repeats something had been clarified.
I assume the partial template is not allowed, so the following
definition is invalid:

type record rec {integer f1, integer f2};
template rec t1 := {f1 := 10}; /*partial
template, INVALID*/
template rec t2 modifies t1 := {f2 := ?}; /*derived from a
partial template, INVALID*/

I am right?

3. Given the definitions:
type record of integer SI;
template SI t1 := {[0] := 0, [1] := 1, [2] := 2 };
template SI t2 modifies t1 := {[3] := 3};
template SI t3 modifies t1 := {10, 20, 30, 40};

t2 adds one element in its templatebody derived from t1, and t3 modifies
t1 with another value notation.
Are both of them invalid definitions?

4. SingleValueOrAttrib ::= MatchingSymbol [ExtraMatchingAttributes] |
SingleExpression
[ExtraMatchingAttributes] |
TemplateRefWithParList

Standard says that variable may only be used in inline template definitions via
SingleExpression, but such
discription is not clear enough. Can we define template fields with function
invokings and other language elements
which can be interpreted as SingleExpressions? For example:

module test
{
function f1() return integer
{...}
function f2(integer i) return integer
{...}

type component M
{...}

type record rec {integer f1, integer f2};

template rec t1 := {f1 := f(), f2 := ?}; /*ALLOWED??*/
tempalte rec t2(integer j) := {f1 := f(j), f2 := ?} /*ALLOWED??*/

testcase ts() runs on M system M
{
var integer v1;
....
pco1.send(t1);
pco1.send(t1(v1));
}

}


5.The last, clause 14.1.0 says "Templates may be specified for any TTCN-3 type
defined in table 3 except for the special configuration and default types (port,
component, address and default)." But in Table 6,there is no matching mechanisms
for
VERDICTTYPE, why?

Thanks!



Stephen TOBIES wrote:
>Hi,
>
>please see below for comments.
>
>BR
>
>Stephan
>


Best Regards
Ji XiangDong
USTC
2003-09-11 15:30:27
The administrator has disabled public write access.
  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin