[Versa] statements function

Uche Ogbuji uche.ogbuji at fourthought.com
Sat Sep 10 12:29:00 MDT 2005


On Fri, 2005-09-09 at 17:03 -0400, Chimezie Ogbuji wrote:
> > I think they both return a list of subjects that match.  The difference
> > being that the second would result with in an error or an empty result
> > if used as a scope.  You would need to rewrite the second to be
> > (assuming a result type optional argument to the filter function)
> 
> Okay.  and since the 'statements' function is the only way to
> construct statement objects so far, every context expression will have
> to be in the form:
> 
> { statements( ... ) }
> 
> Unless you allow the filter function to return a statement in the way
> your query demonstrates, but I think this is covered with the
> statements function:
> 
> { statements(type(rss:item)|-dc:creator-> <mailto:foo at yahoo.com>) }
> 
> > The query I would use would be
> > 
> > subgraph o1 = statements ( all() - rdfs:isDefiniedBy -> <Ontology
> > 1>,rdf:value,*);
> > subgraph o2 = statements ( all() - rdfs:isDefiniedBy -> <Ontology
> > 2>,rdf:value,*);
> > list( {o1}  all() |- * -> {o2}ground(.),
> >              {o2} all() |- * -> {o1}ground(.) )
>  
> or wouldn't those queries be statements ( all() |- rdfs:isDefiniedBy
> -> <Ontology1>,rdf:value,*)
> 
> if the statements function works the way I suggested?

I think I lost track somewhere.  Why put a traversal expression within
the statements function?  Why not just

statements(type(rss:item), dc:creator, <mailto:foo at yahoo.com>)

If I recall correctly, what we'd discussed is that each argument to the
function can be a pattern or a predicate?  A list is a pattern by
enumeration?

But we lose some of the functional power of traversal expressions if so.

type(rss:item) - ns:age -> gt(18)

No way to express this in statements() form as discussed so far.  One
approach would be to have currying:

statements(type(rss:item), dc:creator, curry(gt, 18))

But yeah right the average Versa punter will have that much comfort with
hard core functional language techniques such as currying.

I think this is a good time to bring up what I think is a need in Versa
for less clumsy first-class functions.

Right now functions such as distribute and filter can take a string and
basically cast it to a dynamic expression.  I think we should tie this
up more neatly.  For example:

filter(type(ns:Person), (!x: $x - ns:age -> gt(18))

Basically

anon-function ::= '(!' param-list ':' expr ')'

Or to give an example using the statements function:

statements(type(rss:item), dc:creator, (!x: $x - ns:age -> gt(18))

I prefer naming the parameter (functional macro-like) rather than using
the magic "." particle.  We also then get the flexibility of functions
with multiple parameters, etc.

Then again, I recall Chime thought even named functions were confusing.
Chime, what about the above anonymous function idea?

Personally, I find it a lot clearer that trying to read and interpret
the thicket of quotes in a Versa ~1.0 distribute call.


-- 
Uche Ogbuji                               Fourthought, Inc.
http://uche.ogbuji.net                    http://fourthought.com
http://copia.ogbuji.net                   http://4Suite.org
Use CSS to display XML, part 2 - http://www-128.ibm.com/developerworks/edu/x-dw-x-xmlcss2-i.html
XML Output with 4Suite & Amara - http://www.xml.com/pub/a/2005/04/20/py-xml.html
Use XSLT to prepare XML for import into OpenOffice Calc - http://www.ibm.com/developerworks/xml/library/x-oocalc/
Schema standardization for top-down semantic transparency - http://www-128.ibm.com/developerworks/xml/library/x-think31.html



More information about the Versa mailing list