Skip to content

Commit

Permalink
Removed use of "subarray" for "slice"
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Feb 19, 2024
1 parent 080acae commit 5af4a35
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/content/docs/guide/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ retaining the same syntax as far as possible.
- Zero overhead errors
- Struct subtyping
- Semantic macro system
- Safe array access using sub arrays
- Safe array access using slices
- Zero cost simple gradual & opt-in pre/post conditions
- High level containers and string handling
- LLVM backend
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/guide/my-first-hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn void main() {}
:::tip
the name `main` is a bit special as it is also the entry point to the program.

For Unix-like OSes there are a few different variants, for example we might declare it as `fn void main(String[] args)`. In that case the parameter "args" contains a *sub array* of strings, which correspond to the command line arguments, with the first one being the name of the application itself.
For Unix-like OSes there are a few different variants, for example we might declare it as `fn void main(String[] args)`. In that case the parameter "args" contains a *slice* of strings, which correspond to the command line arguments, with the first one being the name of the application itself.
:::


Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/references/development/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ sidebar:

##### Revision 2019-12-25
- Changes how generic modules work.
- Switched so that vararrays use `Type[*]` and sub arrays use `Type[]`.
- Switched so that vararrays use `Type[*]` and slices use `Type[]`.
- Added submodule granularity, partial imports (only importing selected functions and types), removal of `local`, extended aliasing. See [modules](../modules).
- Updated "changes from C" with removal of multiple declarations.

