<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Typos corrected in Snooze 2.5.<div><br></div><div><blockquote type="cite">Cool, with that fix the only hitch I ran into was that the sqlite3</blockquote></div><div><blockquote type="cite">version of make-database seems to expect a path, and not a string as<br>the Quick Start suggests.<br></blockquote></div><div><br></div><div>I saw and fixed that one too. It turns out Jay has added support for in-memory and temporary-file databases to sqlite.plt as well, which is rather nice! Pass one of the following special paths to specify them:</div><div><br></div><div> (make-database ':memory:)</div><div> (make-database ':temp:)</div><div><br></div><div><blockquote type="cite"><blockquote type="cite">It's ugly but when I wrote the code I didn't know how to do it any other way<br></blockquote><blockquote type="cite">(suggestions for improvement would be much appreciated).<br></blockquote><br>I see, I've been thinking that it would be convenient for the<br>structure syntax to expand to dynamic structure information when used<br>as an expression. This is one place that would be useful.</blockquote></div><div><br></div><div>Sorry - this is going to make me look really dense. Does "as an expression" mean wrapping it in parentheses? If so I think I might have had the same or a similar idea. See below.</div><div><br></div><div><blockquote type="cite">This is more of a general question, not related to the quick start, so<br>I guess the list is still the right place. Is there a way to avoid<br>having two sets of names for each data type? I can see that person1 is<br>used to prevent the names from conflicting with the structure<br>accessors, but it's confusing to have to remember the differences<br>between person and person1.<br></blockquote><br></div><div>This has always bugged me.</div><div><br></div><div>I've been working on an SQL language for Mirrors, to give people the ability to create SQL without all the ERA trappings of Snooze. I thought about this problem again and I came up with a tentative solution.</div><div><br></div><div>The Mirrors language as it stands will have a define-table macro, which is basically like define-persistent-struct:</div><div><br></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px;"> (define-table person</span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px;"> ([name ...]</span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px;"> [age ...]))</span></font></div><div><br></div><div>One you have defined a table, you can access the run-time metadata using the identifier without parentheses:</div><div><br></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px;"> (table-name person) ; ==> symbol</span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px;"> (table-columns person) ; ==> (listof column)</span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px;"> ; and so on ...</span></font></div><div><br></div><div><div>but if you use my-table with parentheses, you get what is effectively an alias for use in queries:</div><div><br></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px;"> (person) ; ==> table-alias</span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px;"> (person name) ; ==> column-alias</span></font></div><div><br></div><div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px; "> (sql (select #:from (my-table)))</span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div></div><div><div>You still have access to define-alias if you need to reference two instances of a table in a single query:</div><div><br></div><div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px; "> (define-alias my-table-1 my-table)</span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px; "> (sql (select #:from (outer my-table my-table-1)))</span></font></div><div><br></div></div></div><div>This is obviously a bit cryptic but it does solve a number of problems:</div><div><br></div><div> - you don't have to use define-alias unless you want to alias a table twice within the same query;</div><div> - you have a default alias you can rely on when constructing queries from code spread across several modules;</div><div> - all the aliases for a table and its columns come from a single identifier, making them easier to provide/require.</div><div><br></div><div>What do you think?</div></div><div><br></div><div>-- Dave</div><div><br></div></body></html>