<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">No, I’m not sure, but I strongly suspect that optima isn’t the right tool for my job.<br><div><br></div><div>My use-case is a macro I’m trying to write called DEFINE-RELATION, which, as one might suspect from a macro with this name, defines relations between instances of classes.  For example:</div><div><br></div><div>(define-relation window <-> layout)</div><div><br></div><div>This means that every instance of a WINDOW is associated with an instance of a LAYOUT, and vice versa.</div><div><br></div><div>But not every relation can be defined simply by the classes.  For example, one might want to define familial relationships among people:</div><div><br></div><div>(define-relation person as father <->> person as child)</div><div><br></div><div>This means that a single instance of a PERSON in the role of a father is associated with multiple instances of PERSON in the role of a child.</div><div><br></div><div>or…</div><div><br></div><div>(define-relation person as manager <->> person as employee)</div><div>(define-relation person as owner <->> animal as pet)</div><div>(define-relation person as owner <->> rock as pet)</div><div>(define-relation person as owner <->> rock as weapon)</div><div><br></div><div>The “pattern” is naturally expressed as a regex:</div><div><br></div><div>(define-class ($class (:optional as $role)) (:or <-> <->> <<-> <<->>) ($class2 (:optional as $role2)))</div><div><br></div><div>I don’t see how to express this sort of thing in optima without enumerating all the possible cases, which rather defeats the purpose (one might as well just write a little parser at that point).</div><div><br></div><div>Then I want to be able to say things like this:</div><div><br></div><div>(define-relation user <->> time-period <->> goal)</div><div><br></div><div>which means that a user is associated with multiple time periods, and that each user-time-period pair is in turn associated with a number of goals.</div><div><br></div><div>This generalization is easily expressed as a minor tweak to the above regex:</div><div><br></div><div>(define-class ($class (:optional as $role)) (:one-or-more (:or <-> <->> <<-> <<->>) ($classN (:optional as $roleN))))</div><div><br></div><div>but AFAICT this is entirely beyond what optima can do.</div><div><br></div><div>rg</div><div><div><br><div><div>On Mar 19, 2014, at 2:40 AM, Hans Hübner <<a href="mailto:hans.huebner@gmail.com">hans.huebner@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Ron,<div><br></div><div>are you sure that a general-purpose pattern matching library like Optima (<a href="https://github.com/m2ym/optima">https://github.com/m2ym/optima</a>) would not be better than a generalized regular expression matching library for what you need to do?</div>

<div><br></div><div>-Hans</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-03-19 1:15 GMT+01:00 Ron Garret <span dir="ltr"><<a href="mailto:ron@flownet.com" target="_blank">ron@flownet.com</a>></span>:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The theory of regular expressions can be applied to any kind of sequence, not just strings.  This would be potentially useful for pattern-matching applications, where current approaches make it very cumbersome to say things like, “Match a list containing between three and five integers”.  This sort of thing is easy to express in CL-PPCRE tree-like notation as, e.g. (:repetition (:type integer) 3 5)<br>


<br>
My question is: how hard would be it be to adapt the CL-PPCRE code to handle things like this?  Is there a sequence-type-agnostic core in CL-PPCRE that could be easily re-used for this purpose, or is the assumption that regexps only apply to strings woven deeply into the code?<br>


<br>
Thanks,<br>
rg<br>
<br>
</blockquote></div><br></div>
</blockquote></div><br></div></div></body></html>