« Collections in Base Language | Main | 90 minutes' DSL challenge! »

December 11, 2006

Collections in Base Language [2]

In his comments to my previous post (thanks for comments BTW) respected Prashant Deva expressed cautious doubts that collections language doesn't offer improvements over using of Java/C# collections.
Since that I’ve got more experience in using of our collections language and can say that sometimes they DO offer improvements over Java, and may be even over C# collections.
I can show an example.
It is real description of custom auto-completion menu of one of the node editor’s cell.

collections_usage.PNG

In the 1st line I got all languages from input model (the 1st line is next to the "parameter objects : ...." caption).
In the 2nd line I got all structure-models from those languages.
And finally, in the 3d line I got all concepts declared in those structure-models.

Isn’t it beautiful?

Posted by Igor Alshannikov at December 11, 2006 04:20 AM

Comments

Is it possible to filter elements of collection, so that only elements for which certain condition is true are left?

I mean, having such a statement instead of of foreach.. if... yield would make it even more beatiful (=more declarative?)

Something like "elements in [roots] matching [isInstanceOf (ConceptDeclaration)]"

Posted by: Igor Karpov at January 9, 2007 05:16 PM

Yes, there is 'where' operation which allows to filter input sequence.
But, it isn't applicable in the case above because we have sequence of models on input and need to produce sequence of nodes.
Each input element will result in 0, 1 or more output elements while the 'where' operation can only map an input element to 0 or 1 output element.

Posted by: Igor Alshannikov at January 15, 2007 07:08 PM

Post a comment




Remember Me?