Re: OCL challenge



Date view Thread view Subject view Author view

Tony Simons (a.simons@dcs.shef.ac.uk)
Wed, 20 Dec 2000 10:56:18 +0000 (GMT)


Daniel, You're right in your supposition that, for some set-valued attribute p of an object x, the expression: x.p.q is really OCL shorthand for: x.p->collect(p : P | p.q) although I would prefer to distinguish x.p the set from p the iteration variable (I assume you rebind p in the iteration). The fundamental flaw in OCL in my view is that by semantically merging/confusing single-valued and set-valued access paths in expressions like x.p.q, this causes the knock-on problem that you cannot distinguish methods of elements from methods of sets. OCL "fixed" this by introducing a spurious syntactic distinction p->q to mean "the set's method" rather than p.q to mean "the result of mapping q over every element of the set p". This is a syntactic kludge to fix a more important semantic fault. I argued this case vociferously when OCL was being defined, and talked to the Dutch team who wrote the book. The counter-argument was that developers preferred the shorthand over having to use explicit mapping and filtering methods. I still don't think that's a good reason for kludgy semantics. A better example is Shipman's DAPLEX language for defining OO databases. In this, he distinguishes single-valued from multi-valued functions: father->age father->>children such that expressions like: father->>children->age have an implicit sense of mapping age over each child and collecting the set result. Here, the syntax difference reflects the semantic difference directly, unpacking each child in the returned set. The ->> had both the sense of visually indicating a set-valued result and of implicitly implying a "for all" quantification in the path expression. Since this was for databases, the results of queries were always either single objects, or flattened sets of objects. You could then use (my own suggestion here): father->children to refer to the SET explicitly, such that: father->children->size were instantly meaningful. OK, you OCL hackers, how about it then? --Tony ========================================================================== Dr Anthony J H Simons a.simons@dcs.shef.ac.uk Lecturer in Computer Science http://www.dcs.shef.ac.uk/~ajhs Director of Teaching Department of Computer Science tel: (+44) 114 22 21838 University of Sheffield dept: (+44) 114 22 21800 Regent Court, 211 Portobello Street fax: (+44) 114 22 21810 SHEFFIELD, S1 4DP univ: (+44) 114 22 22000 United Kingdom ==========================================================================


Date view Thread view Subject view Author view