Thursday, July 06, 2006
Indexing clauses and syntax errors
EiffelStudio supports an extension that allows multiple indexing clauses within an Eiffel class. You can have one at the top of the class, plus one at the bottom of the class, and you can also write an indexing clause for any feature of the class.
This can lead to a syntax error, which has become a "Frequently Asked Question" over on the es-devel mailing list. Consider the following code:
The compiler can't tell, and it throws a syntax error. You can fix this with a judiciously-placed semicolon, for example:
ECMA Eiffel does not have this ambiguity, because it does not support the "indexing" clause. Instead, it supports the "Notes" construct, which uses the "note" keyword. This construct can appear at the top or bottom of a class, but not with a feature.
This can lead to a syntax error, which has become a "Frequently Asked Question" over on the es-devel mailing list. Consider the following code:
How does the compiler know whether this indexing clause is the "end-of-class" indexing clause, or the one associated with the attribute 'test'?class A
...
feature -- Test
test: ANY
-- Test
indexing
...
end -- class A
The compiler can't tell, and it throws a syntax error. You can fix this with a judiciously-placed semicolon, for example:
Now, the indexing clause is taken to be the "end-of-class" indexing clause.class A
...
feature -- Test
test: ANY;
-- Test
indexing
...
end -- class A
ECMA Eiffel does not have this ambiguity, because it does not support the "indexing" clause. Instead, it supports the "Notes" construct, which uses the "note" keyword. This construct can appear at the top or bottom of a class, but not with a feature.
Comments:
<< Home
Note that `Note' did not make it into features in this first revision of standard to accomadate some other Eiffel compilers. But will most likely make it at some point.
Post a Comment
<< Home