Welcome,
Guest
|
TOPIC:
use of value returning function in template 19 May 2009 08:44 #7590
|
Dear all,
according to TTCN-3 core standard in §16.1.4g) component variables should not be changed in functions that are used in templates. In the following example the component variable is used only. My question: is the following TTCN-3 code allowed by the standard? module test { type component my_component { var integer vc_integer := 0 } template integer m_message := f_deliver(); function f_deliver() runs on my_component return integer { return(vc_integer) } } Thanks in advance. Regards, Axel |
Please Log in to join the conversation. |
use of value returning function in template 19 May 2009 11:36 #7593
|
Hi Axel,
just from the words I would say yes. But I doubt whether you would get what you intend. Because it would take the variable value when the template will be "instantiated". In this case when the module is initialized. And in this particular case the value is "undef". In addition I would like to note that for a compiler it might be hard to make a flow-analysis to check whether a function is really reading only variables at runtime. An equivalent statement could be: template integer m_message(integer i) := f_deliver(i); function f_deliver() return integer { return(vc_integer) } with function f() runs on my_component { var integer j := valueof(m_message(vc_integer))=; } I mean, in this context it becomes clear that the value of the component variable is the value *at* *this* *time*. Best regards, Theo Theofanis Vassiliou-Gioles Testing Technologies IST GmbH Michaelkirchstraße 17/18 10179 Berlin, Germany Phone +49 30 726 19 190 Email This email address is being protected from spambots. You need JavaScript enabled to view it. Fax +49 30 726 19 19 20 Internet www.testingtech.com Rennoch, Axel schrieb: > Dear all, > > > > according to TTCN-3 core standard in §16.1.4g) component variables > should not be changed in functions that are used in templates. > > > > In the following example the component variable is used only. My > question: is the following TTCN-3 code allowed by the standard? > > > > *module* test { > > > > *type* *component* my_component { > > *var* *integer* vc_integer := 0 > > } > > > > *template* *integer* m_message := _f_deliver()_; > > > > *function* f_deliver() *runs* *on* my_component *return* *integer* { > > *return*(vc_integer) > > } > > } > > > > Thanks in advance. > > > > Regards, > > Axel > > > |
Please Log in to join the conversation. |
use of value returning function in template 19 May 2009 13:14 #7594
|
Hi all,
I also agree, that Axel's example is allowed by the standard. The result is a more interesting question. I think that templates calling user defined functions shall be "generated" runtime, just like parameterized templates. Hence the actual value of m_message will be the actual value of the component variable when the template is used. 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 > Theofanis Vassiliou-Gioles > Sent: 2009-május-19 13:37 > To: This email address is being protected from spambots. You need JavaScript enabled to view it. > Subject: Re: use of value returning function in template > > Hi Axel, > > just from the words I would say yes. But I doubt whether you > would get what you intend. Because it would take the variable > value when the template will be "instantiated". In this case > when the module is initialized. And in this particular case > the value is "undef". > > In addition I would like to note that for a compiler it might > be hard to make a flow-analysis to check whether a function > is really reading only variables at runtime. > > An equivalent statement could be: > > template integer m_message(integer i) := f_deliver(i); > > function f_deliver() return integer { > return(vc_integer) > } > > with > > function f() runs on my_component { > var integer j := valueof(m_message(vc_integer))=; > } > > I mean, in this context it becomes clear that the value of > the component variable is the value *at* *this* *time*. > > Best regards, Theo > > > > Theofanis Vassiliou-Gioles > > Testing Technologies IST GmbH > Michaelkirchstraße 17/18 > 10179 Berlin, Germany > > Phone +49 30 726 19 190 Email > This email address is being protected from spambots. You need JavaScript enabled to view it. > Fax +49 30 726 19 19 20 Internet www.testingtech.com > > > Rennoch, Axel schrieb: > > Dear all, > > > > > > > > according to TTCN-3 core standard in §16.1.4g) component variables > > should not be changed in functions that are used in templates. > > > > > > > > In the following example the component variable is used only. My > > question: is the following TTCN-3 code allowed by the standard? > > > > > > > > *module* test { > > > > > > > > *type* *component* my_component { > > > > *var* *integer* vc_integer := 0 > > > > } > > > > > > > > *template* *integer* m_message := _f_deliver()_; > > > > > > > > *function* f_deliver() *runs* *on* my_component *return* *integer* { > > > > *return*(vc_integer) > > > > } > > > > } > > > > > > > > Thanks in advance. > > > > > > > > Regards, > > > > Axel > > > > > > > |
Please Log in to join the conversation. |
use of value returning function in template 19 May 2009 13:31 #7595
|
Hi,
Reading back my previous mail, I would like to be more precise. That's how I think the standard text suggests today. I'm not saying that this is the most desirable way, rather think that may be a point for clarification. BR, Gyorgy > Original Message > From: György Réthy > Sent: 2009-május-19 15:15 > To: 'active_ttcn3 : mts stf133 ttcn version 3 - active members only' > Subject: RE: use of value returning function in template > > Hi all, > > I also agree, that Axel's example is allowed by the standard. > The result is a more interesting question. I think that > templates calling user defined functions shall be "generated" > runtime, just like parameterized templates. Hence the actual > value of m_message will be the actual value of the component > variable when the template is used. > > 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 Theofanis Vassiliou-Gioles > > Sent: 2009-május-19 13:37 > > To: This email address is being protected from spambots. You need JavaScript enabled to view it. > > Subject: Re: use of value returning function in template > > > > Hi Axel, > > > > just from the words I would say yes. But I doubt whether > you would get > > what you intend. Because it would take the variable value when the > > template will be "instantiated". In this case when the module is > > initialized. And in this particular case the value is "undef". > > > > In addition I would like to note that for a compiler it > might be hard > > to make a flow-analysis to check whether a function is > really reading > > only variables at runtime. > > > > An equivalent statement could be: > > > > template integer m_message(integer i) := f_deliver(i); > > > > function f_deliver() return integer { > > return(vc_integer) > > } > > > > with > > > > function f() runs on my_component { > > var integer j := valueof(m_message(vc_integer))=; > > } > > > > I mean, in this context it becomes clear that the value of the > > component variable is the value *at* *this* *time*. > > > > Best regards, Theo > > > > > > > > Theofanis Vassiliou-Gioles > > > > Testing Technologies IST GmbH > > Michaelkirchstraße 17/18 > > 10179 Berlin, Germany > > > > Phone +49 30 726 19 190 Email > > This email address is being protected from spambots. You need JavaScript enabled to view it. > > Fax +49 30 726 19 19 20 Internet www.testingtech.com > > > > > > Rennoch, Axel schrieb: > > > Dear all, > > > > > > > > > > > > according to TTCN-3 core standard in §16.1.4g) component > variables > > > should not be changed in functions that are used in templates. > > > > > > > > > > > > In the following example the component variable is used only. My > > > question: is the following TTCN-3 code allowed by the standard? > > > > > > > > > > > > *module* test { > > > > > > > > > > > > *type* *component* my_component { > > > > > > *var* *integer* vc_integer := 0 > > > > > > } > > > > > > > > > > > > *template* *integer* m_message := _f_deliver()_; > > > > > > > > > > > > *function* f_deliver() *runs* *on* my_component *return* > *integer* { > > > > > > *return*(vc_integer) > > > > > > } > > > > > > } > > > > > > > > > > > > Thanks in advance. > > > > > > > > > > > > Regards, > > > > > > Axel > > > > > > > > > > > |
Please Log in to join the conversation. |
use of value returning function in template 19 May 2009 13:58 #7596
|
Hi Gyorgy,
firstly I've been confused because due to previous discussions I was thinking that it is not allowed to use "runs on"-functions from within a template - now I agree but have some additional issues: By using a "runs on"-function a template will implicitly be bound to a component i.e. it connot be used in other components => It is an error to use that template on another component. Furthermore there seems to be no way to enhance the function or template to support several components (e.g. when all components have a similar variable). Is this correct ?? As a consequence: Can we expect tool compatibility accordingly ?? (indirect usage of component variables within templates would solve some of our current problems but I wonder whether I dare to do it that way) Best regards Wolfgang 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 György Réthy Sent: 19 May 2009 15:32 To: TTCN3 Subject: Re: use of value returning function in template Hi, Reading back my previous mail, I would like to be more precise. That's how I think the standard text suggests today. I'm not saying that this is the most desirable way, rather think that may be a point for clarification. BR, Gyorgy > Original Message > From: György Réthy > Sent: 2009-május-19 15:15 > To: 'active_ttcn3 : mts stf133 ttcn version 3 - active members only' > Subject: RE: use of value returning function in template > > Hi all, > > I also agree, that Axel's example is allowed by the standard. > The result is a more interesting question. I think that templates > calling user defined functions shall be "generated" > runtime, just like parameterized templates. Hence the actual value of > m_message will be the actual value of the component variable when the > template is used. > > 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 Theofanis Vassiliou-Gioles > > Sent: 2009-május-19 13:37 > > To: This email address is being protected from spambots. You need JavaScript enabled to view it. > > Subject: Re: use of value returning function in template > > > > Hi Axel, > > > > just from the words I would say yes. But I doubt whether > you would get > > what you intend. Because it would take the variable value when the > > template will be "instantiated". In this case when the module is > > initialized. And in this particular case the value is "undef". > > > > In addition I would like to note that for a compiler it > might be hard > > to make a flow-analysis to check whether a function is > really reading > > only variables at runtime. > > > > An equivalent statement could be: > > > > template integer m_message(integer i) := f_deliver(i); > > > > function f_deliver() return integer { > > return(vc_integer) > > } > > > > with > > > > function f() runs on my_component { > > var integer j := valueof(m_message(vc_integer))=; > > } > > > > I mean, in this context it becomes clear that the value of the > > component variable is the value *at* *this* *time*. > > > > Best regards, Theo > > > > > > > > Theofanis Vassiliou-Gioles > > > > Testing Technologies IST GmbH > > Michaelkirchstraße 17/18 > > 10179 Berlin, Germany > > > > Phone +49 30 726 19 190 Email > > This email address is being protected from spambots. You need JavaScript enabled to view it. > > Fax +49 30 726 19 19 20 Internet www.testingtech.com > > > > > > Rennoch, Axel schrieb: > > > Dear all, > > > > > > > > > > > > according to TTCN-3 core standard in §16.1.4g) component > variables > > > should not be changed in functions that are used in templates. > > > > > > > > > > > > In the following example the component variable is used only. My > > > question: is the following TTCN-3 code allowed by the standard? > > > > > > > > > > > > *module* test { > > > > > > > > > > > > *type* *component* my_component { > > > > > > *var* *integer* vc_integer := 0 > > > > > > } > > > > > > > > > > > > *template* *integer* m_message := _f_deliver()_; > > > > > > > > > > > > *function* f_deliver() *runs* *on* my_component *return* > *integer* { > > > > > > *return*(vc_integer) > > > > > > } > > > > > > } > > > > > > > > > > > > Thanks in advance. > > > > > > > > > > > > Regards, > > > > > > Axel > > > > > > > > > > > |
Please Log in to join the conversation. |
use of value returning function in template 19 May 2009 14:00 #7597
|
Hi Axel,
hi György, well, we have forgotten one aspect in this discussion. (I must admit me too. But some colleagues pointed this out). A topic not discussed so far is, where is the template used. So far templates (parameterized or unparameterized) templates can be used in all type of behavior or the control part. Now, if it would be allowed to use a "behaviour" function in a template, then depending on where you are using the template either it would be possible or not. This sounds very strange to me. Here an example with Axel example extended: if we use the m_message in the control part, like control { log(valueof(m_message)); } this would lead to a run-time error because there is no component. The standard forbids this example anyhow as it states for example: 16.1.1. d) When invoking a function, the compatibility to the test component type of the invoking test component as described in clause 6.3.3 need to be fulfilled. or 16.1. c) Functions used in the control part of a TTCN-3 module shall have no runs on clause. Furthermore does 16.1.1. d) mandates that you have to check the type compatibility. Besides the "strange" control part behavior we would get the same problem, if the *template* is used from within a component of incompatible type. The *usage* of a template is suddenly restricted to the context. I do not think that this a desirable state. A seamless solution to this "template restriction side effect" would be to restrict the usage of functions to computational functions (i.e. functions without a runs on clause) only. I believe this would be a much cleaner definition than assuming (or mandating) that template have to be implemented different whether they are using a function with a runs-on clause or not. Are there any arguments against this view? If not I would raise a CR in order to clarify the situation in the standard. For the time being you would be on the safe side if the value of the functions (that have the runs-on clause) are passed as template parameters. By just using such an explicit notation (without changing the semantics of the template) it would become much clearer. For example with the control part example you would immediately identify that you have to "invent" a value for this field, as there is no component variable available. Best regards, Theo György Réthy schrieb: > Hi all, > > I also agree, that Axel's example is allowed by the standard. The > result is a more interesting question. I think that templates calling > user defined functions shall be "generated" runtime, just like > parameterized templates. Hence the actual value of m_message will be > the actual value of the component variable when the template is used. > > > 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 Theofanis Vassiliou-Gioles Sent: 2009-május-19 13:37 To: >> This email address is being protected from spambots. You need JavaScript enabled to view it. Subject: Re: use of value returning function in >> template >> >> Hi Axel, >> >> just from the words I would say yes. But I doubt whether you would >> get what you intend. Because it would take the variable value when >> the template will be "instantiated". In this case when the module >> is initialized. And in this particular case the value is "undef". >> >> In addition I would like to note that for a compiler it might be >> hard to make a flow-analysis to check whether a function is really >> reading only variables at runtime. >> >> An equivalent statement could be: >> >> template integer m_message(integer i) := f_deliver(i); >> >> function f_deliver() return integer { return(vc_integer) } >> >> with >> >> function f() runs on my_component { var integer j := >> valueof(m_message(vc_integer))=; } >> >> I mean, in this context it becomes clear that the value of the >> component variable is the value *at* *this* *time*. >> >> Best regards, Theo >> >> >> Theofanis Vassiliou-Gioles >> >> Testing Technologies IST GmbH Michaelkirchstraße 17/18 10179 >> Berlin, Germany >> >> Phone +49 30 726 19 190 Email >> This email address is being protected from spambots. You need JavaScript enabled to view it. Fax +49 30 726 19 19 20 >> Internet www.testingtech.com >> >> >> Rennoch, Axel schrieb: >>> Dear all, >>> >>> >>> >>> according to TTCN-3 core standard in §16.1.4g) component >>> variables should not be changed in functions that are used in >>> templates. >>> >>> >>> >>> In the following example the component variable is used only. My >>> question: is the following TTCN-3 code allowed by the standard? >>> >>> >>> >>> *module* test { >>> >>> >>> >>> *type* *component* my_component { >>> >>> *var* *integer* vc_integer := 0 >>> >>> } >>> >>> >>> >>> *template* *integer* m_message := _f_deliver()_; >>> >>> >>> >>> *function* f_deliver() *runs* *on* my_component *return* >>> *integer* { >>> >>> *return*(vc_integer) >>> >>> } >>> >>> } >>> >>> >>> >>> Thanks in advance. >>> >>> >>> >>> Regards, >>> >>> Axel >>> >>> >>> |
Please Log in to join the conversation. |
use of value returning function in template 19 May 2009 14:23 #7598
|
Hi all,
I personally think that using functions with runs on clauses in templates makes no sense at all and I even think this was not meant at all. Any runtime value/template shall be simply passed in as parameter. But as I wrote in my 2nd mail, I did not find a specific restriction disallowing this - but I have to admin I have only scanned the few related parts of the text of the standard quickly. So, when I wrote the "point for clarification", I also meant to search the text more carefully, as I might have overlooked something, but if I did not, we should also consider all the consequences and alternative solutions provided by TTCN-3 for the different cases. So, I would rather propose to take Theo's point as the basis and avoid using similar constructs - that will work with all tools :))) 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 Wolfgang Seka > Sent: 2009-május-19 15:58 > To: This email address is being protected from spambots. You need JavaScript enabled to view it. > Subject: Re: use of value returning function in template > > Hi Gyorgy, > > firstly I've been confused because due to previous > discussions I was thinking that it is not allowed to use > "runs on"-functions from within a template - now I agree but > have some additional issues: > By using a "runs on"-function a template will implicitly be > bound to a component i.e. it connot be used in other > components => It is an error to use that template on another > component. > Furthermore there seems to be no way to enhance the function > or template to support several components (e.g. when all > components have a similar variable). > Is this correct ?? > > As a consequence: Can we expect tool compatibility accordingly ?? > > (indirect usage of component variables within templates would > solve some of our current problems but I wonder whether I > dare to do it that way) > > Best regards > Wolfgang > > > 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 György Réthy > Sent: 19 May 2009 15:32 > To: TTCN3 > Subject: Re: use of value returning function in template > > Hi, > > Reading back my previous mail, I would like to be more > precise. That's how I think the standard text suggests today. > I'm not saying that this is the most desirable way, rather > think that may be a point for clarification. > > BR, Gyorgy > > > Original Message > > From: György Réthy > > Sent: 2009-május-19 15:15 > > To: 'active_ttcn3 : mts stf133 ttcn version 3 - active members only' > > Subject: RE: use of value returning function in template > > > > Hi all, > > > > I also agree, that Axel's example is allowed by the standard. > > The result is a more interesting question. I think that templates > > calling user defined functions shall be "generated" > > runtime, just like parameterized templates. Hence the > actual value of > > m_message will be the actual value of the component > variable when the > > template is used. > > > > 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 Theofanis > Vassiliou-Gioles > > > Sent: 2009-május-19 13:37 > > > To: This email address is being protected from spambots. You need JavaScript enabled to view it. > > > Subject: Re: use of value returning function in template > > > > > > Hi Axel, > > > > > > just from the words I would say yes. But I doubt whether > > you would get > > > what you intend. Because it would take the variable value > when the > > > template will be "instantiated". In this case when the module is > > > initialized. And in this particular case the value is "undef". > > > > > > In addition I would like to note that for a compiler it > > might be hard > > > to make a flow-analysis to check whether a function is > > really reading > > > only variables at runtime. > > > > > > An equivalent statement could be: > > > > > > template integer m_message(integer i) := f_deliver(i); > > > > > > function f_deliver() return integer { > > > return(vc_integer) > > > } > > > > > > with > > > > > > function f() runs on my_component { > > > var integer j := valueof(m_message(vc_integer))=; > > > } > > > > > > I mean, in this context it becomes clear that the value of the > > > component variable is the value *at* *this* *time*. > > > > > > Best regards, Theo > > > > > > > > > > > > Theofanis Vassiliou-Gioles > > > > > > Testing Technologies IST GmbH > > > Michaelkirchstraße 17/18 > > > 10179 Berlin, Germany > > > > > > Phone +49 30 726 19 190 Email > > > This email address is being protected from spambots. You need JavaScript enabled to view it. > > > Fax +49 30 726 19 19 20 Internet www.testingtech.com > > > > > > > > > Rennoch, Axel schrieb: > > > > Dear all, > > > > > > > > > > > > > > > > according to TTCN-3 core standard in §16.1.4g) component > > variables > > > > should not be changed in functions that are used in templates. > > > > > > > > > > > > > > > > In the following example the component variable is used only. My > > > > question: is the following TTCN-3 code allowed by the standard? > > > > > > > > > > > > > > > > *module* test { > > > > > > > > > > > > > > > > *type* *component* my_component { > > > > > > > > *var* *integer* vc_integer := 0 > > > > > > > > } > > > > > > > > > > > > > > > > *template* *integer* m_message := _f_deliver()_; > > > > > > > > > > > > > > > > *function* f_deliver() *runs* *on* my_component *return* > > *integer* { > > > > > > > > *return*(vc_integer) > > > > > > > > } > > > > > > > > } > > > > > > > > > > > > > > > > Thanks in advance. > > > > > > > > > > > > > > > > Regards, > > > > > > > > Axel > > > > > > > > > > > > > > > > |
Please Log in to join the conversation. |
use of value returning function in template 19 May 2009 14:42 #7599
|
Hello,
I also agree, but I want to stress the point that this clarifying restriction should only be applied to global templates, not to templates that are locally defined in a behavior definition. A template which is defined in a behavior definition should very well be able to refer to variables of the component that behavior runs on, i.e. it should also be able to use functions that have a compatible runs on clause. For example: type component C { var integer i := 5; } function x(integer y) runs on C return integer { return i * y } fucntion f() runs on C { template integer t := x(3); // should be allowed } Best regards, Jacob Wieland György Réthy wrote: > Hi all, > > I personally think that using functions with runs on clauses in templates makes no sense at all and I even think this was not meant at all. Any runtime value/template shall be simply passed in as parameter. But as I wrote in my 2nd mail, I did not find a specific restriction disallowing this - but I have to admin I have only scanned the few related parts of the text of the standard quickly. So, when I wrote the "point for clarification", I also meant to search the text more carefully, as I might have overlooked something, but if I did not, we should also consider all the consequences and alternative solutions provided by TTCN-3 for the different cases. > > So, I would rather propose to take Theo's point as the basis and avoid using similar constructs - that will work with all tools :))) > > 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 Wolfgang Seka >> Sent: 2009-május-19 15:58 >> To: This email address is being protected from spambots. You need JavaScript enabled to view it. >> Subject: Re: use of value returning function in template >> >> Hi Gyorgy, >> >> firstly I've been confused because due to previous >> discussions I was thinking that it is not allowed to use >> "runs on"-functions from within a template - now I agree but >> have some additional issues: >> By using a "runs on"-function a template will implicitly be >> bound to a component i.e. it connot be used in other >> components => It is an error to use that template on another >> component. >> Furthermore there seems to be no way to enhance the function >> or template to support several components (e.g. when all >> components have a similar variable). >> Is this correct ?? >> >> As a consequence: Can we expect tool compatibility accordingly ?? >> >> (indirect usage of component variables within templates would >> solve some of our current problems but I wonder whether I >> dare to do it that way) >> >> Best regards >> Wolfgang >> >> >> 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 György Réthy >> Sent: 19 May 2009 15:32 >> To: TTCN3 >> Subject: Re: use of value returning function in template >> >> Hi, >> >> Reading back my previous mail, I would like to be more >> precise. That's how I think the standard text suggests today. >> I'm not saying that this is the most desirable way, rather >> think that may be a point for clarification. >> >> BR, Gyorgy >> >> >>> Original Message >>> From: György Réthy >>> Sent: 2009-május-19 15:15 >>> To: 'active_ttcn3 : mts stf133 ttcn version 3 - active members only' >>> Subject: RE: use of value returning function in template >>> >>> Hi all, >>> >>> I also agree, that Axel's example is allowed by the standard. >>> The result is a more interesting question. I think that templates >>> calling user defined functions shall be "generated" >>> runtime, just like parameterized templates. Hence the >>> >> actual value of >> >>> m_message will be the actual value of the component >>> >> variable when the >> >>> template is used. >>> >>> 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 Theofanis >>>> >> Vassiliou-Gioles >> >>>> Sent: 2009-május-19 13:37 >>>> To: This email address is being protected from spambots. You need JavaScript enabled to view it. >>>> Subject: Re: use of value returning function in template >>>> >>>> Hi Axel, >>>> >>>> just from the words I would say yes. But I doubt whether >>>> >>> you would get >>> >>>> what you intend. Because it would take the variable value >>>> >> when the >> >>>> template will be "instantiated". In this case when the module is >>>> initialized. And in this particular case the value is "undef". >>>> >>>> In addition I would like to note that for a compiler it >>>> >>> might be hard >>> >>>> to make a flow-analysis to check whether a function is >>>> >>> really reading >>> >>>> only variables at runtime. >>>> >>>> An equivalent statement could be: >>>> >>>> template integer m_message(integer i) := f_deliver(i); >>>> >>>> function f_deliver() return integer { >>>> return(vc_integer) >>>> } >>>> >>>> with >>>> >>>> function f() runs on my_component { >>>> var integer j := valueof(m_message(vc_integer))=; >>>> } >>>> >>>> I mean, in this context it becomes clear that the value of the >>>> component variable is the value *at* *this* *time*. >>>> >>>> Best regards, Theo >>>> >>>> >>>> >>>> Theofanis Vassiliou-Gioles >>>> >>>> Testing Technologies IST GmbH >>>> Michaelkirchstraße 17/18 >>>> 10179 Berlin, Germany >>>> >>>> Phone +49 30 726 19 190 Email >>>> This email address is being protected from spambots. You need JavaScript enabled to view it. >>>> Fax +49 30 726 19 19 20 Internet www.testingtech.com >>>> >>>> >>>> Rennoch, Axel schrieb: >>>> >>>>> Dear all, >>>>> >>>>> >>>>> >>>>> according to TTCN-3 core standard in §16.1.4g) component >>>>> >>> variables >>> >>>>> should not be changed in functions that are used in templates. >>>>> >>>>> >>>>> >>>>> In the following example the component variable is used only. My >>>>> question: is the following TTCN-3 code allowed by the standard? >>>>> >>>>> >>>>> >>>>> *module* test { >>>>> >>>>> >>>>> >>>>> *type* *component* my_component { >>>>> >>>>> *var* *integer* vc_integer := 0 >>>>> >>>>> } >>>>> >>>>> >>>>> >>>>> *template* *integer* m_message := _f_deliver()_; >>>>> >>>>> >>>>> >>>>> *function* f_deliver() *runs* *on* my_component *return* >>>>> >>> *integer* { >>> >>>>> *return*(vc_integer) >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> >>>>> >>>>> Thanks in advance. >>>>> >>>>> >>>>> >>>>> Regards, >>>>> >>>>> Axel >>>>> >>>>> >>>>> >>>>> -- Jacob Wieland Software Engineer Testing Technologies IST GmbH Michaelkirchstraße 17/18 10179 Berlin, Germany Phone +49 30 726 19 19 34 Email This email address is being protected from spambots. You need JavaScript enabled to view it. Fax +49 30 726 19 19 20 Internet www.testingtech.com UPCOMING EVENTS May 26-29, Software & Systems Quality Conferences Germany, Düsseldorf www.sqs-conferences.com/de/index.htm June 2, Free TTCN-3 Webinar TTCN-3 for Test Automation www.testingtech.com/services/ttcn3_webinar.php June 2-4, Accredited TTCN-3 Training Course "Theory and Practice of TTCN-3" at the T3UC (ETSI) www.testingtech.com/services/ttcn3_training.php www.ttcn3.org/TTCN3UC2009/sponsors.htm Geschäftsführung: Theofanis Vassiliou-Gioles, Stephan Pietsch Handelsregister HRB 77805, Amtsgericht Charlottenburg Ust ID Nr.: DE 813 143 070 This e-mail may contain confidential and privileged material for the sole use of the intended recipient. Any review, use, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply e-mail and delete all copies of this message. |
Please Log in to join the conversation. |
use of value returning function in template 19 May 2009 15:02 #7600
|
Hi,
Yes, basically I also meant global templates in my mail. In case of local templates, I think that template variables practically provide the same functionality (OK, parameterized ones, if used often and a few fields have different content in subsequent uses - but this may raise the question if the structure of the code is correct). To have different semantic rules for basically-the-same language constructs always cause problems to common users. 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 Jacob Wieland > Sent: 2009-május-19 16:43 > To: This email address is being protected from spambots. You need JavaScript enabled to view it. > Subject: Re: use of value returning function in template > > Hello, > > I also agree, but I want to stress the point that this > clarifying restriction should only be applied to global > templates, not to templates that are locally defined in a > behavior definition. > A template which is defined in a behavior definition should > very well be able to refer to variables of the component that > behavior runs on, i.e. > it should also be able to use > functions that have a compatible runs on clause. > > For example: > > type component C { > var integer i := 5; > } > > function x(integer y) runs on C return integer { return i * y } > > fucntion f() runs on C { > template integer t := x(3); // should be allowed } > > Best regards, > > Jacob Wieland > > György Réthy wrote: > > Hi all, > > > > I personally think that using functions with runs on > clauses in templates makes no sense at all and I even think > this was not meant at all. Any runtime value/template shall > be simply passed in as parameter. But as I wrote in my 2nd > mail, I did not find a specific restriction disallowing this > - but I have to admin I have only scanned the few related > parts of the text of the standard quickly. So, when I wrote > the "point for clarification", I also meant to search the > text more carefully, as I might have overlooked something, > but if I did not, we should also consider all the > consequences and alternative solutions provided by TTCN-3 for > the different cases. > > > > So, I would rather propose to take Theo's point as the > basis and avoid > > using similar constructs - that will work with all tools :))) > > > > 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 Wolfgang Seka > >> Sent: 2009-május-19 15:58 > >> To: This email address is being protected from spambots. You need JavaScript enabled to view it. > >> Subject: Re: use of value returning function in template > >> > >> Hi Gyorgy, > >> > >> firstly I've been confused because due to previous > discussions I was > >> thinking that it is not allowed to use "runs on"-functions from > >> within a template - now I agree but have some additional issues: > >> By using a "runs on"-function a template will implicitly > be bound to > >> a component i.e. it connot be used in other components => It is an > >> error to use that template on another component. > >> Furthermore there seems to be no way to enhance the function or > >> template to support several components (e.g. when all > components have > >> a similar variable). > >> Is this correct ?? > >> > >> As a consequence: Can we expect tool compatibility accordingly ?? > >> > >> (indirect usage of component variables within templates > would solve > >> some of our current problems but I wonder whether I dare to do it > >> that way) > >> > >> Best regards > >> Wolfgang > >> > >> > >> 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 György Réthy > >> Sent: 19 May 2009 15:32 > >> To: TTCN3 > >> Subject: Re: use of value returning function in template > >> > >> Hi, > >> > >> Reading back my previous mail, I would like to be more precise. > >> That's how I think the standard text suggests today. > >> I'm not saying that this is the most desirable way, rather > think that > >> may be a point for clarification. > >> > >> BR, Gyorgy > >> > >> > >>> Original Message > >>> From: György Réthy > >>> Sent: 2009-május-19 15:15 > >>> To: 'active_ttcn3 : mts stf133 ttcn version 3 - active > members only' > >>> Subject: RE: use of value returning function in template > >>> > >>> Hi all, > >>> > >>> I also agree, that Axel's example is allowed by the standard. > >>> The result is a more interesting question. I think that templates > >>> calling user defined functions shall be "generated" > >>> runtime, just like parameterized templates. Hence the > >>> > >> actual value of > >> > >>> m_message will be the actual value of the component > >>> > >> variable when the > >> > >>> template is used. > >>> > >>> 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 Theofanis > >>>> > >> Vassiliou-Gioles > >> > >>>> Sent: 2009-május-19 13:37 > >>>> To: This email address is being protected from spambots. You need JavaScript enabled to view it. > >>>> Subject: Re: use of value returning function in template > >>>> > >>>> Hi Axel, > >>>> > >>>> just from the words I would say yes. But I doubt whether > >>>> > >>> you would get > >>> > >>>> what you intend. Because it would take the variable value > >>>> > >> when the > >> > >>>> template will be "instantiated". In this case when the module is > >>>> initialized. And in this particular case the value is "undef". > >>>> > >>>> In addition I would like to note that for a compiler it > >>>> > >>> might be hard > >>> > >>>> to make a flow-analysis to check whether a function is > >>>> > >>> really reading > >>> > >>>> only variables at runtime. > >>>> > >>>> An equivalent statement could be: > >>>> > >>>> template integer m_message(integer i) := f_deliver(i); > >>>> > >>>> function f_deliver() return integer { > >>>> return(vc_integer) > >>>> } > >>>> > >>>> with > >>>> > >>>> function f() runs on my_component { > >>>> var integer j := valueof(m_message(vc_integer))=; > >>>> } > >>>> > >>>> I mean, in this context it becomes clear that the value of the > >>>> component variable is the value *at* *this* *time*. > >>>> > >>>> Best regards, Theo > >>>> > >>>> > >>>> > >>>> Theofanis Vassiliou-Gioles > >>>> > >>>> Testing Technologies IST GmbH > >>>> Michaelkirchstraße 17/18 > >>>> 10179 Berlin, Germany > >>>> > >>>> Phone +49 30 726 19 190 Email > >>>> This email address is being protected from spambots. You need JavaScript enabled to view it. > >>>> Fax +49 30 726 19 19 20 Internet www.testingtech.com > >>>> > >>>> > >>>> Rennoch, Axel schrieb: > >>>> > >>>>> Dear all, > >>>>> > >>>>> > >>>>> > >>>>> according to TTCN-3 core standard in §16.1.4g) component > >>>>> > >>> variables > >>> > >>>>> should not be changed in functions that are used in templates. > >>>>> > >>>>> > >>>>> > >>>>> In the following example the component variable is used only. My > >>>>> question: is the following TTCN-3 code allowed by the standard? > >>>>> > >>>>> > >>>>> > >>>>> *module* test { > >>>>> > >>>>> > >>>>> > >>>>> *type* *component* my_component { > >>>>> > >>>>> *var* *integer* vc_integer := 0 > >>>>> > >>>>> } > >>>>> > >>>>> > >>>>> > >>>>> *template* *integer* m_message := _f_deliver()_; > >>>>> > >>>>> > >>>>> > >>>>> *function* f_deliver() *runs* *on* my_component *return* > >>>>> > >>> *integer* { > >>> > >>>>> *return*(vc_integer) > >>>>> > >>>>> } > >>>>> > >>>>> } > >>>>> > >>>>> > >>>>> > >>>>> Thanks in advance. > >>>>> > >>>>> > >>>>> > >>>>> Regards, > >>>>> > >>>>> Axel > >>>>> > >>>>> > >>>>> > >>>>> > > > -- > > > Jacob Wieland > Software Engineer > > Testing Technologies IST GmbH > Michaelkirchstraße 17/18 > 10179 Berlin, Germany > > Phone +49 30 726 19 19 34 Email This email address is being protected from spambots. You need JavaScript enabled to view it. > Fax +49 30 726 19 19 20 Internet www.testingtech.com > > > > UPCOMING EVENTS > > May 26-29, Software & Systems Quality Conferences Germany, > Düsseldorf www.sqs-conferences.com/de/index.htm > > June 2, Free TTCN-3 Webinar > TTCN-3 for Test Automation > www.testingtech.com/services/ttcn3_webinar.php > > June 2-4, Accredited TTCN-3 Training Course "Theory and > Practice of TTCN-3" at the T3UC (ETSI) > www.testingtech.com/services/ttcn3_training.php > www.ttcn3.org/TTCN3UC2009/sponsors.htm > > > > Geschäftsführung: Theofanis Vassiliou-Gioles, Stephan Pietsch > Handelsregister HRB 77805, Amtsgericht Charlottenburg Ust ID > Nr.: DE 813 143 070 > > This e-mail may contain confidential and privileged material > for the sole use of the intended recipient. Any review, use, > distribution or disclosure by others is strictly prohibited. > If you are not the intended recipient (or authorized to > receive for the recipient), please contact the sender by > reply e-mail and delete all copies of this message. > |
Please Log in to join the conversation. |