Re: LISPPA

From: Alexander Baranovsky (ab_at_cable.netlux.org)
Date: 04/27/04


Date: 26 Apr 2004 22:51:23 -0700


> The abstract mathematical definition doesn't cope too well
> when you start having structures that are both mutable and
> sharable.
>
> a := [1,2]
> b := [a,a]
> a[0] := 99
>
> I do not believe it is possible to give a coherent account
> of what's going on here without some concept that's basically
> equivalent to that of "pointers" or "references". (The
> latter term may be better because it doesn't have the same
> associations of pointer *arithmetic* as in C.)

Your example seems to be slightly unnatural. Indeed, there are no
programming languages which do not allow to write bad programs, each
programming language has own style of programming (I mean a set of
base ideas and techniques), to follow this style means to avoid many
problems. For example, good style of imperative programming suppose
the replacement number constants with symbolic constants. As for the
sharable structures, it is necessary to avoid them (it if it is
possible, of course). But how these things contradict the "functional"
definition of array? :-)

> > So, you mix concepts of "definition" and "implementation".
> >
> > Next, the "psychological analysis". The equivalence "array elements"
> > and "pointers" come from the C language. This point of view already
> > has been mentioned in this thread a few times.
>
> Firstly, the equivalence C sort-of makes is between *arrays*
> and pointers, not between *array elements* and pointers.

Accepted, my erratum.

> Indeed, the fact that C and C++ treat an array of "struct foo"
> objects as actually *containing* the structures rather than
> references to them (and likewise for other kinds of container
> other than arrays) is, I think, responsible for a substantial
> amount of the pain associated with writing complicated programs
> in those languages.

> (That's not to say that it's entirely bad that C and C++
> do that; for some purposes it's a very good thing.)

Very good question. Indeed, why "ugly" pointers do not prevent C
language be very attractive for programmers? There are many reasons,
but the most important for me is that C provides a possibility to
write concise algorithmes for wide set of problems of low-level
programming. For example:

while ((*s++ = *t++) != '\0');

I'm trying to provide concise and uniform algorithmes and minimal set
of concepts for the working with dynamic data structures in a
high-level language. I sure, the brevity determines style of
programming, if you have have concise patterns and follow the style,
you will able to write effective and free-of-bugs programs.

A.

Gareth McCaughan <gareth.mccaughan@pobox.com> wrote in message news:<87isfmv5l8.fsf@g.mccaughan.ntlworld.com>...
> Alexander Baranovsky wrote:
>
> > According to the Hoare's theory, array is just a function defined on a
> > finite set of indexes (the domain) into a set of values (image). The
> > polymorphic array is the array in Hoare's sense with the following
> > specification: the image is a set defined recursively, so elements of
> > the set are primitive values (null, numbers, strings, booleans) and
> > polymorphic arrays. You see this is a just abstract mathematics
> > definition without any relation to the "memory" or "pointers"
> > concepts.
>
> The abstract mathematical definition doesn't cope too well
> when you start having structures that are both mutable and
> sharable.
>
> a := [1,2]
> b := [a,a]
> a[0] := 99
>
> I do not believe it is possible to give a coherent account
> of what's going on here without some concept that's basically
> equivalent to that of "pointers" or "references". (The
> latter term may be better because it doesn't have the same
> associations of pointer *arithmetic* as in C.)
>
> Unless, of course, your LISPPA does a deep copy every time
> you write an assignment like those?
>
> > So, you mix concepts of "definition" and "implementation".
> >
> > Next, the "psychological analysis". The equivalence "array elements"
> > and "pointers" come from the C language. This point of view already
> > has been mentioned in this thread a few times.
>
> Firstly, the equivalence C sort-of makes is between *arrays*
> and pointers, not between *array elements* and pointers.
> Indeed, the fact that C and C++ treat an array of "struct foo"
> objects as actually *containing* the structures rather than
> references to them (and likewise for other kinds of container
> other than arrays) is, I think, responsible for a substantial
> amount of the pain associated with writing complicated programs
> in those languages.
>
> (That's not to say that it's entirely bad that C and C++
> do that; for some purposes it's a very good thing.)
>
> > I guess the reason of
> > it is that some Lisp users better informed about C language than
> > another imperative languages because some Lisp engines convert Lisp
> > programs into the C language programs. :-)
>
> I think it's enormously unlikely that more than the tiniest
> proportion of Lisp programmers use such compilers and pay
> the slightest attention to the C they output.
>
> > > Perhaps you can explain why you think polymorphic arrays have no
> > > relationship to memory and so on? Does this mean that you can't store
> > > things in polymorphic arrays?
> >
> > You forget, I'm speaking about a definition of array, not
> > implementation. If we are considering AI problems, we are speaking,
> > for example, that facts or clauses can be represented and processed as
> > polymorphic arrays. I do not see why arrays less suitable than linked
> > lists for it. Rather - contrary. Linked lists can be considered just
> > as a partial case of polymorphic array. Array is more preferable data
> > structure than linked list in view of effectivity of programming
> > (random access, reduced assignments instead of garbage collector,
> > iteration instead of recursion).
>
> I would be very sorry to lose either of them. Fortunately Lisp
> has them both natively and doesn't require one to be explicitly
> implemented on top of the other.



Relevant Pages

  • Re: C vs. C++
    ... comparing the languages as they tend to be used by a lot of people. ... std::vector instead of an array. ... I, for one, program in C++ but I prefer procedural programming a lot ...
    (comp.lang.c)
  • Re: execvp second argument question
    ... |> array is, lets say, 10, whilst the arguments are 2. ... Programmers of languages higher than ... But when programming in C, assembly, etc, for the ... If you have trouble understanding your perl code after two days, ...
    (comp.unix.programmer)
  • Re: A List of One.
    ... An array is often represented in memory as a single number that points ... If we want to retrieve the first item of the array, ... that's how arrays were implemented in many older programming ... languages, and still are in lower-level languages like C. Modern, ...
    (alt.html)
  • Re: A List of One.
    ... Javascript, for example, numbers the initial item in the images array (-and ... If we want to retrieve the first item of the array, ... that's how arrays were implemented in many older programming ... languages, and still are in lower-level languages like C. Modern, ...
    (alt.html)
  • Re: compiler for Chinese development language
    ... This relates to the development of vernacular ... Indian vernacular display, OS and programming languages. ... Bangla and other vernaculars. ...
    (comp.compilers)