A
aarklon
Hi all,
In the article http://en.wikipedia.org/wiki/C_language
it is written as follows
C has the following important features:
1) A simple core language, with important functionality such as math
functions and file handling provided by sets of library routines
instead
2) Focus on the procedural programming paradigm, with facilities for
programming in a structured style
3) A type system which prevents many operations that are not
meaningful
4) Use of a preprocessor language, the C preprocessor, for tasks such
as defining macros and including multiple source code files
5) Low-level access to computer memory via the use of pointers
6) A minimalistic set of keywords
7) Parameters that are passed by value. Pass-by-reference semantics
may be simulated by explicitly passing pointer values.
8) Function pointers and static variables, which allow for a
rudimentary form of closures and runtime polymorphism
9) Lexical variable scope
10) Records, or user-defined aggregate datatypes (structs) which
allow related data to be combined and manipulated as a whole
Now my question is on the 8th point
1) Can any body give examples for run time polymorphism in C
is it similar to virtual functions in c++
2)what exactly is this closure???
http://en.wikipedia.org/wiki/Closure_(computer_science)
says
A closure is a function created by a program at run time. This idea
is written as a function that appears entirely within the body of
another function. The nested, inner function may refer to local
variables of the outer function. As the outer function executes,
it creates a closure of the inner function. The closure consists of
the function code and a reference to any variables in the outer
function's scope that the closure needs.
As far as my understanding goes nested functions are not possible in C
In the article http://en.wikipedia.org/wiki/C_language
it is written as follows
C has the following important features:
1) A simple core language, with important functionality such as math
functions and file handling provided by sets of library routines
instead
2) Focus on the procedural programming paradigm, with facilities for
programming in a structured style
3) A type system which prevents many operations that are not
meaningful
4) Use of a preprocessor language, the C preprocessor, for tasks such
as defining macros and including multiple source code files
5) Low-level access to computer memory via the use of pointers
6) A minimalistic set of keywords
7) Parameters that are passed by value. Pass-by-reference semantics
may be simulated by explicitly passing pointer values.
8) Function pointers and static variables, which allow for a
rudimentary form of closures and runtime polymorphism
9) Lexical variable scope
10) Records, or user-defined aggregate datatypes (structs) which
allow related data to be combined and manipulated as a whole
Now my question is on the 8th point
1) Can any body give examples for run time polymorphism in C
is it similar to virtual functions in c++
2)what exactly is this closure???
http://en.wikipedia.org/wiki/Closure_(computer_science)
says
A closure is a function created by a program at run time. This idea
is written as a function that appears entirely within the body of
another function. The nested, inner function may refer to local
variables of the outer function. As the outer function executes,
it creates a closure of the inner function. The closure consists of
the function code and a reference to any variables in the outer
function's scope that the closure needs.
As far as my understanding goes nested functions are not possible in C