🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1323

Re: const arrays in prototypes

#1323
From: Benjamin Zhu
Date: Tue, 29 May 1990 14:04
68 lines
3260 bytes
In article <1745@tkou02.enet.dec.com> diamond@tkou02.enet.dec.com (diamond@tkovoa) writes:
>In article <1990May26.164834.4211@jarvis.csri.toronto.edu> norvell@csri.toronto.edu (Theo Norvell) writes:
>
>>>Perhaps you mean
>>>	void DISALLOW( const int (*const mat)[2] )
>>>But this is UGLY.
>
>It's as ugly as any other solution, and as ugly as most of C.
>
>>>Is the following a solution?
>>>	typedef const int const_matrix[2][2] ;
>>>	...
>>>	void DISALLOW( const const_matrix mat )
>>>If not, I'm sure someone will point out why.
>
>This is also valid.
>But you know the net.  Even if it's a solution, we can still trust
>someone to point out why it isn't.  ;-)
>In article <1359@crabcake> zhu@crabcake.cs.jhu.edu (Benjamin Zhu) writes:
>>	Nope. In this case, "const" has been used twice, i.e., it
>>	is duplicatedly declared, which I believe is illegal in
>>	Ansi stardard.  Moreover, I fail to notice any semantical
>>	difference between "const_matrix" and "const const_matrix".
>>	Maybe you mean something else?
>Mr. Zhu, you have gotten this one wrong twice.  Looks like you should
>take a vacation from answering questions, until you're more alert.

	Wait a second. Let's see what you comment.

>
>typedef const int const_matrix[2][2] ;
>means that a variable of type const_matrix will have constant elements.
>void DISALLOW( const const_matrix mat )
>means that the pointer "mat" is a constant pointer.
>So the result is a constant pointer to constant elements.
>The two "const"s do not duplicate each other.

	No, I believe I am correct. Haven't you confused an array with
	a pointer? An array has to be treeted as a single object. So
	to define

		typedef	const int const_matrix[2][2];
		const const_matrix mat;

	is analogous to define

		typedef const int const_int;
		const const_int number;

	Of course the two const's duplicate each other. If you take
	my arguments, what's the semantical difference then? OK, if
	you insist that const duplication is allowed, then there IS
	some difference.

	I am not flaming you. Would you kindly test what you say, or
	at least check the references before you jump on someone?
>
>-- 
>Norman Diamond, Nihon DEC     diamond@tkou02.enet.dec.com
>Proposed group comp.networks.load-reduction:  send your "yes" vote to /dev/null.

Benjamin Zhu

+=========================================================================+
+Disclaimer:								  +
+	I do not represent Johns Hopkins, Johns Hopkins does not	  +
+	represent me either.						  +
+==========================================================================
Technical Details
Message-ID: <1373@crabcake>
Path: arc1-ca.pugleaf.net!utzoo!yunexus!lethe!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!mailrus!iuvax!purdue!haven!umd5!crabcake!zhu
References: <2781@sunset.MATH.UCLA.EDU> <1356@crabcake> <1990May26.164834.4211@jarvis.csri.toronto.edu> <1359@crabcake> <1745@tkou02.enet.dec.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!yunexus!lethe!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!mailrus!iuvax!purdue!haven!umd5!crabcake!zhu
From: zhu@crabcake.cs.jhu.edu (Benjamin Zhu)
Newsgroups: comp.std.c
Subject: Re: const arrays in prototypes
Message-ID: <1373@crabcake>
Date: 29 May 90 14:04:11 GMT
Article-I.D.: crabcake.1373
References: <2781@sunset.MATH.UCLA.EDU> <1356@crabcake> <1990May26.164834.4211@jarvis.csri.toronto.edu> <1359@crabcake> <1745@tkou02.enet.dec.com>
Reply-To: zhu@crabcake.cs.jhu.edu (Benjamin Zhu)
Followup-To: comp.std.c
Organization: JHU Computer Science Dept -- Town of Solitude
Lines: 68