🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1991

Re: C and its peasant 'ancestors'

#1991
From: Dan Cross
Date: Mon, 30 Nov 2026 02:25
96 lines
5383 bytes
In article <11eij2a$hq5$1@kst.eternal-september.org>,
Keith Thompson  <Keith.S.Thompson+u@gmail.com> wrote:
>cross@spitfire.i.gajendra.net (Dan Cross) writes:
>> In article <11eieib$3v2hj$1@kst.eternal-september.org>,
>> Keith Thompson  <Keith.S.Thompson+u@gmail.com> wrote:
>[...]
>>>I'm not aware that there's any widely accepted definition of
>>>"strongly typed".  And I would argue that "strong typing" cannot
>>>be measured along a single continuum, with "weakly typed" languages
>>>at one end and "strongly typed" languages at the other.  One language
>>>might have strong typing enforced at run time; another might have
>>>weak typing enforced at compile time.
>>
>> No, these terms of art that are, as I understand it, fairly well
>> understood in the PL community.  Generally, "strong typed" means
>> "no implicit conversions", and "statically typed" means "types
>> are known at compile time."
>
>You may well be right about that.  On the other hand, I think there
>are a lot of people who don't use the terms that way, and some of
>them participate in discussions like this one.  (I'm not referring
>to anyone in particular.)

Perhaps; I'm not in anyone else's head so I don't know how they
conceptualize these things, but programming languages are a
domain within computer science (actually, I suppose within the
intersection of a few different fields) and domain nomenclature
has meaning within that domain.

It is fine not to know the nomenclature; it is not fine to say
that it means something different with respect to the domain
because someone is not deeply immersed in the field.  And I say
that as someone who is not a PL person: I'm an OS person.

>In the particular case of "hello" + 1 being valid in C, there are
>two things going on.  One is the implicit conversion of the array
>expression "hello" to a pointer expression; that's weak typing.
>The other is the existence of a + operator that takes pointer and
>integer operands; that's just a weird operator, no more weakly
>typed than Pythons "foo" * 3" or Perl's "foo" x 3.

I'd put the whole thing in C more succinctly: it's an accident
of history.  B had no types other than a "word"; memory was
viewed as an array of words.  As Dennis Ritchie put it in his C
history paper from HOPL III,

|Because pointers in BCPL and B are merely integer indices in
|the memory array, arithmetic on them is meaningful: if `p` is
|the address of a ceil, then `p + 1` is the address of the next
|cell.  This convention is the basis for the semantics of arrays
|in both languages".

He goes on to explain what `auto V[10]` means as a result:

|...a cell named `V` is allocated, then another group of 10
|contiguous cells is set aside, and the memory index of the
|first of these is placed into `V`.  By a general rule, in B,
|the expression `*(V + i)` adds `V` and `i`, and refers to the
|`i`-th location after `V`.  Both BCPL and B each add special
|notation to sweeten such array accesses; in B, an equivalent
|expression is `V[i]`....

The rest is literally history.

https://dl.acm.org/doi/epdf/10.1145/234286.1057834

>A digression: I'm not happy that C's array-to-pointer conversion is
>referred to as a "conversion".  It's not like other type conversions.
>An ordinary type conversion is an operation (either performed
>implicitly or specified by a cast operator) that takes an operand of
>some type, and the result depends only on the *value* of the operand.
>It notionally happens at run time, but can sometimes be optimized
>to occur at compile time.
>
>The array-to-pointer conversion could more accurately be described as
>a compile-time *adjustment*, similar to the array-to-pointer parameter
>adjustment (for which the standard does use the word "adjusted").
>
>Likewise for function-to-pointer conversions.

To be provocative, I think it is easier to conceptualize if one
thinks of C as lacking first-class array types.  Rather, C has
pointers to contiguous regions of memory of some size; the
array-like notation is just syntactic sugar around this.

Btw, in the Q&A transcript at the above link, Ritchie says this
when asked about C declaration syntax:

|It was Ravi Sethi who observed that if C's unary star operator
|were a postfix operator instead of a prefix operator, suddenly
|everything becomes nice and linear and clear.

(Now excuse me, I am ducking and running for cover....)

	- Dan C.
Technical Details
Message-ID: <11eimr1$4c3$1@reader2.panix.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
References: <11dup6q$v4j9$1@dont-email.me> <11eieib$3v2hj$1@kst.eternal-september.org> <11eifmr$4dk$1@reader2.panix.com> <11eij2a$hq5$1@kst.eternal-september.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cross@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.lang.c
Subject: Re: C and its peasant 'ancestors'
Date: Mon, 30 Nov 2026 02:25:37 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <11eimr1$4c3$1@reader2.panix.com>
References: <11dup6q$v4j9$1@dont-email.me> <11eieib$3v2hj$1@kst.eternal-september.org> <11eifmr$4dk$1@reader2.panix.com> <11eij2a$hq5$1@kst.eternal-september.org>
Injection-Date: Mon, 30 Nov 2026 02:25:37 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
	logging-data="4483"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)