Path: utzoo!attcan!uunet!mcsun!ukc!warwick!nott-cs!piaggio!anw From: anw@maths.nott.ac.uk (Dr A. N. Walker) Newsgroups: comp.lang.misc Subject: Re: C's sins of commission Message-ID: <1990Oct26.155937.29185@maths.nott.ac.uk> Date: 26 Oct 90 15:59:37 GMT References: <2062@aber-cs.UUCP> Reply-To: anw@maths.nott.ac.uk (Dr A. N. Walker) Organization: Maths Dept., Nott'm Univ., UK. Lines: 45 In article <2062@aber-cs.UUCP> pcg@cs.aber.ac.uk (Piercarlo Grandi) writes: >In article <1990Oct15.175924.14455@maths.nott.ac.uk> anw@maths.nott.ac.uk >(Dr A. N. Walker) writes: [ of a recursive pseudo-definition of regular graphs ] > Where does it all end, even lazily? > >Ahem. It does not end. There is no problem though. It is just an incorrect >definition. Let's rewrite it like this: [ gives syntactic definition of a graph ] Well, that's fine, and one way I might well do it myself, but it seems to be not the way that other people are telling me I ought to do it! > How do I express the identity of one node with another [ie, perhaps the > same node, but reached via some chain of edges]? How do I *draw* it? > >This is a thing on which I have already commented, but I love repeating >myself. The correct way to implement identity is by contents, not location. But why should I have to invent a contents, just so that I can avoid referring to location? If I draw a graph with lots of nodes, and put some information (perhaps a colour, RED, GREEN, BLUE, ...) in each, I don't necessarily want the contents to be unique. On the other hand, if I'm explaining my drawing to you, I can point to nodes: "Look, *this* node connects to *that*, and so there's a path from *here* to *there*". There's nothing wrong with location! > What is *anyone*'s objection to > > MODE NODE = STRUCT (INT info, REF NODE left, right, middle) ? > >That instead of manipulating just values of type NODE you also have >to deal with values of type REF NODE. This complicates life considerably. But in almost every programming language, in addition to values of type INT, I have to deal with values of type REF INT (integer variables in most languages). Yes, it complicates life, but it's usually thought to be worth it. Extending to REF REF INT (pointers), and other REF types, generalises and simplifies the construct. It's just a shame that so many programmers fail to appreciate this (often because their first language managed to muddy the waters). -- Andy Walker, Maths Dept., Nott'm Univ., UK. anw@maths.nott.ac.uk