Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace remaining uses of "attribute" with "annotation" #427

Merged
merged 2 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/syntax_and_semantics/annotations/built_in_annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Tells the compiler how to link a C library. This is explained in the [lib](../c_

## Extern

Marking a Crystal struct with this attribute makes it possible to use it in lib declarations:
Marking a Crystal struct with this annotation makes it possible to use it in lib declarations:

```crystal
@[Extern]
struct MyStruct
end

lib MyLib
fun my_func(s : MyStruct) # OK (gives an error without the Extern attribute)
fun my_func(s : MyStruct) # OK (gives an error without the Extern annotation)
end
```

Expand All @@ -38,7 +38,7 @@ s.char # => 'B'

## ThreadLocal

The `@[ThreadLocal]` attribute can be applied to class variables and C external variables. It makes them be thread local.
The `@[ThreadLocal]` annotation can be applied to class variables and C external variables. It makes them be thread local.

```crystal
class DontUseThis
Expand Down
6 changes: 3 additions & 3 deletions docs/syntax_and_semantics/c_bindings/callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ end

Note that we save the boxed callback in `@@box`. The reason is that if we don't do it, and our code doesn't reference it anymore, the GC will collect it. The C library will of course store the callback, but Crystal's GC has no way of knowing that.

## Raises attribute
## Raises annotation

If a C function executes a user-provided callback that might raise, it must be annotated with the `@[Raises]` attribute.
If a C function executes a user-provided callback that might raise, it must be annotated with the `@[Raises]` annotation.

The compiler infers this attribute for a method if it invokes a method that is marked as `@[Raises]` or raises (recursively).
The compiler infers this annotation for a method if it invokes a method that is marked as `@[Raises]` or raises (recursively).

However, some C functions accept callbacks to be executed by other C functions. For example, suppose a fictitious library:

Expand Down
2 changes: 1 addition & 1 deletion docs/syntax_and_semantics/c_bindings/fun.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ The valid types to use in C bindings are:
* Other `struct`, `union`, `enum`, `type` or `alias` declared previously.
* `Void`: the absence of a return value.
* `NoReturn`: similar to `Void`, but the compiler understands that no code can be executed after that invocation.
* Crystal structs marked with the `@[Extern]` attribute
* Crystal structs marked with the `@[Extern]` annotation

Refer to the [type grammar](../type_grammar.md) for the notation used in fun types.

Expand Down
2 changes: 1 addition & 1 deletion docs/syntax_and_semantics/c_bindings/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ C.errno = 0
C.errno # => 0
```

A variable can be marked as thread local with an attribute:
A variable can be marked as thread local with an annotation:

```crystal
lib C
Expand Down
6 changes: 3 additions & 3 deletions docs/syntax_and_semantics/enum.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ All enums inherit from [Enum](http://crystal-lang.org/api/Enum.html).

## Flags enums

An enum can be marked with the `@[Flags]` attribute. This changes the default values:
An enum can be marked with the `@[Flags]` annotation. This changes the default values:

```crystal
@[Flags]
Expand All @@ -62,7 +62,7 @@ enum IOMode
end
```

The `@[Flags]` attribute makes the first constant's value be `1`, and successive constants are multiplied by `2`.
The `@[Flags]` annotation makes the first constant's value be `1`, and successive constants are multiplied by `2`.

Implicit constants, `None` and `All`, are automatically added to these enums, where `None` has the value `0` and `All` has the "or"ed value of all constants.

Expand All @@ -71,7 +71,7 @@ IOMode::None.value # => 0
IOMode::All.value # => 7
```

Additionally, some `Enum` methods check the `@[Flags]` attribute. For example:
Additionally, some `Enum` methods check the `@[Flags]` annotation. For example:

```crystal
puts(Color::Red) # prints "Red"
Expand Down