Makro
The Cairo language has some plugins that allow developers to simplify their code. They are called inline_macros
and are a way of writing code that generates other code.
consteval_int!
Macro
Dalam beberapa situasi, seorang pengembang mungkin perlu mendeklarasikan konstanta yang merupakan hasil dari perhitungan bilangan bulat. Untuk menghitung ekspresi konstan dan menggunakan hasilnya pada saat kompilasi, diperlukan untuk menggunakan macro consteval_int!
.
Berikut adalah contoh dari consteval_int!
:
const a: felt252 = consteval_int!(2 * 2 * 2);
Ini akan diinterpretasikan sebagai const a: felt252 = 8;
oleh kompiler.
selector!
Macro
selector!("function_name")
macro generates the entry point selector for the given function name.
print!
and println!
Macros
Please refer to the Printing page.
array!
Macro
Please refer to the Arrays page.
panic!
Macro
See Unrecoverable Errors with panic page.
assert!
and assert_xx!
Macros
See How to Write Tests page.
format!
Macro
See Printing page.
write!
and writeln!
Macros
See Printing page.
get_dep_component!
, get_dep_component_mut
and component!
Macros
Please refer to the Composability and Components chapter.