Hi,

earlier today I was wondering about the best way to write some
Transact-SQL code. I normally write code in C#, Python and lately
Clojure. Even though TSQL is a decent procedural extension to SQL, it
still feels very cumbersome to the languages I use daily. Having done
some C# code generation lately (using ScriptTemplate), I was thinking
about doing the same thing for SQL.

At which point I remembered Scriptjure (and Parenscript) and thought
about writing something similar for TSQL.

Google didn't reveal any already written such generators - I guess
I'll have to come up with one, which I expect to be kind of fun.

The bigger question is, why isn't this way (generate a Lisp
datastructure that describes in a convenient way the syntax tree of
the code to emit, then emit the actual code by walking the
datastructure) of abstracting away syntax problems in programming
languages more common? I can understand why it's not available for C#
- losing code completion is a big disadvantage, but what about (T)SQL
and others? Or it is actually an often used trick, but the tools used
are written 'in-house' and not made public?

I'll be very grateful for any input on the pros and cons of such an approach.

The pros I see are the ability to construct the data structure using
all the tools Clojure/Lisp offer in this area (quasiquotation and its
many friends, for instance). The ability to output code that is pretty
printed in a customized way is also a big plus (I care a great deal
about the readability of the generated code). Also, the SQL flavor
could be a pretty printing parameter - thus making it possible to
write code that will run on many RDBMSs - but I'm not very hopeful
about this, as differences between SQL dialects often go beyond
syntax.

Cons: I'm afraid of getting the SQL generating syntax wrong and making
the data structures used for generation ugly. But I guess that can be
fixed by iterating a little. :-)

Thanks,
-- 
Miron Brezuleanu

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to