partial const'ness (was feature wanted: detect missing 'const')

dfb@beech.CS.Berkeley.EDU (David F. Bacon)
Mon, 28 Mar 1994 21:38:45 GMT

          From comp.compilers

Related articles
feature wanted: detect missing 'const' john_reiser@rainbow.mentorg.com (1994-03-16)
Re: feature wanted: detect missing 'const' Mark.Lomas@cl.cam.ac.uk (1994-03-25)
partial const'ness (was feature wanted: detect missing 'const') dfb@beech.CS.Berkeley.EDU (1994-03-28)
| List of all articles for this month |
Newsgroups: comp.compilers
From: dfb@beech.CS.Berkeley.EDU (David F. Bacon)
Keywords: C++, lint
Organization: University of California, Berkeley
References: 94-03-064 94-03-140
Date: Mon, 28 Mar 1994 21:38:45 GMT

Another problem with "const" arises when I want to annotate part of a
pre-existing declaration. For instance:


    typedef struct treestruct {
        struct treestruct *left, *right;
        float value;
    } tree;


    ...


    void valmunge(tree *t)
    {
        /* code that modifies t->value but not t->left or t->right */
    }


I would like to declare that "left" and "right" are const, without
contraining my ability to modify "value" (or just declare "value" as var,
depending on your bent). It seems that the only thing to do is to take
advantage of structural equivalence and declare a new type called
"consttree" or some such. I'd be interested in suggestions on how to deal
with this, including suggest language mods.


david
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.