[Versa] statements function

Michael Olson Mike.Olson at fourthought.com
Tue Sep 13 10:38:27 MDT 2005


>> { 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?

This is how I remember it.

>
> 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:
>

Right.  Is this supported in the current traverse function?

Though you would be able to express it as

statements( type (rss:item), ns:age, . > 18)



> 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.

I like this better then currying, though I don't see how you would  
specify an anon function with more then one parameter.  Maybe

( !x = ., !y = "foo" :  $x - ns:age -> gt($y)

and the default of (!x : query) would default "x" to the current  
context.

In the current grammar, I supported something similar to this with the  
reuse of the "{}" symbols.  It just did not support parameters.

Mike

>
> 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
>
> _______________________________________________
> Versa mailing list
> Versa at lists.fourthought.com
> http://lists.fourthought.com/mailman/listinfo/versa
>
------------------------------------------------------------------------ 
-----------------
Mike Olson                                                Principal  
Consultant
mike.olson at fourthought.com                +1 720 253 4662
Fourthought, Inc.                                       
http://Fourthought.com
PO Box 270590,                                       http://4Suite.org
Louisville, CO 80027-5009, USA
XML strategy, XML tools, knowledge management



More information about the Versa mailing list