From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: No Itisnt Newsgroups: gmane.lisp.guile.user Subject: Re: Data Dictionary and Configuration Files with Guile Scheme Date: Thu, 5 Aug 2010 16:04:46 -0500 Message-ID: References: <1281028544.2624.38.camel@romel-compaq> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1281042507 26680 80.91.229.12 (5 Aug 2010 21:08:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 5 Aug 2010 21:08:27 +0000 (UTC) Cc: guile-user@gnu.org To: Romel Sandoval Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Aug 05 23:08:25 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Oh7fr-0007yW-JB for guile-user@m.gmane.org; Thu, 05 Aug 2010 23:08:23 +0200 Original-Received: from localhost ([127.0.0.1]:41034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oh7fq-0006BK-IQ for guile-user@m.gmane.org; Thu, 05 Aug 2010 17:08:22 -0400 Original-Received: from [140.186.70.92] (port=44857 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oh7fA-0005H8-Og for guile-user@gnu.org; Thu, 05 Aug 2010 17:07:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oh7cN-0005S0-DQ for guile-user@gnu.org; Thu, 05 Aug 2010 17:04:48 -0400 Original-Received: from mail-qw0-f41.google.com ([209.85.216.41]:60619) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oh7cN-0005Rr-B3 for guile-user@gnu.org; Thu, 05 Aug 2010 17:04:47 -0400 Original-Received: by qwk4 with SMTP id 4so5049175qwk.0 for ; Thu, 05 Aug 2010 14:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=ATZ2F84GJ7OmrQl7xFrZYLKFkK3q1gZfNp25yBnNrZY=; b=VhbxauR+tDYe0ftOnvJ+fqmgSxr1yFYWV/WytWXlB2mQ/73LSb8qFH4w/rl+S8jwlu LuTPErtU2rLfsIxhoRvUeQtsH2evKHSZBv5JKv+XvaBrVaBlljcvCwoyCU9L/WvB4kqJ EQo1etP6MisSS8yFgQEovlFUoUfH0LazCz9ds= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=FIFX/4egjJx0TAbjrE+jsNDzLjHVZvvY/A3XI7jT0nDIIV880foDEmTeJKSUgNAk6B AigiRzd1+0QRNbiKcsMVu7PXV2CG9fYgkGk97SPUlFoaVPTOwSDQ+GDQEI9pxF+o+wuo HOYfHJznK+v11R/+GnksVVjrqOUINttDepQkU= Original-Received: by 10.224.28.195 with SMTP id n3mr5489563qac.107.1281042286355; Thu, 05 Aug 2010 14:04:46 -0700 (PDT) Original-Received: by 10.229.38.85 with HTTP; Thu, 5 Aug 2010 14:04:46 -0700 (PDT) In-Reply-To: <1281028544.2624.38.camel@romel-compaq> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8054 Archived-At: I would use records instead of lists. I think you can also make the input much simpler, for instance it might look like this: (define-table projects (integer id primary-key) (string name non-null #:length 32)) On Thu, Aug 5, 2010 at 12:15 PM, Romel Sandoval wrote: > Hi, > > I'm trying to create a data dictionary [1] to generate code from it. But > since I'm a scheme newbie I was wondering if this is the best method: > > {{{ > (define-syntax table > =A0(syntax-rules () > =A0 =A0((table name ...) > =A0 =A0 (list 'table name ...)))) > > (define-syntax column > =A0(syntax-rules () > =A0 =A0 =A0 =A0((column name ...) > =A0 =A0 =A0 =A0 (list 'column name ...)))) > > (define-syntax type > =A0(syntax-rules () > =A0 =A0 =A0 =A0((type symbol) > =A0 =A0 =A0 =A0 (cons 'type symbol)))) > > (define-syntax constraint > =A0(syntax-rules () > =A0 =A0 =A0 =A0((constraint symbol) > =A0 =A0 =A0 =A0 (cons 'constraint symbol)))) > > (define-syntax length > =A0(syntax-rules () > =A0 =A0 =A0 =A0((length value) > =A0 =A0 =A0 =A0 (cons 'length value)))) > > (define *projects-table* > =A0(table "projects" > =A0 =A0 =A0 =A0(column "id" > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(type 'integer) (constraint 'primary-key)) > =A0 =A0 =A0 =A0(column "title" > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(type 'string) (length 32) (constraint 'no= t-null)))) > }}} > > This way I can write s-exp as in the example *projects-table* an after a > load I will have the data structure ready to work with it. > > {{{ > scheme@(guile-user)> (load "dd.scm") > scheme@(guile-user)> *projects-table* > (table "projects" (column "id" (type . integer) (constraint . > primary-key)) (column "title" (type . string) (length . 32) > (constraint . not-null))) > }}} > > I think this could be a good way to define configuration files too. > > What do you think? > Exists better alternatives with Guile? > This mail should go to another list? :-) > > Regards, > > -- > Romel R. Sandoval-Palomo > > [1]http://database-programmer.blogspot.com/2008/06/using-data-dictionary.= html > > > > >