Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^6: I'm trying to consolidate my functions into subroutines

by Anonymous Monk
on May 18, 2017 at 18:04 UTC ( #1190547=note: print w/replies, xml ) Need Help??


in reply to Re^5: I'm trying to consolidate my functions into subroutines
in thread I'm trying to consolidate my functions into subroutines

It is even possible to call procedures as function. Of course, this results in undefined behavior,

C99 says,

If the } that terminates a function is reached, and the value of the function call is used by the caller, the behavior is undefined.
(There is, however, an exception for the main() function that has an implicit "return 0" before closing brace.)

Further, the C standard does not define or use such terminology "procedure" or "subroutine". These words no not even appear in remarks or informal parts. I think this is a very deliberate choice.

The logic or rationale behind those dangerous jump statements (goto/return/break/continue) is that the compiler is unable to follow the program flow or value propagation in the absolute sense. Gcc may warn that a variable may be used uninitialized, while the programmer can easily see this can not happen. The compiler may not even know if the return value was properly computed or if undefined behavior was somehow involved. Thus C does not prohibit questionable constructs such as goto into a scope of a variable (past its initialization).

But note, even when "may be uninitialized" warning is a false positive, it has informational value for the programmer. It may signal a refactoring opportunity, such that would allow the compiler better insight into your program and possibly better code as a result.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1190547]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2017-07-20 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (304 votes). Check out past polls.