[
Lists Home |
Date Index |
Thread Index
]
Ken North wrote:
>>What you say is quite impossible - maybe I am not clear enough:
>>the simple static analysis I am aiming at is made by the *Java
>>compiler*: correct syntax of the query, and possibly some type-checking.
>>This catches the "easily avoidable errors".
>>
>>
>
>My point is you can use the prepare step to validate the query. It's not compile
>time, but it's pre-execution.
>
>
>
...but doing this is completely left optional to the XQJ driver developers.
And it does not help the XQJ user much: the program has to be running,
e.g. the development database used for unit testing has to be up and
running...
>>Let us suppose you want to use such a tool: every abstract syntax tree
>>can be serialized to concrete syntax with no effort.
>>
>>
>
>Suppose I want to [build | buy ] a query logger, performance monitor, trace tool
>or query designer that's programmed in C++ or Visual Basic. It can process or
>generate XQuery strings, but it's unlikely to "understand" encrypted Java
>bytestreams.
>
>
>
Why, because Java uses UTF-16 ? I mean serialization to any format,
including concrete syntax (==XQuery string) in whatever format.
Here's a calculator language (for terseness, with alebraic datatype)
abstract class Term { def toNiceString; /* this one is virtual */}
class Var(x:String) { def toNiceString = "$"+x }
class Plus( t1:Term, t2:Term ) = { def toNiceString= t1.toNiceString + "
plus " + t2.toNiceString }
Serializing any instance t of Term happens by calling toNiceString.
We have just successfully serialized an abstract syntax tree.
We can look up the Visitor pattern from the Gang of Four book and
reimplement this without putting "def toNiceString" in all classes.
Every reasonable compiler or language-tool (or also XQuery stuff from
above) does pretty-printing in a way similar to this - a case
distinction on the structure of the term(or query or program). In
functional programming, you have a pattern match primitive built-in for
this kind of task.
Strings can be generated as easy as a anything. You can go and interpret
the stuff.
Most important, a user can build queries from typed building blocks at
runtime and hand it over to the driver, without using raw strings.
I really don't understand how one could possibly want anything else as
an interface for a domain-specific language.
cheers,
Burak
|