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

TOPIC: Assigning parameterized templates

Assigning parameterized templates 17 Dec 2007 15:56 #7275

Hello together,

Currently I am pondering on template computing functions. When doing so I came across template computing functions that might return parameterized templates. As this case is not mentioned at all in the standard, I assume that this would actually be allowed. On the other hand, one would actually not know at all whether the result of a template computing function would have formal parameters or not.

If somehow has an opinion on the code below, please let me know. Thanks.

Btw.: this is purely artifical code, just exploring the language.

Best regards

Thomas

| Thomas Deiß |
| Nokia Siemens Networks Deutschland GmbH |
| Meesmannstraße 103 |
| D-44807 Bochum |
| Mobile: +49 1639842217 |
| Direct: +49 2349842217 |
| Fax: +49 2349843491 |
| email: This email address is being protected from spambots. You need JavaScript enabled to view it. |

module Generate {
type integer R;
type record S { R r };

function s_assignment () {
template S l_s (in template R p_r) :={r := p_r};
var template S a;
a := l_s(?); //(1) this should be correct
a := l_s; //(2) is this a correct assignment?
return;
}

function s_parameter () return template S {
template S l_s (in template R p_r) := {r := p_r};
return l_s(?);
}

function s_freeParameter () return template S {
template S l_s (in template R p_r) := {r := p_r};
return l_s; //(3) is this a correct usage of a local template?
}

}
The administrator has disabled public write access.

Assigning parameterized templates 18 Dec 2007 07:51 #7276

Hi,

In each case when it is used parameters of a something shall be resolved. This is true for e.g. function calls as well as using a parameterized template. I think this is not specifically mentioned in the case of parameterized templates, because it is not specific to templates. The same way as

function MyFunc (integer p_i) {...}
function myFunc () {
var integer vl_i := MyFunc; //this is an error, the function shall be called with the actual parameters
//(unless the formal parameter will have a default value in the next edition :),
//but the paranthesis shall be present also in this latter case)
...
}
would be wrong.

But we can also think another way. When using var a from your example after the second assignment (a := l_s;), e.g.
var template S b;
...
b := a;

there is no chance to pass an actual parameter, as "a" is not parameterized. Also, with your example s_freeParameter(), there would be little chance to check compile time if a correct parameter is passed to the return value of s_freeParameter(), if it would be possible (but this is not possible like in case of var "a").

Hence neither a := l_s; nor the return statement in s_freeParameter() are correct as you suggest.

BR, Gyorgy

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: Monday, 17 December, 2007 4:57 PM
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Assigning parameterized templates

Hello together,

Currently I am pondering on template computing functions. When doing so I came across template computing functions that might return parameterized templates. As this case is not mentioned at all in the standard, I assume that this would actually be allowed. On the other hand, one would actually not know at all whether the result of a template computing function would have formal parameters or not.

If somehow has an opinion on the code below, please let me know. Thanks.

Btw.: this is purely artifical code, just exploring the language.

Best regards

Thomas

| Thomas Deiß |
| Nokia Siemens Networks Deutschland GmbH |
| Meesmannstraße 103 |
| D-44807 Bochum |
| Mobile: +49 1639842217 |
| Direct: +49 2349842217 |
| Fax: +49 2349843491 |
| email: This email address is being protected from spambots. You need JavaScript enabled to view it. |

module Generate {
type integer R;
type record S { R r };

function s_assignment () {
template S l_s (in template R p_r) :={r := p_r};
var template S a;
a := l_s(?); //(1) this should be correct
a := l_s; //(2) is this a correct assignment?
return;
}

function s_parameter () return template S {
template S l_s (in template R p_r) := {r := p_r};
return l_s(?);
}

function s_freeParameter () return template S {
template S l_s (in template R p_r) := {r := p_r};
return l_s; //(3) is this a correct usage of a local template?
}

}
The administrator has disabled public write access.

Assigning parameterized templates 18 Dec 2007 08:06 #7277

Hello Gyorgy,

Thanks for the explanation. What you described is fine for me. Even the implication that a template computing function cannot return a parameterized template is fine for me.

Best regards

Thomas

