9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] no const?
@ 2000-09-13 14:22 Russ Cox
  2000-09-13 14:30 ` Boyd Roberts
  0 siblings, 1 reply; 24+ messages in thread
From: Russ Cox @ 2000-09-13 14:22 UTC (permalink / raw)
  To: 9fans

	'cos they were stupid, unnecessary, incomprehensable language abortions.

They are neither stupid nor unnecessary.




^ permalink raw reply	[flat|nested] 24+ messages in thread
* Re: [9fans] no const?
@ 2000-09-13 18:06 Russ Cox
  2000-09-14  8:13 ` Douglas A. Gwyn
  0 siblings, 1 reply; 24+ messages in thread
From: Russ Cox @ 2000-09-13 18:06 UTC (permalink / raw)
  To: 9fans

I don't know anything officially but what I understand is...

In the Plan 9 compilers, volatile is mostly unnecessary.
Treating all variables as callee-save has the side effect
of taking care of setjmp and longjmp.  I believe pointers
are always dereferenced (i.e. multiple *p's will never get
coalesced into a single dereference or lifted out of a loop).
Those are the two main needs for volatile, gone, at the
price of a little optimization, as was pointed out.

When I tried to port drawterm (basically a stripped down
Plan 9 kernel) to Digital Unix, I had a bear of a time putting
the volatiles in the right places, until I found the -volatile
compiler flag to make everything volatile.  This is basically
what the Plan 9 compiler does.

In the case of const, it is harder to justify both its 
necessity and its omission.  It's hard to explain to people,
and as Forsyth points out, adds little serious protection.
It's also not too hard to implement, and indeed the compilers
do implement it now.  The lack of necessity is really the 
best justification for the omission.  The C type system is
not particularly expressive, but adding little warts like
const or restrict, whatever that means, just sullies it without
any real benefit.  Boyd is right that it certainly feels like
such things have been added as a sacrifice to the god of 
efficiency rather than for use by mere mortals.

And it is a fact that const and volatile are not easily
understood.  Try explaining to a beginning C programmer
why "volatile Chan *c" or "Chan volatile *c" both declare
a pointer to a volatile Chan structure rather than a 
volatile pointer to a Chan structure (which would, obviously,
be "Chan *volatile c").

Russ



^ permalink raw reply	[flat|nested] 24+ messages in thread
* Re: [9fans] no const?
@ 2000-09-13 14:39 forsyth
  2000-09-13 16:44 ` Douglas A. Gwyn
  0 siblings, 1 reply; 24+ messages in thread
From: forsyth @ 2000-09-13 14:39 UTC (permalink / raw)
  To: 9fans

i suspect the answers are along the lines of disapproval sparked by:
	volatile: both too little and too much to be useful for the purpose for which it is touted
	const: confuses the C type system but does not seriously add clarity or protection
			(eg, char *strchr(const char *, int))
although the compilers now pay more attention, at least when type checking,
when const, volatile and register appear than that paper suggests.




^ permalink raw reply	[flat|nested] 24+ messages in thread
* Re: [9fans] no const?
@ 2000-09-13 14:29 miller
  0 siblings, 0 replies; 24+ messages in thread
From: miller @ 2000-09-13 14:29 UTC (permalink / raw)
  To: 9fans

> This is a bit mysterious...why are volitile and const ignored?

In fact they aren't.  Compilers (if invoked with '-w') will give a warning
message on assignment to identifiers declared const.  And volatile declarations
do influence the register allocation algorithm.

-- Richard Miller




^ permalink raw reply	[flat|nested] 24+ messages in thread
* [9fans] no const?
@ 2000-09-13 14:00 David L Rubin
  2000-09-13 14:17 ` Boyd Roberts
  0 siblings, 1 reply; 24+ messages in thread
From: David L Rubin @ 2000-09-13 14:00 UTC (permalink / raw)
  To: 9fans

http://plan9.bell-labs.com/sys/doc/comp.html states

"The compilers do their own register allocation so the register keyword
is ignored. For different reasons, volatile and const are also ignored."

This is a bit mysterious...why are volitile and const ignored?

	david

~~
David L Rubin <davidrubin@lucent.com>   f/973.581.6665  
v/973.386.8598   
Lucent Technologies, NJ0117 15G-117, 67 Whippany Rd, Whippany, NJ 07981
temporary voice mail: +34 91.807.1054



^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2000-09-18 10:47 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-13 14:22 [9fans] no const? Russ Cox
2000-09-13 14:30 ` Boyd Roberts
  -- strict thread matches above, loose matches on Subject: below --
2000-09-13 18:06 Russ Cox
2000-09-14  8:13 ` Douglas A. Gwyn
2000-09-13 14:39 forsyth
2000-09-13 16:44 ` Douglas A. Gwyn
2000-09-13 14:29 miller
2000-09-13 14:00 David L Rubin
2000-09-13 14:17 ` Boyd Roberts
2000-09-13 16:42   ` Douglas A. Gwyn
2000-09-13 17:03     ` Boyd Roberts
2000-09-13 17:11       ` Steve Kilbane
2000-09-13 19:33         ` Boyd Roberts
2000-09-14  8:13           ` Douglas A. Gwyn
2000-09-14 12:34             ` Boyd Roberts
2000-09-15  8:47               ` Douglas A. Gwyn
2000-09-15 11:34                 ` Boyd Roberts
2000-09-15 13:07                   ` Theo Honohan
2000-09-15 14:55                     ` Boyd Roberts
2000-09-16  8:51                       ` Matt Lawless
2000-09-18 10:47                   ` Douglas A. Gwyn
2000-09-15 20:46                 ` Steve Kilbane
2000-09-14 19:41           ` Steve Kilbane
2000-09-18 10:47             ` Douglas A. Gwyn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).