mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
4.8 KiB
4.8 KiB
Some short names:
- expl - explicit
- sw/sn - simple widening + subexpression narrowing
- yes - always allowed
- explptr - explicit if pointer sized
- ptrconv - to/from void* is fine, other cast must be explicit
- saconv - explicit if same element size
- explbase - explicit to base disregaring sign
- distel - explicit to same element disregarding distinct
- inline - implicit if type subtype
- cond - implicit in cond, explicit otherwise
- edist - explicit to anything underlying type can convert to, if inline as underlying
- arve - if array or vec ptr
Bool
- Explicitly convert to float, int, bool vector
- Implicitly convert to bool vector init
- Implicitly convert to distinct bool if constant value.
Int
- Implicitly convert to unsigned counterpart
- Implicitly convert to float / wider int for simple expressions.
- Implicitly convert to same int vector init (or any?)
- Explicitly convert to pointer if pointer sized
- Explicitly convert to same size int vector, enum with same backing size, bitstruct with same backing size.
- Explicitly convert to bool, any int or float.
- Implicitly convert to bool in conditionals.
- Implicitly convert to any distinct integer. (Same size only?)
- Implicitly convert to any float/int/distinct float/int if constant value that fits.
Float
- Implicitly convert to wider float for simple expressions.
- Implicitly convert to same float vector init (or any?)
- Explicitly convert to bool, any int or float.
- Explicitly convert to any distinct float. (Same size only?)
- Implicitly convert to any float / distinct float constant value that fits.
Non void* pointer
- Implicitly convert to void* and
any. - Implicitly convert to an interface if the pointee implements the interface.
- Explicitly convert to pointer sized int.
- Implicitly convert to slice if it is a pointer to a vector or array.
- Explicitly convert to any other pointer.
- Explicitly convert to any distinct pointer.
void* pointer
- Implicitly convert to a pointer sized int.
- Implicitly convert to any other pointer.
- Explicitly convert to any distinct pointer.
- Implicitly convert to any distinct pointer if constant value.
Slice
- Implicitly convert to a pointer of the same type.
| from, to | bool | int | float | pointer | subarr | vec | bits | distc | array | struct | union | any | fault | enum | typeid |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| bool | n/a | expl | expl | no | no | expand | no | edist | no | no | no | no | no | no | no |
| int | cond | sw/sn | always | explptr | no | expand | explbase | edist | no | no | no | no | no | edist | no |
| float | cond | expl | sw/sn | no | no | expand | no | edist | no | no | no | no | no | no | no |
| pointer | cond | explptr | no | ptrconv | arve | expand | no | edist | no | no | no | yes | expl | no | expl |
| slice | cond | no | no | no | saconv | no | no | edist | no? | no | no | no | no | no | no |
| vec | cond | no | no | no | no | as base | no | edist | expl | no | no | no | no | no | no |
| bits | no | explbase | no | no | no | no | no? | edist | explbase | no | no | no | no | no | no |
| distc | edist | edist | edist | edist | edist | edist | edist | edist | edist | edist | edist | edist | edist | edist | edist |
| array | no | no | no | no | no | explbase | explbase | edist | distel | no | no | no | no | no | no |
| struct | inline | inline | inline | inline | inline | inline | inline | edist | inline | inline | inline | inline | inline | inline | inline |
| union | no | no | no | no | no | no | no | edist | no | no | no | no | no | no | no |
| any | cond | no | no | expl | no | no | no | edist | no | no | no | n/a | no | no | no |
| fault | cond | explptr | no | expl | no | no | no | edist | no | no | no | no | anyf | no | no |
| enum | no | expl | no | no | no | expand | no | edist | no | no | no | no | no | no | no |
| typeid | cond | no | no | expl | no | no | no | edist | no | no | no | no | no | no | n/a |