Skip to content

Commit b98fd73

Browse files
committed
delete description about trait from documents
1 parent f4fccd9 commit b98fd73

File tree

2 files changed

+0
-92
lines changed

2 files changed

+0
-92
lines changed

doc/4_godelscript_language.en.md

-46
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
- [Statements](#statements)
1111
- [Schema](#schema)
1212
- [Database](#database)
13-
- [Trait](#trait)
1413
- [Import](#import)
1514
- [Query](#query)
1615
- [Ungrounded Error: Unassigned/Unbound Error](#ungrounded-error-unassignedunbound-error)
@@ -59,7 +58,6 @@ A GödelScript program may include:
5958
- [Module and symbol import statements](#import)
6059
- [Schema type declarations](#schema)
6160
- [Database type declarations](#database)
62-
- [Trait declarations](#trait)
6361
- [Method implementations](#method-implementation)
6462
- [Function declarations and implementations](#function)
6563
- [Query declarations](#query)
@@ -87,18 +85,6 @@ database NewDB {
8785
file: *File
8886
}
8987

90-
// Trait declaration
91-
trait FileTrait {
92-
fn getId(self) -> int;
93-
}
94-
95-
// Impl trait for
96-
impl FileTrait for File {
97-
fn getId(self) -> int {
98-
return self.id
99-
}
100-
}
101-
10288
// Impl
10389
impl File {
10490
@data_constraint
@@ -786,38 +772,6 @@ fn getAnnotation() -> Annotation {
786772
}
787773
```
788774

789-
### Trait
790-
791-
#### Trait Declaration
792-
793-
The syntax for declaring a `trait` is as follows:
794-
795-
```rust
796-
trait Example {
797-
fn getId(self) -> int;
798-
fn getName(self) -> string;
799-
fn getValueByName(self, name: string) -> string;
800-
}
801-
```
802-
803-
#### Impl Trait
804-
805-
The syntax is similar to `impl`, but you must implement all the functions declared in the `trait` to pass compilation.
806-
807-
```rust
808-
impl Example for XmlElement {
809-
fn getId(self) -> int {return self.id}
810-
fn getName(self) -> int {return self.name}
811-
fn getValueByName(self, name: string) -> int {
812-
for(attr in XmlAttribute(XmlDB::load("...")) {
813-
if (attr.getName() = name && attr.id = self.getAttribute().id) {
814-
return attr.getValue()
815-
}
816-
}
817-
}
818-
}
819-
```
820-
821775
### Import
822776

823777
GödelScript uses the `use` keyword to import symbols from other files:

doc/4_godelscript_language.md

-46
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
- [语句](#语句)
1111
- [Schema](#schema)
1212
- [数据库](#数据库)
13-
- [Trait](#trait)
1413
- [Import](#import)
1514
- [Query](#query)
1615
- [Ungrounded Error: 未赋值/未绑定错误](#ungrounded-error-未赋值未绑定错误)
@@ -59,7 +58,6 @@ GödelScript 程序可能包含:
5958
- [模块和符号引用](#import)
6059
- [Schema 类型声明](#schema)
6160
- [数据库类型声明](#数据库)
62-
- [Trait 声明](#trait)
6361
- [Schema 方法实现](#方法实现)
6462
- [函数声明和实现](#函数)
6563
- [Query 声明](#query)
@@ -87,18 +85,6 @@ database NewDB {
8785
file: *File
8886
}
8987

90-
// trait 声明
91-
trait FileTrait {
92-
fn getId(self) -> int;
93-
}
94-
95-
// impl trait for
96-
impl FileTrait for File {
97-
fn getId(self) -> int {
98-
return self.id
99-
}
100-
}
101-
10288
// impl
10389
impl File {
10490
@data_constraint
@@ -786,38 +772,6 @@ fn getAnnotation() -> Annotation {
786772
}
787773
```
788774

789-
### Trait
790-
791-
#### Trait 声明
792-
793-
`trait`声明语法如下:
794-
795-
```rust
796-
trait Example {
797-
fn getId(self) -> int;
798-
fn getName(self) -> string;
799-
fn getValueByName(self, name: string) -> string;
800-
}
801-
```
802-
803-
#### Impl Trait
804-
805-
写法与`impl`类似,但是必须要将`trait`中声明的所有函数都实现出来,否则无法通过编译。
806-
807-
```rust
808-
impl Example for XmlElement {
809-
fn getId(self) -> int {return self.id}
810-
fn getName(self) -> int {return self.name}
811-
fn getValueByName(self, name: string) -> int {
812-
for(attr in XmlAttribute(XmlDB::load("...")) {
813-
if (attr.getName() = name && attr.id = self.getAttribute().id) {
814-
return attr.getValue()
815-
}
816-
}
817-
}
818-
}
819-
```
820-
821775
### Import
822776

823777
GödelScript 使用`use`关键字来引入其他文件的符号:

0 commit comments

Comments
 (0)