I&#39;m having problems with duplicate definition for identifier errors when using modules.<div><br></div><div>I have a small DSL for defining some data that looks a bit like this:</div><div><br></div><div>(mission 20 rendezvous<br>
</div><div>&nbsp;&nbsp; &nbsp;person &quot;Jimmy&quot;</div><div>&nbsp;&nbsp; &nbsp;place &quot;beach&quot;)</div><div><br></div><div>(mission 21 deliver</div><div>&nbsp;&nbsp; &nbsp;item &quot;peanuts&quot;</div><div>&nbsp;&nbsp; &nbsp;person &quot;Boris&quot;)</div><div><br></div>
<div><br></div><div>The DSL code sits in one file and is loaded by the scheme file which implements the DSL. To implement this DSL, I have a macro for defining mission types which allows me to&nbsp;do this:</div><div><br></div>
<div>(module mission-dsl scheme</div><div>.</div><div>.</div><div>.</div><div>(define-mission-type rendezvous</div><div>&nbsp;&nbsp; &nbsp;(person &lt;string&gt;)</div><div>&nbsp;&nbsp; &nbsp;(place &lt;string&gt;))</div><div><br></div><div>(define-mission-type deliver</div>
<div>&nbsp;&nbsp; &nbsp;(item &lt;string&gt;)</div><div>&nbsp;&nbsp; &nbsp;(person &lt;string&gt;))</div><div>.</div><div>.</div><div>.)</div><div><br></div><div>This expands to something like this:</div><div><br></div><div>(define rendezvous (lambda (num . args)</div>
<div>&nbsp;&nbsp; &nbsp; ;; Code for constructing fields from arg list based on</div><div>&nbsp;&nbsp; &nbsp; ;; type constructor in mission type definition</div><div>&nbsp;&nbsp; &nbsp; ...))</div><div><br></div><div>;; These are required so the person defining the missions in the DSL does not need to explicitly quote the field names</div>
<div>(define person &#39;person)</div><div>(define place &#39;place)</div><div><br></div><div>(define deliver (lambda (num . args) ...))</div><div><br></div><div>(define item &#39;item)</div><div>(define person &#39;person) ;; &lt;== ERROR: duplicate definition for identifier at: person in: (define-values (person) (quote person))</div>
<div><br></div><div><br></div><div><br></div><div>So, Im wondering if there&#39;s a way to get around these duplicate definitions, maybe by checking if the identifier is bound in the define-mission-type macro before trying to define it, ie have this:</div>
<div><br></div><div><div>(define-mission-type rendezvous</div><div>&nbsp;&nbsp; &nbsp;(person &lt;string&gt;)</div><div>&nbsp;&nbsp; &nbsp;(place &lt;string&gt;))</div></div><div><br></div><div>expand to this:</div><div><br></div><div>(define rendezvous (lambda (num . args)</div>
<div>&nbsp;&nbsp; &nbsp; ...))</div><div><br></div><div>(if (unbound? &#39;person) (define person &#39;person)) &nbsp;;; There is no unbound? function</div><div>(if (unbound? &#39;place) (define place &#39;place))</div><div><br></div><div><br>
</div><div><br></div><div>Ive looked for a way to do this, but haven&#39;t found anything. I really want to keep the DSL as simple as possible to make it easier for the person writing in it (not a programmer). This means, if at all possible, not having to prefix the field names with the mission type, and not having to quote the field names.</div>
<div><br></div><div>Any help would be appreciated</div><div><br></div><div>Sincerely</div><div>Killian</div>