Showing posts with label Functions. Show all posts
Showing posts with label Functions. Show all posts

Tuesday, January 11, 2011

PERL Functions






Definition and Usage

If EXPR is numeric, then it demands that the script requires the specified version of Perl in order to continue. If EXPR or $_ are not numeric, it assumes that the name is the name of a library file to be included. You cannot include the same file with this function twice. The included file must return a true value as the last statement.
This differs from use in that included files effectively become additional text for the current script. Functions, variables, and other objects are not imported into the current name space, so if the specified file includes a package definition, then objects will require fully qualified names.
The specified module is searched for in the directories defined in @INC, looking for a file with the specified name and an extension of .pm.

Return Value

  • Nothing

Example

Try out following example:
#!/usr/bin/perl -w

# require to demand a particular perl version.
require 5.003;

# require to include amodule.
require Module;
Perl_Programming_Tutorial

Tags: perl, functions
Source: http://www.tutorialspoint.com/perl/perl_require.htm

Wednesday, March 24, 2010

Modular programming in C




What is Modular programming ?

- A programming technique to break down program functions into separate modules/parts/layers.
- Module, have to accomplishes one function by containing the source codes and input/output variables needed to accomplish that function.

Tuesday, March 23, 2010

Function call order




The value of an expression shall be the same under any order of evaluation that the standard permits (misra2004_12_2_4_FunctionsCallOrder.rule)


Description

"Apart from a few operators (notably the function call operator (), &&, , ?: and , (comma)) the order in which sub-expressions are evaluated is unspecified and can vary. This means that no reliance can be placed on the order of evaluation of sub-expressions, and in particular no reliance can be placed on the order in which side effects occur. Those points in the evaluation of an expression at which all previous side effects can be guaranteed to have taken place are called “sequence points”. Sequence points and side effects are described in sections 5.1.2.3, 6.3 and 6.6 of ISO 9899:1990 [2].

Note that the order of evaluation problem is not solved by the use of parentheses, as this is not a precedence issue." "Functions may have additional effects when they are called (e.g. modifying some global data). Dependence on order of evaluation could be avoided by invoking the function prior to the expression that uses it, making use of a temporary variable for the value.

Labels