Monday, February 25, 2008

Function Ptrs in the C/C++ languages

In the C/C++ languages, the notion of function ptrs has been used only in a limited way, to my thought, though they provide quite a expressive setting. This is thought to be due to the cumbersome and/or difficult syntax for writing functions ptrs and their types.

To relieve this problem, a nice tutorial is given by Lars Haendel:

The Function Pointer Tutorials
- http://www.newty.de/zip/e_fpt.pdf


* Should correct something with sidebars!
==
type-name: (type-specifier type-qualifier)+ abstract-declarator?

type-specifier: ("void" "char" "short" "int" "long" "float" "double" "signed" "unsigned" struct-or-union-specifier enum-specifier typedef-name)

type-qualifier: ("const" "volatile")

abstract-declarator: pointer ("(" abstract-declarator ")")? ( "[" constant-expression? "]" "(" parameter-type-list? ")" )*

enum-specifier: "enum" (identifier identifier? "{" enumerator% "}")

enumerator: identifier ("=" constant-expression)?

struct-or-union-specifier: ("struct" "union") ( identifier? "{" struct-declaration+ "}" identifier )

struct-declaration: (type-specifier type-qualifier)+ struct-declarator%

struct-declarator: declarator declarator? ":" constant-expression

pointer: ("*" type-qualifier*)*

parameter-type-list: parameter-declaration% ("," "...")?

parameter-declaration: declaration-specifiers (declarator abstract-declarator)?

==

No comments: