Skip to content

Commit

Permalink
delete description about trait from documents
Browse files Browse the repository at this point in the history
  • Loading branch information
ValKmjolnir committed May 15, 2024
1 parent f4fccd9 commit b98fd73
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 92 deletions.
46 changes: 0 additions & 46 deletions doc/4_godelscript_language.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
- [Statements](#statements)
- [Schema](#schema)
- [Database](#database)
- [Trait](#trait)
- [Import](#import)
- [Query](#query)
- [Ungrounded Error: Unassigned/Unbound Error](#ungrounded-error-unassignedunbound-error)
Expand Down Expand Up @@ -59,7 +58,6 @@ A GödelScript program may include:
- [Module and symbol import statements](#import)
- [Schema type declarations](#schema)
- [Database type declarations](#database)
- [Trait declarations](#trait)
- [Method implementations](#method-implementation)
- [Function declarations and implementations](#function)
- [Query declarations](#query)
Expand Down Expand Up @@ -87,18 +85,6 @@ database NewDB {
file: *File
}

// Trait declaration
trait FileTrait {
fn getId(self) -> int;
}

// Impl trait for
impl FileTrait for File {
fn getId(self) -> int {
return self.id
}
}

// Impl
impl File {
@data_constraint
Expand Down Expand Up @@ -786,38 +772,6 @@ fn getAnnotation() -> Annotation {
}
```

### Trait

#### Trait Declaration

The syntax for declaring a `trait` is as follows:

```rust
trait Example {
fn getId(self) -> int;
fn getName(self) -> string;
fn getValueByName(self, name: string) -> string;
}
```

#### Impl Trait

The syntax is similar to `impl`, but you must implement all the functions declared in the `trait` to pass compilation.

```rust
impl Example for XmlElement {
fn getId(self) -> int {return self.id}
fn getName(self) -> int {return self.name}
fn getValueByName(self, name: string) -> int {
for(attr in XmlAttribute(XmlDB::load("...")) {
if (attr.getName() = name && attr.id = self.getAttribute().id) {
return attr.getValue()
}
}
}
}
```

### Import

GödelScript uses the `use` keyword to import symbols from other files:
Expand Down
46 changes: 0 additions & 46 deletions doc/4_godelscript_language.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
- [语句](#语句)
- [Schema](#schema)
- [数据库](#数据库)
- [Trait](#trait)
- [Import](#import)
- [Query](#query)
- [Ungrounded Error: 未赋值/未绑定错误](#ungrounded-error-未赋值未绑定错误)
Expand Down Expand Up @@ -59,7 +58,6 @@ GödelScript 程序可能包含:
- [模块和符号引用](#import)
- [Schema 类型声明](#schema)
- [数据库类型声明](#数据库)
- [Trait 声明](#trait)
- [Schema 方法实现](#方法实现)
- [函数声明和实现](#函数)
- [Query 声明](#query)
Expand Down Expand Up @@ -87,18 +85,6 @@ database NewDB {
file: *File
}

// trait 声明
trait FileTrait {
fn getId(self) -> int;
}

// impl trait for
impl FileTrait for File {
fn getId(self) -> int {
return self.id
}
}

// impl
impl File {
@data_constraint
Expand Down Expand Up @@ -786,38 +772,6 @@ fn getAnnotation() -> Annotation {
}
```

### Trait

#### Trait 声明

`trait`声明语法如下:

```rust
trait Example {
fn getId(self) -> int;
fn getName(self) -> string;
fn getValueByName(self, name: string) -> string;
}
```

#### Impl Trait

写法与`impl`类似,但是必须要将`trait`中声明的所有函数都实现出来,否则无法通过编译。

```rust
impl Example for XmlElement {
fn getId(self) -> int {return self.id}
fn getName(self) -> int {return self.name}
fn getValueByName(self, name: string) -> int {
for(attr in XmlAttribute(XmlDB::load("...")) {
if (attr.getName() = name && attr.id = self.getAttribute().id) {
return attr.getValue()
}
}
}
}
```

### Import

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

0 comments on commit b98fd73

Please sign in to comment.