Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Janis Papanagnou Newsgroups: comp.lang.c Subject: Re: Recursion, Yo Date: Mon, 15 Apr 2024 15:07:37 +0200 Organization: A noiseless patient Spider Lines: 82 Message-ID: References: <87edbestmg.fsf@bsb.me.uk> <_zSRN.161297$m4d.144795@fx43.iad> <20240411075825.30@kylheku.com> <20240413203303.000001f9@yahoo.com> <878r1grgn3.fsf@bsb.me.uk> <20240414032902.00003dc8@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Mon, 15 Apr 2024 15:07:38 +0200 (CEST) Injection-Info: dont-email.me; posting-host="7442213264ab8592460c4ec71b7997a1"; logging-data="323674"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18JU6TawT2h6fyQjzG0pSDp" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cancel-Lock: sha1:cv+By0BvO0Ch2s18fRbU4jX1XBo= X-Enigmail-Draft-Status: N1110 In-Reply-To: <20240414032902.00003dc8@yahoo.com> Bytes: 4599 On 14.04.2024 02:29, Michael S wrote: > On Sun, 14 Apr 2024 00:23:44 +0100 > Ben Bacarisse wrote: > >> Michael S writes: >> >>> On Sat, 13 Apr 2024 00:13:36 -0000 (UTC) >>> Lawrence D'Oliveiro wrote: >>> >>>> On Fri, 12 Apr 2024 14:35:47 +0200, Janis Papanagnou wrote: >>>> >>>>> It seems that's one of the fundamental differences between >>>>> (low-level) languages that want to provide such technical factors >>>>> explicit to the user and between languages that want to provide a >>>>> higher abstraction. >>>>> >>>>> Algol 60, Pascal, Simula 67 and Algol 60, Eiffel, etc. all took >>>>> that approach. >>>> >>>> Pascal had explicit pointers, though. Algol 68 and Ada did not. >>> >>> Of course, Ada has pointers. The are called access types. >>> https://en.wikibooks.org/wiki/Ada_Programming/Types/access >>> >>> I never learned Algol-68, but considering your reputation I'd want >>> to see confirmation from more reliable source. >> >> I suppose it all depends on what constitutes a pointer, but Algol 68 >> has pointers to this extent: >> >> BEGIN >> INT i := 42; >> [3] INT a := (1, 2, 3); >> >> REF INT p := i; CO p is a "pointer" to i >> CO REF INT(p) := 99; CO changes i via p >> CO p := a[2]; CO p now points to the second element of array a >> CO REF INT(p) := 99; CO change that element via p >> CO >> >> print((i, a[1], a[2], a[3])) >> END >> >> I'd call p a pointer. >> > > Thank you. > It looks closer to C than to Pascal, i.e. pointer can point to any > object rather than just to dynamically allocated object. The major difference is that they are closely bound to the type. In that respect they are more like Pascal pointers. C pointers open the can of issues with arithmetic on pointer values. You don't find that in Pascal or Algol 68. WRT 'REF' you have to understand that it's a sort of "technical" reference item that is used to link structures as pointers do. And besides that you also have allocators for stack or heap objects. You combine the two to get what you have in other languages. Usually you don't see the stack allocator because Algol 68 allows abbreviations to write only brief declarations what we also know from other programming languages. For example the following are the same INT a := 42; REF INT a = LOC INT := 42; It says that a is an integer 'REF' ("lvalue"), identical to a local (stack) item - where LOC is the generator -, and finally the value assigned. You can replace the 'LOC' by 'HEAP' if you want the heap generator to allocate the memory. For example HEAP INT a; REF INT a = HEAP INT; In Algol 68 (as in Pascal) these references are bound to the type (in the above examples to 'INT'). Janis