mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-01 21:21:10 +00:00
Merge remote-tracking branch 'upstream/main' into add-sync_to_translation_status.er
This commit is contained in:
commit
c3d27fb059
47 changed files with 462 additions and 237 deletions
|
@ -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
|
||||
'''
|
||||
|
|
|
@ -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"}, ...
|
||||
|
|
|
@ -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
|
||||
```
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 assignment](./28_spread_syntax.md#extract-assignment)
|
||||
* ... → [Extract assignment](./29_spread_syntax.md#extract-assignment)
|
||||
* ... → [Variable-length arguments](./04_function.md#variable-length-arguments)
|
||||
* /
|
||||
* :
|
||||
* : → [Colon application style](./04_function.md)
|
||||
* : → [Type ascription](./03_declaration.md.md)
|
||||
* : → [Type ascription](./03_declaration.md)
|
||||
* : → [Keyword arguments](./04_function.md)
|
||||
* :: → [private variable modifier](./19_visibility.md)
|
||||
* :: → [private variable modifier](./20_visibility.md)
|
||||
* := → [default parameters](./04_function.md)
|
||||
* ;
|
||||
* <
|
||||
|
@ -49,13 +49,13 @@ Also, see [here](../terms.md) for terminology.
|
|||
* <=
|
||||
* <.. → [left-open range operator](./01_literal.md/#range-object)
|
||||
* <..< → [open range operator](./01_literal.md/#range-object)
|
||||
* = → [Variable](./19_visibility.md)
|
||||
* = → [Variable](./20_visibility.md)
|
||||
* ==
|
||||
* => → [anonymous procedure operator](./08_procedure.md)
|
||||
* >
|
||||
* >>
|
||||
* >=
|
||||
* @ → [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 erasure](./type/advanced/erasure.md)
|
||||
* _+_ → + (infix)
|
||||
* _-_ → − (infix)
|
||||
* [`` (back quote)](./22_subroutine.md#operator)
|
||||
* [`` (back quote)](./23_subroutine.md#operator)
|
||||
* {}
|
||||
* [{} type](./type/01_type_system.md)
|
||||
* {=} → [Type System](./type/01_type_system.md#classification)
|
||||
* [{=} type](./13_record.md#empty-record)
|
||||
* [{=} type](./14_record.md#empty-record)
|
||||
* |
|
||||
* || → [Type variable list](./type/advanced/)
|
||||
* ~
|
||||
|
@ -83,11 +83,11 @@ Also, see [here](../terms.md) for terminology.
|
|||
* [algebraic type](./type/13_algebraic.md)
|
||||
* [And]
|
||||
* [and]
|
||||
* [anonymous function](./21_lambda.md)
|
||||
* [anonymous function](./22_lambda.md)
|
||||
* anonymous type → [Type 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 definitions](./type/02_basic.md#attribute-definitions)
|
||||
* [Attribute type](./type/09_attributive.md)
|
||||
|
@ -96,7 +96,7 @@ Also, see [here](../terms.md) for terminology.
|
|||
|
||||
* [Bool, Boolean](./01_literal.md#boolean-object)
|
||||
* [Boolean 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 object](./01_literal.md#complex-object)
|
||||
* [Compile-time functions](./04_function.md#compile-time-functions)
|
||||
* [circular references](./18_ownership.md#circular-references)
|
||||
* [circular references](./19_ownership.md#circular-references)
|
||||
* [Class](./type/04_class.md)
|
||||
* [Class relationship](./type/04_class.md#class-relationships)
|
||||
* [Class upcasting](./type/16_subtyping.md#class-upcasting)
|
||||
* [Colon application 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 type](./type/01_type_system.md#data-type)
|
||||
* [Declaration](./03_declaration.md)
|
||||
* [decorator](./29_decorator.md)
|
||||
* [decorator](./30_decorator.md)
|
||||
* [Default parameters](./04_function.md#default-parameters)
|
||||
* [Del](./02_name.md#delete-an-variable)
|
||||
* [Dependent 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 record](./13_record.md#empty-record)
|
||||
* [Empty record](./14_record.md#empty-record)
|
||||
* [Enum class](./type/04_class.md#enum-class)
|
||||
* [Enum type](./type/11_enum.md)
|
||||
* [Enumerated, Interval and Refinement types](./type/12_refinement.md#enumerated-interval-and-refinement-types)
|
||||
* [error handling](./30_error_handling.md)
|
||||
* [error handling](./31_error_handling.md)
|
||||
* [Existential type](./type/advanced/existential.md)
|
||||
* [Exponential literal](./01_literal.md#exponential-literal)
|
||||
* [Extract assignment](./28_spread_syntax.md#extract-assignment)
|
||||
* [Extract assignment](./29_spread_syntax.md#extract-assignment)
|
||||
|
||||
### F
|
||||
|
||||
|
@ -148,14 +148,14 @@ Also, see [here](../terms.md) for terminology.
|
|||
* [Float object](./01_literal.md#float-object)
|
||||
* [for](./05_builtin_funcs.md#for)
|
||||
* [For-All patch](./type/07_patch.md#for-all-patch)
|
||||
* [freeze](./18_ownership.md#freeze)
|
||||
* [freeze](./19_ownership.md#freeze)
|
||||
* [Function](./04_function.md)
|
||||
* [Function definition with multiple patterns](./04_function.md#function-definition-with-multiple-patterns)
|
||||
|
||||
### G
|
||||
|
||||
* [GADTs(Generalized Algebraic Data Types)](./type/advanced/GADTs.md)
|
||||
* [Generator](./34_generator.md)
|
||||
* [Generator](./35_generator.md)
|
||||
* [Glue 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 block](./13_record.md#instant-block)
|
||||
* [Instant block](./14_record.md#instant-block)
|
||||
* [Instance/class 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 with Python](./32_integration_with_Python.md)
|
||||
* [Integration with Python](./33_integration_with_Python.md)
|
||||
* [Interval 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 function](./21_lambda.md)
|
||||
* lambda → [anonymous function](./22_lambda.md)
|
||||
* let-polymorphism → [rank 1 polymorphism]
|
||||
* [Literal Identifiers](./20_naming_rule.md#literal-identifiers)
|
||||
* [Literal Identifiers](./21_naming_rule.md#literal-identifiers)
|
||||
|
||||
### M
|
||||
|
||||
* [match]
|
||||
* match
|
||||
* [Marker 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 inheritance](type/05_inheritance.md#multiple-inheritance)
|
||||
* [Multi-layer (multi-level) Inheritance](type/05_inheritance.md#multi-layer-multi-level-inheritance)
|
||||
* [Mutable type](./type/18_mut.md)
|
||||
* [Mutable structure type](./type/advanced/mut_struct.md)
|
||||
* [Mutability](./17_mutability.md)
|
||||
* [Mutability](./18_mutability.md)
|
||||
|
||||
### N
|
||||
|
||||
* [Nat](./01_literal.md#int-literal)
|
||||
* [Never]
|
||||
* Never
|
||||
* [New type](./type/advanced/newtype.md)
|
||||
* [Heterogeneous Dict](./12_dict.md#heterogeneous-dict)
|
||||
* [Heterogeneous Dict](./11_dict.md#heterogeneous-dict)
|
||||
* None → [None Object]
|
||||
* [None Object]
|
||||
* None Object
|
||||
* Nominal 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 system](./18_ownership.md)
|
||||
* [ownership system](./19_ownership.md)
|
||||
* [Overloading](./type/advanced/overloading.md)
|
||||
* [Overriding](./type/05_inheritance.md#overriding)
|
||||
* [Override in 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 match](./26_pattern_matching.md)
|
||||
* [Pattern match](./27_pattern_matching.md)
|
||||
* [Phantom class](./type/advanced/phantom.md)
|
||||
* [pipeline operator](./31_pipeline.md)
|
||||
* [pipeline operator](./32_pipeline.md)
|
||||
* [Predicate](./type/19_bound.md#predicate)
|
||||
* [print!]
|
||||
* print!
|
||||
* [Procedures](./08_procedure.md)
|
||||
* [Projection type](./type/advanced/projection.md)
|
||||
* Python → [Integration with Python](./32_integration_with_Python.md)
|
||||
* Python → [Integration with Python](./33_integration_with_Python.md)
|
||||
|
||||
### Q
|
||||
|
||||
|
@ -251,15 +251,15 @@ Also, see [here](../terms.md) for terminology.
|
|||
### R
|
||||
|
||||
* [Range Object](./01_literal.md#range-object)
|
||||
* [ref]
|
||||
* [ref!]
|
||||
* [Record](./13_record.md)
|
||||
* ref
|
||||
* ref!
|
||||
* [Record](./14_record.md)
|
||||
* [Recursive functions](./04_function.md#recursive-functions)
|
||||
* [Refinement pattern](./type/12_refinement.md#refinement-pattern)
|
||||
* [Refinement type](./type/12_refinement.md)
|
||||
* [replication](./18_ownership.md#replication)
|
||||
* [replication](./19_ownership.md#replication)
|
||||
* [Replacing traits](./type/05_inheritance.md#replacing-traits-or-what-looks-like-it)
|
||||
* Result → [error handling](./30_error_handling.md)
|
||||
* Result → [error handling](./31_error_handling.md)
|
||||
|
||||
### S
|
||||
|
||||
|
@ -269,9 +269,9 @@ Also, see [here](../terms.md) for terminology.
|
|||
* [Shared reference](./type/advanced/shared.md)
|
||||
* [side-effect](./07_side_effect.md)
|
||||
* [Smart cast](./type/12_refinement.md#smart-cast)
|
||||
* [Spread assignment](./28_spread_syntax.md)
|
||||
* [Spread assignment](./29_spread_syntax.md)
|
||||
* [special type variables](./type/advanced/special.md#special-type-variables)
|
||||
* [Stack trace](30_error_handling.md#stack-trace)
|
||||
* [Stack trace](./31_error_handling.md#stack-trace)
|
||||
* [Structure type](./type/01_type_system.md#structure-type-anonymous-type)
|
||||
* [Structural patch](./type/07_patch.md#structural-patch)
|
||||
* [Structural trait](./type/03_trait.md#structural-traits)
|
||||
|
@ -282,17 +282,17 @@ Also, see [here](../terms.md) for terminology.
|
|||
* [Subtyping of subroutines](./type/16_subtyping.md#subtyping-of-subroutines)
|
||||
* [Subtype specification](./type/02_basic.md#subtype-specification)
|
||||
* [Subtyping of polymorphic function types](./type/15_quantified.md#subtyping-of-polymorphic-function-types)
|
||||
* [Subroutine signatures](./22_subroutine.md)
|
||||
* [Subroutine signatures](./23_subroutine.md)
|
||||
|
||||
### T
|
||||
|
||||
* [Test](./29_decorator.md#test)
|
||||
* [Test](./30_decorator.md#test)
|
||||
* [Traits](./type/03_trait.md)
|
||||
* [Trait inclusion](./type/03_trait.md#trait-inclusion)
|
||||
* True → [Boolean object](./01_literal.md#boolean-object)
|
||||
* [True algebraic type](./type/13_algebraic.md#true-algebraic-type)
|
||||
* [Type]
|
||||
* [type](./15_type.md)
|
||||
* Type
|
||||
* [type](./16_type.md)
|
||||
* [Type arguments in method definitions](./type/15_quantified.md#type-arguments-in-method-definitions)
|
||||
* [Type bound](./type/19_bound.md)
|
||||
* [Type definitions](./type/01_type_system.md#type-definitions)
|
||||
|
@ -301,12 +301,12 @@ Also, see [here](../terms.md) for terminology.
|
|||
* [Type specification](./type/02_basic.md#type-specification)
|
||||
* [Type system](./type/01_type_system.md)
|
||||
* [Type 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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue