Commit b5e0cc7e authored by Robert Griesemer's avatar Robert Griesemer

- added language re: interface compparison using ==, !=

(seems not controversial)

R=r
DELTA=8  (3 added, 2 deleted, 3 changed)
OCL=16940
CL=16940
parent 900e076d
...@@ -54,7 +54,6 @@ Open issues: ...@@ -54,7 +54,6 @@ Open issues:
[ ] new(arraytype, n1, n2): spec only talks about length, not capacity [ ] new(arraytype, n1, n2): spec only talks about length, not capacity
(should only use new(arraytype, n) - this will allow later (should only use new(arraytype, n) - this will allow later
extension to multi-dim arrays w/o breaking the language) extension to multi-dim arrays w/o breaking the language)
[ ] comparison operators: can we compare interfaces?
[ ] like to have assert() in the language, w/ option to disable code gen for it [ ] like to have assert() in the language, w/ option to disable code gen for it
[ ] composite types should uniformly create an instance instead of a pointer [ ] composite types should uniformly create an instance instead of a pointer
[ ] semantics of statements [ ] semantics of statements
...@@ -85,6 +84,7 @@ Decisions in need of integration into the doc: ...@@ -85,6 +84,7 @@ Decisions in need of integration into the doc:
Closed: Closed:
[x] comparison operators: can we compare interfaces?
[x] can we add methods to types defined in another package? (probably not) [x] can we add methods to types defined in another package? (probably not)
[x] optional semicolons: too complicated and unclear [x] optional semicolons: too complicated and unclear
[x] anonymous types are written using a type name, which can be a qualified identifier. [x] anonymous types are written using a type name, which can be a qualified identifier.
...@@ -1348,7 +1348,7 @@ number of methods with the same names, and corresponding (by name) methods ...@@ -1348,7 +1348,7 @@ number of methods with the same names, and corresponding (by name) methods
have the same function types. have the same function types.
Assignment compatibility: A value can be assigned to an interface variable Assignment compatibility: A value can be assigned to an interface variable
if the static type of the value implements the interface. if the static type of the value implements the interface or if the value is "nil".
Expressions Expressions
...@@ -1810,8 +1810,7 @@ Comparison operators ...@@ -1810,8 +1810,7 @@ Comparison operators
Comparison operators yield a boolean result. All comparison operators apply Comparison operators yield a boolean result. All comparison operators apply
to strings and numeric types. The operators "==" and "!=" also apply to to strings and numeric types. The operators "==" and "!=" also apply to
boolean values and to pointer types (including the value "nil"). Finally, boolean values, pointer and interface types (including the value "nil").
"==" and "!=" can also be used to compare interface types against "nil".
== equal == equal
!= not equal != not equal
...@@ -1822,7 +1821,9 @@ boolean values and to pointer types (including the value "nil"). Finally, ...@@ -1822,7 +1821,9 @@ boolean values and to pointer types (including the value "nil"). Finally,
Strings are compared byte-wise (lexically). Strings are compared byte-wise (lexically).
Interfaces can be tested against "nil" (§Interface types). Pointers are equal if they point to the same value.
Interfaces are equal if both their dynamic types and values are equal.
For a value "v" of interface type, "v == nil" is true only if the predeclared For a value "v" of interface type, "v == nil" is true only if the predeclared
constant "nil" is assigned explicitly to "v" (§Assignments), or "v" has not constant "nil" is assigned explicitly to "v" (§Assignments), or "v" has not
been modified since creation (§Program initialization and execution). been modified since creation (§Program initialization and execution).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment