# Common programming concepts
## `main`
As always, `main` is the entry point of the program. For example:
`main` can have either:
- No parameters: **`#!cpp main: () /*etc.*/`**
- One parameter of implicit type named `args`: **`#!cpp main: (args) /*etc.*/`**
- The type of `args` cannot be explicitly specified. It is always `cpp2::args_t`, which behaves similarly to a `#!cpp const std::array`.
- Using `args` performs zero heap allocations. Every `string_view` is directly bound to the string storage provided by host environment.
- `args.argc` and `args.argv` additionally provide access to the raw C/C++ `main` parameters.
``` cpp title="main with (args)" hl_lines="5 9"
// Print out command line arguments, then invoke
// a Qt event loop for a non-UI Qt application
main: (args) -> int
= {
for args do (arg) {
std::cout identifier == "void";
// Cpp2 equivalents:
address = tokens*[pos + num]&;
is_void = u**.identifier* == "void";
```
Postfix notation lets the code read fluidly left-to-right, in the same order in which the operators will be applied, and lets declaration syntax be consistent with usage syntax. For more details, see [Design note: Postfix operators](https://github.com/hsutter/cppfront/wiki/Design-note%3A-Postfix-operators).
> Note: The function call syntax `f(x)` calls a namespace-scope function only. The function call syntax `x.f()` is a unified function call syntax (aka UFCS) that calls a type-scope function in the type of `x` if available, otherwise calls the same as `f(x)`. The function call syntax `x..f()` calls a type-scope function only. For details, see [Design note: UFCS](https://github.com/hsutter/cppfront/wiki/Design-note%3A-UFCS).
| Unary operator | Cpp2 example | Cpp1 equivalent |
|---|---|---|
| `#!cpp .` | `#!cpp obj.f()` | `#!cpp obj.f()` |
| `#!cpp *` | `#!cpp pobj*.f()` | `#!cpp (*pobj).f()` or `#!cpp pobj->f()` |
| `#!cpp &` | `#!cpp obj&` | `#!cpp &obj` |
| `#!cpp ~` | `#!cpp val~` | `#!cpp ~val` |
| `#!cpp ++` | `#!cpp iter++` | `#!cpp ++iter` |
| `#!cpp --` | `#!cpp iter--` | `#!cpp --iter` |
| `(` `)` | `#!cpp f( 1, 2, 3)` | `#!cpp f( 1, 2, 3)` |
| `[` `]` | `#!cpp vec[123]` | `#!cpp vec[123]` |
| `.. Note: The `(` `)`, `[` `]`, `.. Note: Because `++` and `--` always have in-place update semantics, we never need to remember "use prefix `++`/`--` unless you need a copy of the old value." If you do need a copy of the old value, just take the copy before calling `++`/`--`. When you write a copyable type that overloads `operator++` or `operator--`, cppfront generates also the copy-old-value overload of that function to support natural use of the type from Cpp1 code.
### Binary operators
Binary operators are the same as in Cpp1. From highest to lowest precedence:
| Binary operators grouped by precedence |
|---|
| `*`, `/`, `%` |
| `+`, `-` |
| `` |
| `` |
| ``, `=` |
| `==`, `!=` |
| `&` |
| `^` |
| `|` |
| `&&` |
| `||` |
| `=` and compound assignment |
[^u8using]: Or `123.cpp2::u8()` if you aren't `using` the namespace or that specific name.