<div dir="ltr">Yeah, I agree it does make sense to do this kind of merging with examples like the one you posted or else you get very very bad performance in matching. And the merging is coming about because of the way the language is structured; it isn&#39;t accidental &quot;lucky&quot; merging; you expect the same productions to show up multiple times because of the way the grammars are constructed.<div>
<br></div><div style>Overall, I agree with you that this is a reasonable request. I would be happier if I could say that Redex&#39;s module language were anywhere close to being ready because if it were, there would be a better way to do this. But in the meantime, I think your extension is a good one. Your email suggests that you are unaffiliated but I think you&#39;re actually at Northeastern? Can someone there help you make this push? If not, I&#39;d be happy to do it.</div>
<div style><br></div><div style>Meanwhile, as to your Redex code, two points about reduction-semantics style: you should put both &quot;v&quot; and &quot;E&quot; into the extension not the originals: typically both concepts are a part of standard reduction. But, if you have a need of values in the original language, (for, say, defining Eval) then you should make it a separate non-terminal, not a production of &#39;e&#39;. In your specific example, you run into trouble if you want to make pair strict, since you want only (pair v v) in the v non-terminal, but (pair e e) in the e non-terminal. FWIW.</div>
<div style><br></div><div style>Robby</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 28, 2013 at 3:04 PM, William J. Bowman <span dir="ltr">&lt;<a href="mailto:wjb@williamjbowman.com" target="_blank">wjb@williamjbowman.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">By the way, when I was tinkering, I originally got my example working<br>
*without* merging nts (lines 1967-1983). I only added it after<br>
inspecting the output of `compiled-lang-lang&#39;. The resulting<br>
union-language had the same nonterminal in a language several times with<br>
overlapping right-hand-sides, so I merged them<br>
<div class="im HOEnZb"><br>
William Bowman<br>
<br>
On Thu, Feb 28, 2013 at 02:05:59PM -0600, Robby Findler wrote:<br>
</div><div class="HOEnZb"><div class="h5">&gt; The reason I didn&#39;t do that is very much related to lines 1967-1983 in your<br>
&gt; diff.<br>
&gt;<br>
&gt; That isn&#39;t a good idea: what you really want to do there is check to see if<br>
&gt; different patterns generate the same languages or not. But that&#39;s not<br>
&gt; something that is easily done (I&#39;m guessing it is computable, but very very<br>
&gt; expensive. It may not be computable, tho, for all I know.)<br>
&gt;<br>
&gt; One could allow unioning by just keeping all productions, and I guess I<br>
&gt; wouldn&#39;t mind an extension to define-union-language via a keyword that did<br>
&gt; that, tho.<br>
&gt;<br>
&gt; In your case, is there not a way to refactor your grammars so that you<br>
&gt; don&#39;t need this capability? Could you maybe make a small, representative<br>
&gt; example to post to the list? I find that kind of thing to be quite helpful<br>
&gt; for me to understand what the best change to Redex is.<br>
&gt;<br>
&gt; Robby<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Feb 28, 2013 at 1:46 PM, William J. Bowman<br>
&gt; &lt;<a href="mailto:wjb@williamjbowman.com">wjb@williamjbowman.com</a>&gt;wrote:<br>
&gt;<br>
&gt; &gt; Hello all,<br>
&gt; &gt;<br>
&gt; &gt; I&#39;ve been hacking on some languages in Redex, and found myself<br>
&gt; &gt; abstracting commons parts into base languages, and gradually building new<br>
&gt; &gt; languages via `define-extended-language&#39; and `define-union-language&#39;.<br>
&gt; &gt; Unfortunately, I hit a wall when I discovered `define-union-language&#39;<br>
&gt; &gt; doesn&#39;t like to union languages that define the same nonterminals.<br>
&gt; &gt;<br>
&gt; &gt; Consider this toy example: <a href="https://gist.github.com/bluephoenix47/5054403" target="_blank">https://gist.github.com/bluephoenix47/5054403</a><br>
&gt; &gt;<br>
&gt; &gt; This seems like a sensible thing to want to do, so I forked racket wrote a<br>
&gt; &gt; patch:<br>
&gt; &gt;<br>
&gt; &gt; <a href="https://github.com/bluephoenix47/racket/commit/0a7781b2be2643778f8d8d10d771ab1ce2dc622b" target="_blank">https://github.com/bluephoenix47/racket/commit/0a7781b2be2643778f8d8d10d771ab1ce2dc622b</a><br>
&gt; &gt;<br>
&gt; &gt; Unfortunately, several Redex tests fail (<a href="http://sprunge.us/fPHU" target="_blank">http://sprunge.us/fPHU</a>) because<br>
&gt; &gt; they expect an error when languages which define the same nonterminals<br>
&gt; &gt; are used in `define-union-language&#39;.<br>
&gt; &gt;<br>
&gt; &gt; Is this *desired* behavior? If so, why? It seems very reasonable to want<br>
&gt; &gt; to merge the nonterminals of languages.<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt;<br>
&gt; &gt; William J. Bowman<br>
&gt; &gt;<br>
&gt; &gt; _________________________<br>
&gt; &gt;   Racket Developers list:<br>
&gt; &gt;   <a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
</div></div></blockquote></div><br></div>