Expand Down
6 changes: 3 additions & 3 deletions src/content/docs/references/docs/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ When you want to initialize a fixed array without specifying the size, use the [



## Subarray
## Slice

The final type is the subarray `<type>[]` e.g. `int[]`. A subarray is a view into either a fixed or variable array. Internally it is represented as a struct containing a pointer and a size. Both fixed and variable arrays may be converted into slices, and slices may be implicitly converted to pointers:
The final type is the slice `<type>[]` e.g. `int[]`. A slice is a view into either a fixed or variable array. Internally it is represented as a struct containing a pointer and a size. Both fixed and variable arrays may be converted into slices, and slices may be implicitly converted to pointers:

int[4] a = { 1, 2, 3, 4};
int[] b = &a; // Implicit conversion is always ok.
Expand All @@ -49,7 +49,7 @@ The final type is the subarray `<type>[]` e.g. `int[]`. A subarray is a view in

### Slicing arrays

It's possible to use a range syntax to create subarrays from pointers, arrays, vararrays and other subarrays. They either use range syntax:
It's possible to use a range syntax to create slices from pointers, arrays and other slicess. They either use range syntax:
`arr[<start index>..<end index>]` (the end index is included in the final result) or start + len syntax: `arr[<start index> : len]`


Expand Down
8 changes: 4 additions & 4 deletions src/content/docs/references/docs/compare.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ C3 adds features, but also removes a few.
- Associated enum data
- Distinct types and subtypes
- Optional contracts
- Built-in subarrays
- Built-in slices
- Foreach for iteration over arrays and types
- Dynamic calls and types

Expand Down Expand Up @@ -58,7 +58,7 @@ different from how C++ does things.
- Error handling
- Defer
- Associated enum data
- Built-in subarrays
- Built-in slices
- Dynamic calls

## Rust
Expand All @@ -70,9 +70,9 @@ pattern matching to mention a few.
Error handling is handled using `Result` and `Optional` which is similar to
how C3 works.

C3 compares to Rust much like C, although the presence of built-in subarrays and
C3 compares to Rust much like C, although the presence of built-in slices and
strings reduces the places where C3 is unsafe. Rust provides arrays and strings,
but they are not built in. Subarrays are the same as Rust's slices.
but they are not built in.

##### In Rust but not in C3

Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/references/docs/conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Substructs may be used in place of its parent structs in many cases. The rule is

1. A substruct pointer may implicitly convert to a parent struct.
2. A substruct *value* may be implicitly assigned to a variable with the parent struct type, This will *truncate* the value, copying only the parent part of the substruct. However, a substruct value cannot be assigned its parent struct.
3. Substruct subarrays, vararrays and arrays *can not* be cast (implicitly or explicitly) to an array of the parent struct type.
3. Substruct slices and arrays *can not* be cast (implicitly or explicitly) to an array of the parent struct type.

## Pointer conversions

Expand Down
4 changes: 2 additions & 2 deletions src/content/docs/references/docs/reflection.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Returns the minimum value of the type (only valid for integer and float types).

#### names

Returns a subarray containing the names of an enum or fault.
Returns a slice containing the names of an enum or fault.

enum FooEnum
{
Expand Down Expand Up @@ -192,7 +192,7 @@ Returns the typeid for the given type. `def`s will return the typeid of the unde

#### values

Returns a subarray containing the values of an enum or fault.
Returns a slice containing the values of an enum or fault.

enum FooEnum
{
Expand Down
8 changes: 4 additions & 4 deletions src/content/docs/references/docs/specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,9 @@ int[<2>] c = { a[0] * b[0], a[1] * b[1] };
An array has the alignment of its elements. An array must have at least one element.
### Subarray types
### Slice types
The subarray consist of a pointer, followed by an usz length, having the alignment of pointers.
The slice consist of a pointer, followed by an usz length, having the alignment of pointers.
### Pointer types
Expand Down Expand Up @@ -744,7 +744,7 @@ int d = (int)((int*)1); // Invalid, not constant

### Subscript operator

The subscript operator may take as its left side a pointer, array, subarray or vararray. The index may be of any integer
The subscript operator may take as its left side a pointer, array or slice. The index may be of any integer
type. TODO
*NOTE* The subscript operator is not symmetrical as in C. For example in C3 `array[n] = 33` is allowed, but
not `n[array] = 33`. This is a change from C.
Expand Down Expand Up @@ -1447,7 +1447,7 @@ Modifying the index variable will not affect the foreach iteration.

#### Foreach support

Foreach is natively supported for any subarray, array, pointer to an array, vector and pointer to a vector.
Foreach is natively supported for any slice, array, pointer to an array, vector and pointer to a vector.
These types support both iteration by value and reference.

In addition, a type with **operator overload** for `len` and `[]` will support iteration by value,
Expand Down
4 changes: 2 additions & 2 deletions src/content/docs/references/docs/standard_library.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ char* data2 = malloc(8, .using = my_allocator);

The first form allocates a single element of $Type, returning the pointer,
the second form allocates a slice with `elements` number of elements, returning
a subarray of the given length. Elements are not initialized.
a slice of the given length. Elements are not initialized.

```c
int* int = malloc(int);
int[] ints = new_array(int, 100); // Allocated int[100] on the heap.
int[] ints = mem::new_array(int, 100); // Allocated int[100] on the heap.
```

```c
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/references/docs/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ the raw `void*` pointer.

### Array types

Arrays are indicated by `[size]` after the type, e.g. `int[4]`. Subarrays use the `type[]`. For initialization the wildcard `type[*]` can be used to infer the size
Arrays are indicated by `[size]` after the type, e.g. `int[4]`. Slices use the `type[]`. For initialization the wildcard `type[*]` can be used to infer the size
from the initializer. See the chapter on [arrays](../arrays).

### Vector types
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/references/docs/undefinedbehaviour.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The following operations cause undefined behaviour in release builds of C3:
| dereference `null` | Yes |
| dereferencing memory not allocated | Possible\* |
| dereferencing memory outside of its lifetime | Possible\* |
| casting pointer to the incorrect array or vararray | Possible\* |
| casting pointer to the incorrect array | Possible\* |
| violating pre or post conditions | Yes |
| violating asserts | Yes |
| reaching `unreachable()` code | Yes |
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/references/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Last updated: [Revision 2023-10-24](changes).
- Zero overhead errors
- Struct subtyping
- Semantic macro system
- Safe array access using sub arrays
- Safe array access using slices
- Zero cost simple gradual & opt-in pre/post conditions
- High level containers and string handling
- C to C3 conversion (for a subset of C) *TODO*
Expand Down

0 comments on commit 5af4a35

Please sign in to comment.