>
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 György Réthy
>Sent: Tuesday, 18. December 2007 08:52
>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
>Subject: Re: Assigning parameterized templates
>Importance: High
>
>Hi,
>
>In each case when it is used parameters of a something shall
>be resolved. This is true for e.g. function calls as well as
>using a parameterized template. I think this is not
>specifically mentioned in the case of parameterized templates,
>because it is not specific to templates. The same way as
>
>function MyFunc (integer p_i) {...}
>function myFunc () {
>var integer vl_i := MyFunc; //this is an error, the function
>shall be called with the actual parameters
> //(unless the formal parameter
>will have a default value in the next edition :),
> //but the paranthesis shall be
>present also in this latter case) ...
>}
>would be wrong.
>
>But we can also think another way. When using var a from your
>example after the second assignment (a := l_s;), e.g.
>var template S b;
>...
>b := a;
>
>there is no chance to pass an actual parameter, as "a" is not
>parameterized. Also, with your example s_freeParameter(),
>there would be little chance to check compile time if a
>correct parameter is passed to the return value of
>s_freeParameter(), if it would be possible (but this is not
>possible like in case of var "a").
>
>Hence neither a := l_s; nor the return statement in
>s_freeParameter() are correct as you suggest.
>
>BR, Gyorgy
>
>
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: Monday, 17 December, 2007 4:57 PM
>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
>Subject: Assigning parameterized templates
>
>Hello together,
>
>Currently I am pondering on template computing functions. When
>doing so I came across template computing functions that might
>return parameterized templates. As this case is not mentioned
>at all in the standard, I assume that this would actually be
>allowed. On the other hand, one would actually not know at all
>whether the result of a template computing function would have
>formal parameters or not.
>
>If somehow has an opinion on the code below, please let me
>know. Thanks.
>
>Btw.: this is purely artifical code, just exploring the language.
>
>Best regards
>
>Thomas
>
>
>| Thomas Deiß |
>| Nokia Siemens Networks Deutschland GmbH |
>| Meesmannstraße 103 |
>| D-44807 Bochum |
>| Mobile: +49 1639842217 |
>| Direct: +49 2349842217 |
>| Fax: +49 2349843491 |
>| email: This email address is being protected from spambots. You need JavaScript enabled to view it. |
>
>
>module Generate {
> type integer R;
> type record S { R r };
>
> function s_assignment () {
> template S l_s (in template R p_r) :={r := p_r};
> var template S a;
> a := l_s(?); //(1) this should be correct
> a := l_s; //(2) is this a correct assignment?
> return;
> }
>
> function s_parameter () return template S {
> template S l_s (in template R p_r) := {r := p_r};
> return l_s(?);
> }
>
> function s_freeParameter () return template S {
> template S l_s (in template R p_r) := {r := p_r};
> return l_s; //(3) is this a correct usage of a
>local template?
> }
>
>}
>
The administrator has disabled public write access.

Assigning parameterized templates 18 Dec 2007 10:14 #7278

Hi,

In addition to the discussion:

If we think of template effective values as an extension of a set of allowed non-template values, then having parameterization as a part of template effective values does not fit into this picture.

You probably somehow mix template effective values that do not have formal parameters and template definitions that may have it. I think evaluator or executor cannot deal with effective template values with formal parameters attached in a sensible way.

Alexey

Thomas Deiss <This email address is being protected from spambots. You need JavaScript enabled to view it.> wrote: Hello together,

Currently I am pondering on template computing functions. When doing so I came across template computing functions that might return parameterized templates. As this case is not mentioned at all in the standard, I assume that this would actually be allowed. On the other hand, one would actually not know at all whether the result of a template computing function would have formal parameters or not.

If somehow has an opinion on the code below, please let me know. Thanks.

Btw.: this is purely artifical code, just exploring the language.

Best regards

Thomas

| Thomas Deiß |
| Nokia Siemens Networks Deutschland GmbH |
| Meesmannstraße 103 |
| D-44807 Bochum |
| Mobile: +49 1639842217 |
| Direct: +49 2349842217 |
| Fax: +49 2349843491 |
| email: This email address is being protected from spambots. You need JavaScript enabled to view it. |

module Generate {
type integer R;
type record S { R r };

function s_assignment () {
template S l_s (in template R p_r) :={r := p_r};
var template S a;
a := l_s(?); //(1) this should be correct
a := l_s; //(2) is this a correct assignment?
return;
}

function s_parameter () return template S {
template S l_s (in template R p_r) := {r := p_r};
return l_s(?);
}

function s_freeParameter () return template S {
template S l_s (in template R p_r) := {r := p_r};
return l_s; //(3) is this a correct usage of a local template?
}

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

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin