Re: RM and abstract syntax trees
Date: Thu, 01 Nov 2007 03:35:38 GMT
Message-ID: <eQbWi.164468$Da.12831_at_pd7urf1no>
David BL wrote:
> On Oct 31, 12:23 pm, paul c <toledobythe..._at_ooyah.ac> wrote:
>> David BL wrote: >> >> ... >> >>> Yes RM references things uniquely with values, but pointers are "value >>> types"! ... >> Sure, but what good does it do to think of them that way, when plain old >> "values" suffices?
>
> I guess I equate pointers with edges in a directed graph (where by
> directed graph I'm referring to the formalised notion of a set of
> nodes plus a set of directed edges between nodes), and naturally I
> regard an AST as an acyclic directed graph.
>
> Using Prolog notation, consider the following relations
>
> var(N,S) :- node N is a variable named S
> number(N,I) :- node N is a number with value I
> add(N,N1,N2) :- node N is the addition of nodes N1,N2
> mult(N,N1,N2) :- node N is the product of nodes N1,N2
>
> Suppose we define a view called nodes(N) which is a union of
> projections as follows
>
> nodes(N) :- var(N,_).
> nodes(N) :- number(N,_).
> nodes(N) :- add(N,_,_).
> nodes(N) :- mult(N,_,_).
>
> Note that I use underscores for attributes to be projected away.
>
> There are numerous integrity constraints. Each of the following SPJ
> queries must be empty.
>
> var(N,S1), var(N,S2), S1 <> S2?
> number(N,I1), number(N,I2), I1 <> I2?
> add(N,N1,_), add(N,N2,_), N1 <> N2?
> add(N,_,N1), add(N,_,N2), N1 <> N2?
> mult(N,N1,_), mult(N,N2,_), N1 <> N2?
> mult(N,_,N1), mult(N,_,N2), N1 <> N2?
> var(N,_), number(N,_)?
> var(N,_), add(N,_,_)?
> var(N,_), mult(N,_,_)?
> number(N,_), add(N,_,_)?
> number(N,_), mult(N,_,_)?
> add(N,_,_), mult(N,_,_)?
> add(_,N,_), not nodes(N)?
> add(_,_,N), not nodes(N)?
> mult(_,N,_), not nodes(N)?
> mult(_,_,N), not nodes(N)?
>
>>From these integrity constraints we can deduce that joins used to
> traverse down through the AST give us back precisely one tuple in the
> result set.
>
> Isn't it helpful to see the analogy with a pointer dereference?
>
> I'll leave it up to you as to whether you dislike the analogy between
> node identifiers and pointer values, and the idea that a join can be
> compared to a pointer dereference. Perhaps you are right and the
> analogy creates confusion.
>
> Anyway, what matters is whether RM is suited to representing ASTs. I
> find it significant that RM forces one to generate unique identifiers
> on all the nodes and exposes them for all to see, whereas LISP,
> Prolog and even C/C++ allow the user/programmer to work at a level of
> abstraction where node identifiers are hidden.
>
> I find it particularly telling that Prolog provides the choice of
> 1. using the approach above (which is how RM would be used); or
> 2. using nested terms, (which is outside of RM's scope)
> and the clear winner is 2.
>
>
>
Without claiming to understand everything you're saying, I just want to say this: Trying to use the RM to portray an AST seems unnecessarily [Quoted] adventurous to me. I would rather that smart people (not me, I'm a plodder) try to use the RM to address the same problem that AST's try to address, rather than trying to address AST's. For me, the former is like trying to translate Shakespeare into Latin, it might be possible but life seems too short to try and it seems more opportune to appraise the thought in the same language that is chosen to express it. I wish Codd had said more about problems of this sort, but I suppose he was very tied up trying to get people to understand how his approach handled much simpler problems. I met him once and he wasn't very tied up that day but I was even more ignorant then and couldn't think of any really provocative questions for him. From listening to him talk adhoc for half a day, I had the feeling that he was a lucky man, not only did he seem to have mastered his subject, but he had got to choose it in the first place. I'm still sure that he would have entertained such questions graciously if somebody in the audience had had the nous to pose them. The thing is, although he is not known as a great popular writer, his words do seem to me to transcend the usual techie gobbledygook that is so common today. Received on Thu Nov 01 2007 - 04:35:38 CET