[plt-scheme] Errors from Snooze Quick Start

From: Henk Boom (lunarc.lists at gmail.com)
Date: Tue Jan 6 19:45:10 EST 2009

2009/1/6 Dave Gurnell <d.j.gurnell at gmail.com>:
> Typos corrected in Snooze 2.5.


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

I actually meant without the parentheses. I've never tried this, but
I'm under the impression that this can be done with

> This has always bugged me.
> 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.
> The Mirrors language as it stands will have a define-table macro, which is
> basically like define-persistent-struct:
>   (define-table person
>     ([name ...]
>      [age  ...]))
> One you have defined a table, you can access the run-time metadata using the
> identifier without parentheses:
>   (table-name person)    ; ==> symbol
>   (table-columns person) ; ==> (listof column)
>   ; and so on ...
> but if you use my-table with parentheses, you get what is effectively an
> alias for use in queries:
>   (person)               ; ==> table-alias
>   (person name)          ; ==> column-alias
>   (sql (select #:from (my-table)))

That could work, but why not allow the use of the accessors directly?
It seems that that would be much simpler.

> You still have access to define-alias if you need to reference two instances
> of a table in a single query:
>   (define-alias my-table-1 my-table)
>   (sql (select #:from (outer my-table my-table-1)))
> This is obviously a bit cryptic but it does solve a number of problems:
>   - you don't have to use define-alias unless you want to alias a table
> twice within the same query;
>   - you have a default alias you can rely on when constructing queries from
> code spread across several modules;
>   - all the aliases for a table and its columns come from a single
> identifier, making them easier to provide/require.
> What do you think?

I agree on all counts. The flipside of your last point, though, is
that it becomes hard to export only certain parts of the alias. I
can't think of a situation where you would want to export the alias
without also exporting the corresponding accessors.

Thanks for listening =)

Posted on the users mailing list.