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

TOPIC:

question about the parameter of function 03 Dec 2002 15:56 #6291

Dear Jacon,

as I could not find something contradictory in the TTCN-3 and common
sense is also not opposed, I would say yes.

What you have is a "call by value" semantics. So the formal parameter a
will be bound (initially) to whatever actual parameter is provided.

Afterwards there shouldn't be any reason why you should not treat the
formal parameter as any other variable within this scope. Of course the
new value will not be passed back.

Best regards,

Theo

Best regards,

Theo

jacon_wang schrieb:
> hi.
> In the following example,can I modify the (in) formal parameter?
>
> Thanks in advance.
>
> function MyFunc(in integer a)
> {
> a := 10;//here,Can I modify the (in) formal parameter "a"?
> }
>
>                  2002-12-03
> --
> Engineering is the art of making what you want from
> things you can get.
> ★★★★★★★★★★★★★★★★★★★★★★★★★★★★
> ★Department of Automation ★
> ★The University of Science and Technology of China ★
> ★RoomX11-215,Jinzai Road,Hefei,Anhui,China ★
> ★
★
> ★Tel: +865513630653(H),+865513606534-3016(O) ★
> ★Email: This email address is being protected from spambots. You need JavaScript enabled to view it. ★
> ★★★★★★★★★★★★★★★★★★★★★★★★★★★★


--
Theofanis Vassiliou-Gioles Testing Technologies IST
Oranienburger Str. 65 The TTCN-3 Company
10117 Berlin, Germany phone +49 30 726 19 19 0
This email address is being protected from spambots. You need JavaScript enabled to view it. DDI +49 30 726 19 19 12
www.testingtech.de fax +49 30 726 19 19 20

Please Log in to join the conversation.

question about the parameter of function 03 Dec 2002 16:33 #6292

Hi,

Yes. As Theo pointed out, an 'in' formal parameter in TTCN-3 is follows the
'pass by value' parameter passing mechanism. This mechanism has the
following features:

-the actual parameter value is used to initialize the formal parameter (a in your case).

-The formal parameter (a) is usually a local copy whose scope is limited to the
function definition. (the formal parameter is only visible in the function (MyFunc ).

-Any attempt to reference the formal parameter 'a' outside of the function body
should result in a compilation error. This assumes that a is not defined in an
outer scope. (see scope rules for TTCN-3).

-Modifications to this formal parameter are allowed.

-When the function exits 'a' no longer exists (with respect to the function).

-If the actual parameter is a variable and its original value before the call to MyFunc()
was 666, then its value after returning from MyFunc will still be 666. Irrespective
of what other operations you may have made inside the function (usually the
formal parameter is a local copy and is removed (its activation record no longer exists).

-pass by value (depending on implementation) requires local storage to be allocated.

Note that in TTCN-3 an actual parameter value may be a literal value, a constant or even a variable.
However, in the case of TTCN-3 inout parameters, literals are not permitted as acutal parameters.
See section 5.2.1 of ES201 873-1 V2.2.1 (The TTCN-3 core notation specification)

Hope this helps,

Cheers,

Claude.

Claude Desroches
Technical Architect
Strategic Test Solutions
City Gate East
Toll House Hill
Nottingham
NG1 5FS
United Kingdom

Phone +44 (0) 115 9586600
Mobile +44 (0) 796 6482165
Fax +44 (0) 115 9586633

Email This email address is being protected from spambots. You need JavaScript enabled to view it.
Web www.strategictest.co.uk

TTCN - Imagination Technologies






>
Original Message
> From: jacon_wang [This email address is being protected from spambots. You need JavaScript enabled to view it.]
> Sent: 03 December 2002 14:11
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: question about the parameter of function
>
>
> hi.
> In the following example,can I modify the (in) formal parameter?
>
> Thanks in advance.
>
> function MyFunc(in integer a)
> {
> a := 10;//here,Can I modify the (in) formal parameter "a"?
> }
>
>                  2002-12-03
> --
> Engineering is the art of making what you want from
> things you can get.
> ★★★★★★★★★★★★★★★★★★★★★★★★★★★★
> ★Department of Automation ★
> ★The University of Science and Technology of China ★
> ★RoomX11-215,Jinzai Road,Hefei,Anhui,China ★
> ★
> ★
> ★Tel: +865513630653(H),+865513606534-3016(O) ★
> ★Email: This email address is being protected from spambots. You need JavaScript enabled to view it. ★
> ★★★★★★★★★★★★★★★★★★★★★★★★★★★★
>

Please Log in to join the conversation.

  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin