September 10, 2007Re: Const sucks
Russell Lewis Wrote: > Walter Bright wrote: > > What we are trying to achieve: > > > > a) utility for functional programming > > b) better modularity by self-documenting interfaces better > > c) be able to treat reference types as if they were value types (i.e. > > strings should behave to the user like value types, even though they are > > references) > > Is there a way to express (for a pointer passed as a function parameter) "the callee is allowed to modify this object through the pointer, but the caller ensures that no other code will be modifying it at the same time"? Sort of a "you have exclusive write access" modifier? Is that a common enough case to even support? > > Russ That's an interesting concept. From the functions point of view it would compile as if it was invariant but the invariantness doesn't have a lifetime beyond the function. I think its slightly off topic here though, multi-threading / IPC is an entirely different kettle of bananas. How do you even declare whether a variable is shared or thread-local at the moment? This is only indirectly related to the const concept. What we have hear is "shared locked" versus "shared volatile" versus "local". Bruce.
Copyright © 1999-2016 by Digital Mars ®, All Rights Reserved