Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site opus.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!hao!nbires!opus!rcd From: rcd@opus.UUCP (Dick Dunn) Newsgroups: net.lang.c Subject: Re: Type modifiers in C Message-ID: <177@opus.UUCP> Date: Wed, 30-Oct-85 02:00:06 EST Article-I.D.: opus.177 Posted: Wed Oct 30 02:00:06 1985 Date-Received: Fri, 1-Nov-85 03:09:31 EST References: <943@lll-crg.ARpA> Organization: NBI,Inc, Boulder CO Lines: 39 > In considering some new type modifiers that are useful for multiprocessing > one needs to consider how type modifiers fit in the ANSI standard. > Could someone explain all the details of what you might do with for example > the volatile type modifier... ...examples follow of various combinations of types and "volatile" at various points. I don't have the standard proposal to examine, but there's a general point about these "type modifiers"--seemingly a generalization of what are more commonly [mis?]named "storage classes". There are attributes of objects which affect the declaration of the object itself but which don't carry outward, and there are other attributes which have to be propagated to referencing or containing objects. Attributes like C's "static" (in the sense that it means "local") and "external" are used to establish some property of an object at its declaration, but they don't need to be propagated through, say, a pointer to the object. (A pointer to a local int need not be different from a pointer to a global int.) Attributes like "constant" or "volatile" need to be propagated through dependent types. (A pointer to a volatile int is different from a pointer to a "normal" int, in the sense that the pointers point to objects which have different properties; if you dereference the pointers, you have to treat the resulting objects differently.) In "current" C (as in K&R), the "static" attribute is particularly unfortunate in this regard: When applied to a procedure or a variable outside of a procedure, it restricts the scope of the object only and there is no need to propagate the attribute. When applied to a variable within a procedure, it affects the semantics and the extent of the variable; in some sense the static-vs-automatic distinction should be propagated. (In some languages it would be prohibited to assign the address of an automatic variable to a more global pointer--i.e., a pointer whose extent exceeds that of the variable.) -- Dick Dunn {hao,ucbvax,allegra}!nbires!rcd (303)444-5710 x3086 ...At last it's the real thing...or close enough to pretend.