Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

This place just isn't big enough for all of us. We've got to find a way off this planet.


devel / comp.lang.forth / Re: Confusion about pointers in c/cc

SubjectAuthor
* Confusion about pointers in c/ccalbert
+- Re: Confusion about pointers in c/ccminforth
`* Re: Confusion about pointers in c/ccPaul Rubin
 `* Re: Confusion about pointers in c/ccalbert
  `- Re: Confusion about pointers in c/ccPaul Rubin

1
Confusion about pointers in c/cc

<nnd$3a2dd52a$7fec1a9a@dc8892c0d291c155>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26380&group=comp.lang.forth#26380

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
From: albert@spenarnc.xs4all.nl
Subject: Confusion about pointers in c/cc
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$3a2dd52a$7fec1a9a@dc8892c0d291c155>
Organization: KPN B.V.
Date: Wed, 13 Mar 2024 10:20:45 +0100
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.gegeweb.eu!gegeweb.org!usenet-fr.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe004.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 37
Injection-Date: Wed, 13 Mar 2024 10:20:45 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1620
 by: albert@spenarnc.xs4all.nl - Wed, 13 Mar 2024 09:20 UTC

In a recent thread there was a confusion about pointers
in c/cc
Algol 68 has
'int' y;
'ref' 'int' py;

C has
int y;
int *py;

This defines py as something that can be dereferenced to
yield an int. This inside out type of definition leads to
confusion.

This is an example that you can compile with gcc
------------------- pointer.cc ------------
#include <stdio.h>
int main()
{ int y, *py;
py=&y;
printf("%x",py);
} ----------------
Running it reveals the address of y, or at least the 32 least
significant bits.

I couldn't find back the thread, but this is a separate subject
anyway. Confirms the superiority of Forth ;-)

Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat purring. - the Wise from Antrim -

Re: Confusion about pointers in c/cc

<c92cdebe2e510303045872a3d98cd667@www.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26383&group=comp.lang.forth#26383

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!.POSTED!not-for-mail
From: minforth@gmx.net (minforth)
Newsgroups: comp.lang.forth
Subject: Re: Confusion about pointers in c/cc
Date: Wed, 13 Mar 2024 10:58:22 +0000
Organization: novaBBS
Message-ID: <c92cdebe2e510303045872a3d98cd667@www.novabbs.com>
References: <nnd$3a2dd52a$7fec1a9a@dc8892c0d291c155>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="1833474"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Rslight-Posting-User: d2a19558f194e2f1f8393b8d9be9ef51734a4da3
X-Spam-Checker-Version: SpamAssassin 4.0.0
X-Rslight-Site: $2y$10$daTixYshKuvRwEndkTUvIuedbnyQdLwfXYr0rCZpXS4MGSFneyNZi
 by: minforth - Wed, 13 Mar 2024 10:58 UTC

albert@spenarnc.xs4all.nl wrote:
------------------- pointer.cc ------------
> #include <stdio.h>
> int main()
> {
> int y, *py;
> py=&y;
> printf("%x",py);
> }
> ----------------
> Running it reveals the address of y, or at least the 32 least
> significant bits.

use %p instead of %x

Re: Confusion about pointers in c/cc

<8734st1u9a.fsf@nightsong.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26393&group=comp.lang.forth#26393

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Confusion about pointers in c/cc
Date: Wed, 13 Mar 2024 18:23:29 -0700
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <8734st1u9a.fsf@nightsong.com>
References: <nnd$3a2dd52a$7fec1a9a@dc8892c0d291c155>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5e13a877c405b42ffe91dd9e42ac1c1b";
logging-data="1320683"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/befbPNIXAfyGyFYDBcCbo"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:2oclU8yye6PH6udDI7w5N4JMhYA=
sha1:VDY5VaJ+e3Lc/HsxIAxhx6Fvdgg=
 by: Paul Rubin - Thu, 14 Mar 2024 01:23 UTC

albert@spenarnc.xs4all.nl writes:
> Running it reveals the address of y, or at least the 32 least
> significant bits.

Being able to find the addresses of memory objects is considered a
feature in C and it's used all the time in idiomatic C. In retrospect,
other languages have usually-good ways to do without that feature, such
as references, access types, etc. I think if you are writing an OS or
standalone embedded program in Ada though, it's not unusual to have some
low level parts of it in assembly language, that reach into the access
types and do stuff with the addresses.

Re: Confusion about pointers in c/cc

<nnd$17415a58$15d8a39c@7f11b53ce81fb98a>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26395&group=comp.lang.forth#26395

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <nnd$3a2dd52a$7fec1a9a@dc8892c0d291c155> <8734st1u9a.fsf@nightsong.com>
From: albert@spenarnc.xs4all.nl
Subject: Re: Confusion about pointers in c/cc
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$17415a58$15d8a39c@7f11b53ce81fb98a>
Organization: KPN B.V.
Date: Thu, 14 Mar 2024 09:23:07 +0100
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!news.neodome.net!npeer.as286.net!npeer-ng0.as286.net!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe005.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 26
Injection-Date: Thu, 14 Mar 2024 09:23:07 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1975
 by: albert@spenarnc.xs4all.nl - Thu, 14 Mar 2024 08:23 UTC

In article <8734st1u9a.fsf@nightsong.com>,
Paul Rubin <no.email@nospam.invalid> wrote:
>albert@spenarnc.xs4all.nl writes:
>> Running it reveals the address of y, or at least the 32 least
>> significant bits.
>
>Being able to find the addresses of memory objects is considered a
>feature in C and it's used all the time in idiomatic C. In retrospect,
>other languages have usually-good ways to do without that feature, such
>as references, access types, etc. I think if you are writing an OS or
>standalone embedded program in Ada though, it's not unusual to have some
>low level parts of it in assembly language, that reach into the access
>types and do stuff with the addresses.

All non-toy languages have side-effects. All i/o are side effects.
It is impossible to do that with addresses (ports or memory) that have
connection to the real world, like actuators that close valves.
Relying on an OS only serves to hide this.

Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat purring. - the Wise from Antrim -

Re: Confusion about pointers in c/cc

<87ttl8zd00.fsf@nightsong.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26399&group=comp.lang.forth#26399

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: Confusion about pointers in c/cc
Date: Thu, 14 Mar 2024 15:04:31 -0700
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <87ttl8zd00.fsf@nightsong.com>
References: <nnd$3a2dd52a$7fec1a9a@dc8892c0d291c155>
<8734st1u9a.fsf@nightsong.com>
<nnd$17415a58$15d8a39c@7f11b53ce81fb98a>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="45ec120975ce484c52326163b18f0579";
logging-data="1976476"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Cw5RZXmn5CMyvaMXGeSs/"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:YGC71i/gnS6zOyeEuETggQgbSKI=
sha1:y14JzlUjmAahyUoWk+KENr8c1Hc=
 by: Paul Rubin - Thu, 14 Mar 2024 22:04 UTC

albert@spenarnc.xs4all.nl writes:
> All non-toy languages have side-effects. All i/o are side effects.
> It is impossible to do that with addresses (ports or memory) that have
> connection to the real world, like actuators that close valves.
> Relying on an OS only serves to hide this.

I don't see what you're getting at here. It's far preferable to isolate
the unsafe operations to a few places in the program, than to have them
pervading the code base. E.g. you can't really write a garbage
collector without dealing with memory addresses, but if the GC is part
of a Lisp interpreter, the user's Lisp program doesn't have to be able
to see the raw addresses.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor