Skip to content

Commit

Permalink
Improve wording on alignof and sizeof pages
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Jan 9, 2024
1 parent 22698c1 commit 3bb6d0e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/syntax_and_semantics/alignof.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ alignof(Bar) # => 1
For [Reference](https://crystal-lang.org/api/Reference.html) types, the alignment is the same as the alignment of a pointer:

```crystal
# On a 64 bits machine
# On a 64-bit machine
alignof(Pointer(Int32)) # => 8
alignof(String) # => 8
```

This is because a Reference's memory is allocated on the heap and a pointer to it is passed around. To get the effective alignment of a class, use [instance_alignof](instance_alignof.md).
This is because a reference's memory is allocated on the heap and a pointer to it is passed around. To get the effective alignment of a class, use [instance_alignof](instance_alignof.md).

The argument to alignof is a [type](type_grammar.md) and is often combined with [typeof](typeof.md):

Expand Down
4 changes: 3 additions & 1 deletion docs/syntax_and_semantics/instance_alignof.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# instance_alignof

The `instance_alignof` expression returns an `Int32` with the instance alignment of a given class. For example:
The `instance_alignof` expression returns an `Int32` with the instance alignment of a given class.
It's the equivalent to [`alignof`](alignof.md) but for reference types.
For example:

```crystal
class Foo
Expand Down
4 changes: 3 additions & 1 deletion docs/syntax_and_semantics/instance_sizeof.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# instance_sizeof

The `instance_sizeof` expression returns an `Int32` with the instance size of a given class. For example:
The `instance_sizeof` expression returns an `Int32` with the instance size of a given class.
It's the equivalent to [`sizeof`](sizeof.md) but for reference types.
For example:

```crystal
class Point
Expand Down
4 changes: 2 additions & 2 deletions docs/syntax_and_semantics/sizeof.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ sizeof(Int64) # => 8
For [Reference](https://crystal-lang.org/api/Reference.html) types, the size is the same as the size of a pointer:

```crystal
# On a 64 bits machine
# On a 64-bit machine
sizeof(Pointer(Int32)) # => 8
sizeof(String) # => 8
```

This is because a Reference's memory is allocated on the heap and a pointer to it is passed around. To get the effective size of a class, use [instance_sizeof](instance_sizeof.md).
This is because a reference's memory is allocated on the heap and a pointer to it is passed around. To get the effective size of a class, use [instance_sizeof](instance_sizeof.md).

The argument to sizeof is a [type](type_grammar.md) and is often combined with [typeof](typeof.md):

Expand Down

0 comments on commit 3bb6d0e

Please sign in to comment.