You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/writing-reactors/preambles.mdx
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -440,7 +440,7 @@ The important takeaway here is with the package.json file and the compiled JavaS
440
440
441
441
<ShowIfrs>
442
442
443
-
You can use the `preamble` to define macros and functions that are shared within the given reactor:
443
+
For example, you can use the `preamble` to define macros and functions that are shared within the given reactor:
444
444
445
445
```lf-c
446
446
target Rust;
@@ -472,7 +472,8 @@ add 42 example: 52
472
472
473
473
By having the `preamble` inside the reactor, you can define any functions or macros to be shared within the given reactor.
474
474
This will allow you to reuse code across different reactions easily within the same reactor.
475
-
This also can allow us to change the scope of items using the 'use' statement.
475
+
This also can allow us to change the scope of items using the `use` statement.
476
+
476
477
For example, the follow reactor brings the constant `PI` into scope and print out the first 15 digits of pi:
477
478
478
479
```lf-c
@@ -529,7 +530,7 @@ This will print:
529
530
Hello, world!
530
531
```
531
532
532
-
Its important to note that besides the crates specified in the target declarations_cargo-dependencies_ and user modules in _rust-include_, all user code is added to a module called `reactors` during compilation time.
533
+
It is important to note that besides Crates specified in the rust target declaration's_cargo-dependencies_ and user modules in _rust-include_, all user code is added to a module called `reactors` during compilation time.
533
534
This means that crate level attributes like `#![no_std]` will not work if added to the preamble.
0 commit comments