mirror of
https://github.com/golang/go
synced 2024-11-22 00:04:41 -07:00
- language for embedded interfaces (as discussed this morning)
- fixed a syntax error R=r DELTA=17 (15 added, 0 deleted, 2 changed) OCL=24876 CL=24889
This commit is contained in:
parent
52c02c2d5d
commit
38c232fe37
@ -1218,7 +1218,7 @@ types (§Types).
|
|||||||
|
|
||||||
StructType = "struct" [ "{" [ FieldDeclList ] "}" ] .
|
StructType = "struct" [ "{" [ FieldDeclList ] "}" ] .
|
||||||
FieldDeclList = FieldDecl { ";" FieldDecl } [ ";" ] .
|
FieldDeclList = FieldDecl { ";" FieldDecl } [ ";" ] .
|
||||||
FieldDecl = (IdentifierList CompleteType | TypeName) [ Tag ] .
|
FieldDecl = (IdentifierList CompleteType | [ "*" ] TypeName) [ Tag ] .
|
||||||
Tag = StringLit .
|
Tag = StringLit .
|
||||||
|
|
||||||
// An empty struct.
|
// An empty struct.
|
||||||
@ -1387,7 +1387,7 @@ the set of methods specified by the interface type, and the value "nil".
|
|||||||
|
|
||||||
InterfaceType = "interface" [ "{" [ MethodSpecList ] "}" ] .
|
InterfaceType = "interface" [ "{" [ MethodSpecList ] "}" ] .
|
||||||
MethodSpecList = MethodSpec { ";" MethodSpec } [ ";" ] .
|
MethodSpecList = MethodSpec { ";" MethodSpec } [ ";" ] .
|
||||||
MethodSpec = IdentifierList Signature .
|
MethodSpec = IdentifierList Signature | TypeName .
|
||||||
|
|
||||||
// An interface specifying a basic File type.
|
// An interface specifying a basic File type.
|
||||||
interface {
|
interface {
|
||||||
@ -1425,6 +1425,21 @@ If S1 and S2 also implement
|
|||||||
|
|
||||||
they implement the Lock interface as well as the File interface.
|
they implement the Lock interface as well as the File interface.
|
||||||
|
|
||||||
|
An interface may contain a type name T in place of a method specification.
|
||||||
|
T must denote another, complete (and not forward-declared) interface type.
|
||||||
|
Using this notation is equivalent to enumerating the methods of T explicitly
|
||||||
|
in the interface containing T.
|
||||||
|
|
||||||
|
type ReadWrite interface {
|
||||||
|
Read, Write (b Buffer) bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
type File interface {
|
||||||
|
ReadWrite; // same as enumerating the methods in ReadWrite
|
||||||
|
Lock; // same as enumerating the methods in Lock
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
Forward declaration:
|
Forward declaration:
|
||||||
A interface type consisting of only the reserved word "interface" may be used in
|
A interface type consisting of only the reserved word "interface" may be used in
|
||||||
a type declaration; it declares an incomplete interface type (§Type declarations).
|
a type declaration; it declares an incomplete interface type (§Type declarations).
|
||||||
|
Loading…
Reference in New Issue
Block a user