const'ness vs reality


Subject: const'ness vs reality
From: Joao.Geada@synopsys.com
Date: Wed Dec 11 2002 - 09:02:18 PST


Please everybody, lets be very careful in distinguishing between language
conveniences vs language capabilities/rules.
Yes, C and C++ (and numerous other languages) permit the user to mark some
arguments as being 'const'. This is a useful indicator to the users and
implementors of such functions about the interface expectations.

HOWEVER, please do NOT confuse this convenience and extra compile time checking
as meaning that it is forbidden for a programmer to make changes to such a variable.
There is *no* such restriction in either language (regardless of whether the
function name is annotated with 'const'ness attributes for the linker). Please
recall that both C and C++ give programmers the ability to cast away the 'const'ness
No sufficiently useful programming language can *stop* a programmer from writing buggy
or incorrect code.

My point is as follows: putting the const attribute in the prototypes for external
functions is desirable, particularly so if the prototypes are automatically
created by the SystemVerilog compiler. This does *not* prevent a user from
writing to input arguments, but for users attempting to write valid code this
would be helpful for ensuring that they are following the relevant rules.

Joao
==============================================================================
Joao Geada, PhD Principal Engineer Verif Tech Group
Synopsys, Inc TEL: (508) 263-8083
154 Crane Meadow Road, Suite 300, FAX: (508) 263-8069
Marlboro, MA 01752, USA
==============================================================================



This archive was generated by hypermail 2b28 : Wed Dec 11 2002 - 09:03:06 PST