Streams
Posted: Fri Nov 28, 2008 1:36 pm
I have added streams to the language. Instead of saying IEnumerable<of T> you can say T* as in int*, String*, etc. This feature comes from the Comega language.
-- Streams are portable between backends, whereas .NET's IEnumerable<of> and JVM's Iterable<of> are not.
-- Streams are two-way compatible with IEnumerable/Iterable:
---- Streams can be used whereever a compatible IEnumerable/Iterable is expected.
---- An IEnumerable/Iterable can be used whereever a compatible stream type is expected.
---- The term "compatible" means the same inner type: int* is compatible with IEnumerable<of int>/Iterable<of int>, but not IEnumerable<of String>/Iterable<of String>
-- However, compatibility does not mean that you can use the methods of IEnumerable or Iterable, since these vary between platforms.
-- Streams are an abstract type, so you cannot create them directly with a call on the type such as `int*()`. Instead, use a concrete class such as `List<of>`, or `yield` results out of a method.
-- Streams are defaulted to be empty rather than nil.
-- You can look at the test cases online or via your workspace (which will be nice with syntax highlighting):
Tests/240-generics/500-misc/800-streams.cobra
Tests/240-generics/500-misc/810-streams-errors.cobra
If you have any questions or find any problems, let me know.
-- Streams are portable between backends, whereas .NET's IEnumerable<of> and JVM's Iterable<of> are not.
-- Streams are two-way compatible with IEnumerable/Iterable:
---- Streams can be used whereever a compatible IEnumerable/Iterable is expected.
---- An IEnumerable/Iterable can be used whereever a compatible stream type is expected.
---- The term "compatible" means the same inner type: int* is compatible with IEnumerable<of int>/Iterable<of int>, but not IEnumerable<of String>/Iterable<of String>
-- However, compatibility does not mean that you can use the methods of IEnumerable or Iterable, since these vary between platforms.
-- Streams are an abstract type, so you cannot create them directly with a call on the type such as `int*()`. Instead, use a concrete class such as `List<of>`, or `yield` results out of a method.
-- Streams are defaulted to be empty rather than nil.
-- You can look at the test cases online or via your workspace (which will be nice with syntax highlighting):
Tests/240-generics/500-misc/800-streams.cobra
Tests/240-generics/500-misc/810-streams-errors.cobra
If you have any questions or find any problems, let me know.