Merge remote-tracking branch 'upstream/main' into add-sync_to_translation_status.er

This commit is contained in:
toddlerer 2023-01-27 06:36:35 +09:00
commit c3d27fb059
No known key found for this signature in database
GPG key ID: 44060B0ACE658F8D
47 changed files with 462 additions and 237 deletions

View file

@ -112,8 +112,8 @@ C = Class {x = Int}
.method self = ...
```
You can specify the language of the document by writing the language code immediately after the `'''`. The [Erg Language Server](https://github.com/erg-lang/erg/tree/main/compiler/els) will then display documents in the Markdown format for each language version (The default language is English).
See [here](https://github.com/erg-lang/erg/blob/main/doc/JA/dev_guide/i18n_messages.md) for registered language codes.
You can specify the language of the document by writing the language code immediately after the `'''`. The [Erg Language Server](https://github.com/erg-lang/erg/tree/main/crates/els) will then display documents in the Markdown format for each language version (The default language is English).
See [here](https://github.com/erg-lang/erg/blob/main/doc/EN/dev_guide/i18n_messages.md) for registered language codes.
```python
'''

View file

@ -76,25 +76,25 @@ Each of these literals has its own documentation describing them separately, so
[], [1], [1, 2, 3], ["1", "2",], ...
```
### [Tuple Literal](./11_tuple.md)
### [Tuple Literal](./13_tuple.md)
```python
(), (1, 2, 3), (1, "hello", True), ...
```
### [Dict Literal](./12_dict.md)
### [Dict Literal](./11_dict.md)
```python
{:}, {"one": 1}, {"one": 1, "two": 2}, {"1": 1, "2": 2}, {1: "1", 2: True, "three": [1]}, ...
```
### [Record Literal](./13_record.md)
### [Record Literal](./14_record.md)
```python
{=}, {one = 1}, {one = 1; two = 2}, {.name = "John"; .age = 12}, {.name = Str; .age = Nat}, ...
```
### [Set Literal](./14_set.md)
### [Set Literal](./15_set.md)
```python
{}, {1}, {1, 2, 3}, {"1", "2", "1"}, ...

View file

@ -98,11 +98,11 @@ The above code prints `π` when `x` is `3.141592653589793`. If `x` is changed to
Some objects cannot be bound as constants. Mutable objects, for example. Mutable objects are objects whose states can be changed, as described in detail later.
This is because of the rule that only constant expressions can be assigned to constants. Constant expressions are also discussed later.
```python,compile_fail
```python
X = 1 # OK
```
```python
```python,compile_fail
X = !1 # TypeError: cannot define Int! object as a constant
```

View file

@ -28,7 +28,7 @@ C!.
x
```
Procedural methods can also take [ownership](./18_ownership.md) of `self`. Remove `ref` or `ref!` from the method definition.
Procedural methods can also take [ownership](./19_ownership.md) of `self`. Remove `ref` or `ref!` from the method definition.
```python,compile_fail
n = 1

View file

@ -18,7 +18,7 @@ The difference from JavaScript object literals is that they are not accessible a
This is because access to the value is determined at compile-time, and because dictionaries and records are different things. In other words, `{"name": "John"}` is a Dict and `{name = "John"}` is a record.
So how should we use dictionaries and records?
In general, we recommend using records. Records have the advantages of being checked at compile-time for the existence of elements and of being able to specify __visibility_.
Specifying visibility is equivalent to specifying public/private in Java and other languages. For details, see [visibility](./19_visibility.md) for details.
Specifying visibility is equivalent to specifying public/private in Java and other languages. For details, see [visibility](./20_visibility.md) for details.
```python,compile_fail
a = {x = 1; .y = x + 1}
@ -53,7 +53,7 @@ assert o.i == 1
```
There is a notable syntax with respect to records. When all the attribute values of a record are classes (not structural types), the record itself behaves as a type with its own attributes as required attributes.
Such a type is called a record type. See the section [Record] for more details.
Such a type is called a record type. See the section [Record](../API/types/classes/Record.md) for more details.
```python
# record

View file

@ -8,15 +8,15 @@ Also, see [here](../terms.md) for terminology.
* ! → [side effect](./07_side_effect.md)
* !-type → [mutable type](./type/18_mut.md)
* ? → [error handling](./30_error_handling.md)
* # → [Str](./00_basic.md/#comment)
* ? → [error handling](./31_error_handling.md)
* # → [Str](./00_basic.md/#comments)
* $ → [shared](./type/advanced/shared.md)
* %
* &
* &&
* [′ (single quote)](./20_naming_rule.md#literal-identifiers)
* [′ (single quote)](./21_naming_rule.md#literal-identifiers)
* [" (double quote)](./01_literal.md#str-literal)
* () → [Tuple](./11_tuple.md)
* () → [Tuple](./13_tuple.md)
* *
* * → [*-less multiplication](./01_literal.md/#less-multiplication)
* + (prefix) → [operator](./06_operator.md)
@ -28,19 +28,19 @@ Also, see [here](../terms.md) for terminology.
* −_ → − (prefix)
* − (infix) → [operator](./06_operator.md)
* − (infix) → [Trait](./type/03_trait.md)
* −> → [anonymous function](./21_lambda.md)
* . → [Visibility](./19_visibility.md)
* −> → [anonymous function](./22_lambda.md)
* . → [Visibility](./20_visibility.md)
* .. → [closed range operator](./01_literal.md/#range-object)
* ..< → [right-open range operator](./01_literal.md/#range-object)
* ...
* ... → [Extract&nbsp;assignment](./28_spread_syntax.md#extract-assignment)
* ... → [Extract&nbsp;assignment](./29_spread_syntax.md#extract-assignment)
* ... → [Variable-length arguments](./04_function.md#variable-length-arguments)
* /
* :
* : → [Colon&nbsp;application&nbsp;style](./04_function.md)
* : → [Type ascription](./03_declaration.md.md)
* : → [Type ascription](./03_declaration.md)
* : → [Keyword&nbsp;arguments](./04_function.md)
* :: → [private variable modifier](./19_visibility.md)
* :: → [private variable modifier](./20_visibility.md)
* := → [default&nbsp;parameters](./04_function.md)
* ;
* &lt;
@ -49,13 +49,13 @@ Also, see [here](../terms.md) for terminology.
* &lt;=
* &lt;.. → [left-open range operator](./01_literal.md/#range-object)
* &lt;..&lt; → [open range operator](./01_literal.md/#range-object)
* = → [Variable](./19_visibility.md)
* = → [Variable](./20_visibility.md)
* ==
* => → [anonymous procedure operator](./08_procedure.md)
* &gt;
* &gt;&gt;
* &gt;=
* @ → [decorator](./29_decorator.md)
* @ → [decorator](./30_decorator.md)
* [] → [Array](./10_array.md)
* \ → [Escaping](./00_basic.md)
* ^
@ -63,11 +63,11 @@ Also, see [here](../terms.md) for terminology.
* _ → [Type&nbsp;erasure](./type/advanced/erasure.md)
* &#95;+&#95;&plus; (infix)
* &#95;-&#95;&minus; (infix)
* [``&nbsp;(back&nbsp;quote)](./22_subroutine.md#operator)
* [``&nbsp;(back&nbsp;quote)](./23_subroutine.md#operator)
* {}
* [{} type](./type/01_type_system.md)
* {=} → [Type&nbsp;System](./type/01_type_system.md#classification)
* [{=}&nbsp;type](./13_record.md#empty-record)
* [{=}&nbsp;type](./14_record.md#empty-record)
* |
* || → [Type variable list](./type/advanced/)
* ~
@ -83,11 +83,11 @@ Also, see [here](../terms.md) for terminology.
* [algebraic&nbsp;type](./type/13_algebraic.md)
* [And]
* [and]
* [anonymous&nbsp;function](./21_lambda.md)
* [anonymous&nbsp;function](./22_lambda.md)
* anonymous type → [Type&nbsp;system](./type/01_type_system.md)
* [Array](./10_array.md)
* [assert]
* [Attach](./29_decorator.md#attach)
* assert
* [Attach](./30_decorator.md#attach)
* [attribute](type/09_attributive.md)
* [Attribute&nbsp;definitions](./type/02_basic.md#attribute-definitions)
* [Attribute&nbsp;type](./type/09_attributive.md)
@ -96,7 +96,7 @@ Also, see [here](../terms.md) for terminology.
* [Bool, Boolean](./01_literal.md#boolean-object)
* [Boolean&nbsp;object](./01_literal.md#boolean-object)
* [borrowing](./18_ownership.md#borrow)
* [borrowing](./19_ownership.md#borrow)
### C
@ -104,43 +104,43 @@ Also, see [here](../terms.md) for terminology.
* [Comments](./00_basic.md#comments)
* [Complex&nbsp;object](./01_literal.md#complex-object)
* [Compile-time&nbsp;functions](./04_function.md#compile-time-functions)
* [circular&nbsp;references](./18_ownership.md#circular-references)
* [circular&nbsp;references](./19_ownership.md#circular-references)
* [Class](./type/04_class.md)
* [Class&nbsp;relationship](./type/04_class.md#class-relationships)
* [Class&nbsp;upcasting](./type/16_subtyping.md#class-upcasting)
* [Colon&nbsp;application&nbsp;style](./04_function.md#colon-application-style)
* [Closure](./23_closure.md)
* [Closure](./24_closure.md)
* [Compound literals](./01_literal.md#compound-literals)
* [Complement](./type/13_algebraic.md#complement)
* [Comprehension](./27_comprehension.md)
* [constant](./17_mutability.md#constant)
* [Comprehension](./28_comprehension.md)
* [constant](./18_mutability.md#constant)
* [Constants](./02_name.md#constants)
* [Context](./30_error_handling.md#context)
* [Context](./31_error_handling.md#context)
### D
* [Data&nbsp;type](./type/01_type_system.md#data-type)
* [Declaration](./03_declaration.md)
* [decorator](./29_decorator.md)
* [decorator](./30_decorator.md)
* [Default&nbsp;parameters](./04_function.md#default-parameters)
* [Del](./02_name.md#delete-an-variable)
* [Dependent&nbsp;type](./type/14_dependent.md)
* Deprecated
* [Dict](./12_dict.md)
* [Dict](./11_dict.md)
* [Diff](./type/13_algebraic.md#diff)
* distinct
* [Downcasting](./type/17_type_casting.md#downcasting)
### E
* [Empty&nbsp;record](./13_record.md#empty-record)
* [Empty&nbsp;record](./14_record.md#empty-record)
* [Enum&nbsp;class](./type/04_class.md#enum-class)
* [Enum&nbsp;type](./type/11_enum.md)
* [Enumerated,&nbsp;Interval&nbsp;and&nbsp;Refinement&nbsp;types](./type/12_refinement.md#enumerated-interval-and-refinement-types)
* [error&nbsp;handling](./30_error_handling.md)
* [error&nbsp;handling](./31_error_handling.md)
* [Existential&nbsp;type](./type/advanced/existential.md)
* [Exponential&nbsp;literal](./01_literal.md#exponential-literal)
* [Extract&nbsp;assignment](./28_spread_syntax.md#extract-assignment)
* [Extract&nbsp;assignment](./29_spread_syntax.md#extract-assignment)
### F
@ -148,14 +148,14 @@ Also, see [here](../terms.md) for terminology.
* [Float&nbsp;object](./01_literal.md#float-object)
* [for](./05_builtin_funcs.md#for)
* [For-All&nbsp;patch](./type/07_patch.md#for-all-patch)
* [freeze](./18_ownership.md#freeze)
* [freeze](./19_ownership.md#freeze)
* [Function](./04_function.md)
* [Function&nbsp;definition&nbsp;with&nbsp;multiple patterns](./04_function.md#function-definition-with-multiple-patterns)
### G
* [GADTs(Generalized&nbsp;Algebraic&nbsp;Data&nbsp;Types)](./type/advanced/GADTs.md)
* [Generator](./34_generator.md)
* [Generator](./35_generator.md)
* [Glue&nbsp;Patch](./type/07_patch.md#glue-patch)
### H
@ -166,19 +166,19 @@ Also, see [here](../terms.md) for terminology.
* [id](./09_builtin_procs.md#id)
* [if](./05_builtin_funcs.md#if)
* [import](./33_package_system.md)
* [impl](./29_decorator.md#impl)
* [in]
* [import](./34_package_system.md)
* [impl](./30_decorator.md#impl)
* in
* [Indention](./00_basic.md#indentation)
* [Instant&nbsp;block](./13_record.md#instant-block)
* [Instant&nbsp;block](./14_record.md#instant-block)
* [Instance/class&nbsp;attributes](./type/04_class.md#instance-and-class-attributes)
* [inheritable](./29_decorator.md#inheritable)
* [inheritable](./30_decorator.md#inheritable)
* [inheritance](./type/05_inheritance.md)
* [Int](./01_literal.md)
* [Integration&nbsp;with&nbsp;Python](./32_integration_with_Python.md)
* [Integration&nbsp;with&nbsp;Python](./33_integration_with_Python.md)
* [Interval&nbsp;Type](./type/10_interval.md)
* [Intersection](./type/13_algebraic.md#intersection)
* [Iterator](./16_iterator.md)
* [Iterator](./17_iterator.md)
### J
@ -189,59 +189,59 @@ Also, see [here](../terms.md) for terminology.
### L
* lambda → [anonymous&nbsp;function](./21_lambda.md)
* lambda → [anonymous&nbsp;function](./22_lambda.md)
* let-polymorphism → [rank&nbsp;1&nbsp;polymorphism]
* [Literal&nbsp;Identifiers](./20_naming_rule.md#literal-identifiers)
* [Literal&nbsp;Identifiers](./21_naming_rule.md#literal-identifiers)
### M
* [match]
* match
* [Marker&nbsp;trait](./type/advanced/marker_trait.md)
* [Method](./07_side_effect.md#methods)
* Modifier → [decorator](./29_decorator.md)
* [module](./24_module.md)
* Modifier → [decorator](./30_decorator.md)
* [module](./25_module.md)
* [Multiple&nbsp;inheritance](type/05_inheritance.md#multiple-inheritance)
* [Multi-layer&nbsp;(multi-level)&nbsp;Inheritance](type/05_inheritance.md#multi-layer-multi-level-inheritance)
* [Mutable&nbsp;type](./type/18_mut.md)
* [Mutable&nbsp;structure&nbsp;type](./type/advanced/mut_struct.md)
* [Mutability](./17_mutability.md)
* [Mutability](./18_mutability.md)
### N
* [Nat](./01_literal.md#int-literal)
* [Never]
* Never
* [New&nbsp;type](./type/advanced/newtype.md)
* [Heterogeneous&nbsp;Dict](./12_dict.md#heterogeneous-dict)
* [Heterogeneous&nbsp;Dict](./11_dict.md#heterogeneous-dict)
* None → [None&nbsp;Object]
* [None&nbsp;Object]
* None&nbsp;Object
* Nominal&nbsp;Subtyping → [Class](./type/04_class.md)
* [Not]
* [not]
* Not
* not
### O
* [Object](./25_object_system.md)
* [Object](./26_object_system.md)
* [Option]
* [Or]
* [or]
* [Ord]
* [ownership&nbsp;system](./18_ownership.md)
* [ownership&nbsp;system](./19_ownership.md)
* [Overloading](./type/advanced/overloading.md)
* [Overriding](./type/05_inheritance.md#overriding)
* [Override&nbsp;in&nbsp;trait](./type/03_trait.md#override-in-trait)
### P
* [Panic](./30_error_handling.md#panic)
* [Panic](./31_error_handling.md#panic)
* [Patch](./type/07_patch.md)
* [Pattern&nbsp;match](./26_pattern_matching.md)
* [Pattern&nbsp;match](./27_pattern_matching.md)
* [Phantom&nbsp;class](./type/advanced/phantom.md)
* [pipeline&nbsp;operator](./31_pipeline.md)
* [pipeline&nbsp;operator](./32_pipeline.md)
* [Predicate](./type/19_bound.md#predicate)
* [print!]
* print!
* [Procedures](./08_procedure.md)
* [Projection&nbsp;type](./type/advanced/projection.md)
* Python → [Integration&nbsp;with&nbsp;Python](./32_integration_with_Python.md)
* Python → [Integration&nbsp;with&nbsp;Python](./33_integration_with_Python.md)
### Q
@ -251,15 +251,15 @@ Also, see [here](../terms.md) for terminology.
### R
* [Range&nbsp;Object](./01_literal.md#range-object)
* [ref]
* [ref!]
* [Record](./13_record.md)
* ref
* ref!
* [Record](./14_record.md)
* [Recursive&nbsp;functions](./04_function.md#recursive-functions)
* [Refinement&nbsp;pattern](./type/12_refinement.md#refinement-pattern)
* [Refinement&nbsp;type](./type/12_refinement.md)
* [replication](./18_ownership.md#replication)
* [replication](./19_ownership.md#replication)
* [Replacing&nbsp;traits](./type/05_inheritance.md#replacing-traits-or-what-looks-like-it)
* Result → [error&nbsp;handling](./30_error_handling.md)
* Result → [error&nbsp;handling](./31_error_handling.md)
### S
@ -269,9 +269,9 @@ Also, see [here](../terms.md) for terminology.
* [Shared&nbsp;reference](./type/advanced/shared.md)
* [side-effect](./07_side_effect.md)
* [Smart&nbsp;cast](./type/12_refinement.md#smart-cast)
* [Spread&nbsp;assignment](./28_spread_syntax.md)
* [Spread&nbsp;assignment](./29_spread_syntax.md)
* [special&nbsp;type&nbsp;variables](./type/advanced/special.md#special-type-variables)
* [Stack&nbsp;trace](30_error_handling.md#stack-trace)
* [Stack&nbsp;trace](./31_error_handling.md#stack-trace)
* [Structure&nbsp;type](./type/01_type_system.md#structure-type-anonymous-type)
* [Structural&nbsp;patch](./type/07_patch.md#structural-patch)
* [Structural&nbsp;trait](./type/03_trait.md#structural-traits)
@ -282,17 +282,17 @@ Also, see [here](../terms.md) for terminology.
* [Subtyping&nbsp;of&nbsp;subroutines](./type/16_subtyping.md#subtyping-of-subroutines)
* [Subtype&nbsp;specification](./type/02_basic.md#subtype-specification)
* [Subtyping&nbsp;of&nbsp;polymorphic&nbsp;function types](./type/15_quantified.md#subtyping-of-polymorphic-function-types)
* [Subroutine&nbsp;signatures](./22_subroutine.md)
* [Subroutine&nbsp;signatures](./23_subroutine.md)
### T
* [Test](./29_decorator.md#test)
* [Test](./30_decorator.md#test)
* [Traits](./type/03_trait.md)
* [Trait&nbsp;inclusion](./type/03_trait.md#trait-inclusion)
* True → [Boolean&nbsp;object](./01_literal.md#boolean-object)
* [True&nbsp;algebraic&nbsp;type](./type/13_algebraic.md#true-algebraic-type)
* [Type]
* [type](./15_type.md)
* Type
* [type](./16_type.md)
* [Type&nbsp;arguments&nbsp;in&nbsp;method&nbsp;definitions](./type/15_quantified.md#type-arguments-in-method-definitions)
* [Type&nbsp;bound](./type/19_bound.md)
* [Type&nbsp;definitions](./type/01_type_system.md#type-definitions)
@ -301,12 +301,12 @@ Also, see [here](../terms.md) for terminology.
* [Type&nbsp;specification](./type/02_basic.md#type-specification)
* [Type&nbsp;system](./type/01_type_system.md)
* [Type&nbsp;widening](./type/advanced/widening.md)
* [Tuple](./11_tuple.md)
* [Tuple](./13_tuple.md)
### U
* [union](type/13_algebraic.md#union)
* [Unit](./11_tuple.md#unit)
* [Unit](./13_tuple.md#unit)
* [Upcasting](type/17_type_casting.md#upcasting)
### V
@ -317,7 +317,7 @@ Also, see [here](../terms.md) for terminology.
### W
* [while]
* while!
### X