Change interface prefix from ? to ~

? will eventually be used in place of * to denote an optional
pointer, and ~ already means "approximation", which works well for
a polymorphic data structure.
This commit is contained in:
Sasha Koshka 2024-02-08 04:10:11 -05:00
parent cb7180fa1c
commit ba52a2df2e
3 changed files with 6 additions and 6 deletions

View File

@ -130,7 +130,7 @@ type TypeInterface struct {
}
func (*TypeInterface) ty(){}
func (this *TypeInterface) String () string {
out := "(?"
out := "(~"
for _, behavior := range this.Behaviors {
out += fmt.Sprint(" ", behavior)
}

View File

@ -7,7 +7,7 @@ testString (test,
// correct
`- BasicInt: Int
- Structure: (. x:Int y:Int)
- Interface: (? [aMethod x:Int]:*U8 [otherMethod arg:5:Int]:*U8)
- Interface: (~ [aMethod x:Int]:*U8 [otherMethod arg:5:Int]:*U8)
- Array: 16:16:16:Int
- StructArray: 31:24:340920:(. x:Int y:Int)
- String: *:U8`,
@ -17,7 +17,7 @@ BasicInt: Int
Structure: (.
x:Int
y:Int)
Interface: (?
Interface: (~
[aMethod x:Int]:*U8
[otherMethod arg:5:Int]:*U8)
Array: 16:16:16:Int

View File

@ -57,12 +57,12 @@ func (this *Parser) parseType () (entity.Type, error) {
case lexer.LParen:
err := this.expectNext(lexer.Dot, lexer.Symbol)
if err != nil { return nil, err }
err = this.expectValue(0, ".", "?", "|")
err = this.expectValue(0, ".", "~", "|")
if err != nil { return nil, err }
switch this.value() {
case ".": return this.parseTypeStructCore()
case "?": return this.parseTypeInterfaceCore()
case "~": return this.parseTypeInterfaceCore()
}
panic(this.bug())
}
@ -155,7 +155,7 @@ func (this *Parser) parseTypeStructCore () (entity.Type, error) {
}
func (this *Parser) parseTypeInterfaceCore () (entity.Type, error) {
err := this.expectValue(lexer.Symbol, "?")
err := this.expectValue(lexer.Symbol, "~")
if err != nil { return nil, err }
ty := &entity.TypeInterface {
Position: this.pos(),