Hello Michael,
Michael Sperber wrote:
> I have a few questions regarding goto:
>
> The standard says:
>
> "It is not allowed to jump into a sequence of statements defined in a
> compound statement (i.e. alt statement, while loop, for loop, if-else
> statement, do- while loop and the interleave statement)."
>
> Is it allowed to jump between the alternatives of an alt statement?
>
I think that would be a special case of the mentioned jump into an alt
statement.
So, no, I don't think so (and I don't think it makes much sense, either).
As far as I can remember, the goto was introduced into the language
after labeled break and continue statements (as in Java) were proposed
to be added to the standard, to allow breaking/continuing of nested
loops in a more straightforward way.
Its intention was never to allow to break the proper flow semantics of
structured programming.
> Consider the situation where a forward goto goes over a declaration,
> i.e. like this:
>
> control {
> goto forward;
>
> var integer i := 5;
>
> forward:
>
> ... i ...
> }
>
>
As far as I know, all variable declarations have to come at the
beginning of a block before any control statements (like goto).
Thus, you would need to modify your example to something like to be
allowed TTCN-3:
goto forward;
...
{
var integer i := 5;
...
label forward;
... i ...
}
However, since the variable declaration with initialization is simply
syntactic sugar for a declaration (which is not a statement in itself,
but only meta information about this scope for the compiler to be able
to check type-correctness) without initialization and an additional
assignment, I think the result of jumping over the assignment would be
that the variable still is declared, but (if it is not assigned after
the jump label) not initialized, leading to a runtime error, if it is
used as Rvalue.
> Does the standard say anything about i in this case, i.e. if the use of
> i is a violation, or if it's OK to use it, but its value is unspecified,
> or undefined?
>
I'm sure it does, somewhere.
> Help would be much appreciated!
>
>
Best regards,
Jacob Wieland
--
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!
August 13, Free TTCN-3 Webinar, 5:00 pm CET
www.testingtech.com/services/ttcn3_webinar.php
August 28-29, Toolapalooza India
Cisco Systems, Inc, Bangalore, India
www.cisco.com
September 17-18, Ericsson PM&T Conference
Linköping, Sweden, Booth #8
www.ericsson.com
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.