Skip to content

Commit

Permalink
[doc] Improved clarity in phrasing & Fixed footnote (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
nerodesu017 authored Sep 26, 2024
1 parent 00fd63e commit cb60a74
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion doc/tutorial/Casts.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ There are obviously some cases where the compiler can determine that a cast coul

You should usually avoid type casts and type queries in your programs. A failed cast will terminate your program with an exception if it fails at runtime, therefore you should strive to make sure that no cast can ever fail. Type queries in your program may indicate that it has a design problem that could be avoided by restructuring your program.

However, sometimes type queries and type casts are the most straightforward and simplest way to solve a problem. If localized, they can serve as a cheap form of pattern matching, particularly when used with parameterized methods. You should consider the design impact of restructuring your program to avoid casts. If eliminating a few casts requires restructuring entire class hierarchies and adding lots of methods, then maybe it's not worth it; use your judgment for is the simplest solution overall.
However, sometimes type queries and type casts are the most straightforward and simplest way to solve a problem. If localized, they can serve as a cheap form of pattern matching, particularly when used with parameterized methods. You should consider the design impact of restructuring your program to avoid casts. If eliminating a few casts requires restructuring entire class hierarchies and adding lots of methods, then maybe it's not worth it; use your judgment for what is the simplest solution overall.
4 changes: 2 additions & 2 deletions doc/tutorial/Layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Virgil is a language for writing systems software at the lowest level.
Such software often has to manipulate data in formats that are specified by software and hardware that cannot be changed.
For example, bootstrapping the language, implementing high-performance (zero-copying) I/O, and interacting with memory-mapped I/O devices requires reading and writing data in specific formats.
Prior to the introduction of layouts in Virgil, such interactions were done with byte-by-byte encoding or direct pointers.
With the addition of layouts, this code because easier and safer to write, making it a breeze to deal with data in binary formats.
With the addition of layouts, this code becomes easier and safer to write, making it a breeze to deal with data in binary formats.

## Specifying a memory layout

Expand Down Expand Up @@ -37,7 +37,7 @@ Every field must have an explicit offset[^1].
While being a little more work to write, this allows for the most general descriptions, including skipping padding and choosing exact alignment.
The compiler will check that fields do not overlap or overflow the specified layout size.

[^1] The offset of a field can be written in hexadecimal, which makes it easy to align, e.g. to powers of two.
[^1]: The offset of a field can be written in hexadecimal, which makes it easy to align, e.g. to powers of two.

## Allowable layout field types

Expand Down

0 comments on commit cb60a74

Please sign in to comment.