Significantly Prettier and Easier C++ Syntax
From Wikipedia, the free encyclopedia
Significantly Prettier and Easier C++ Syntax or SPECS is an alternative syntactic binding for the semantics of C++ designed by Ben Werther and Damian Conway. SPECS has a LALR(1) parsable grammar, which means it is significantly easier to parse than standard C++ syntax, both for computers and for humans alike. Also unlike standard C++ syntax, in SPECS declarations do not look like uses. For example, the fundamental C++ allocation control function set_new_handler has this declaration in orthodox C++ syntax:
void (*set_new_handler(void (*)(void)))(void);
which in SPECS becomes:
func set_new_handler : (^(void->void) -> ^(void->void));
and using typedefs in C++:
typedef void (*new_handler)(void); new_handler set_new_handler(new_handler);
and in SPECS:
type new_handler : ^(void->void); func set_new_handler : (new_handler -> new_handler);
Apart from the declaration syntax change, the template syntax is changed to use <[ ]> brackets to make the template keyword unnecessary, several overloaded syntax elements are separated for clarity and some small things are changed such as := for assignment (instead of =), and = for comparison (instead of ==), mandatory blocks for if-, for- and while-statements and no fallthrough for switch-statements.
[edit] External links
[edit] Seminal articles (PDF)
- The Design and Implementation of: An Alternative C++ Syntax
- A Modest Proposal: C++ Resyntaxed a shorter version which cites the above