Isn't "transitive" the wrong word?
guslay
guslay at gmail.com
Fri Apr 4 10:14:55 PDT 2008
Janice Caron Wrote:
> Sorry to go all grammar/mathematics nit-picky, but isn't "transitive"
> completely the wrong word?
>
> But the word "transitive" has no meaning when applied to a unary type
> constructor like const().
>
> No, methinks the word you're looking for here is RECURSIVE. Const in D
> is recursive, not transitive.
>
> Should we change all the documention, or is this some new definition
> of "transitive" which is in common use in some field of which I am
> unaware?
You are correct. Recursive (but recursive is already full of meaning) or chaining would be better words for something that "brings the const along"...
But I think the concept mainly need clarification, not a different name. I could not find a comprehensive definition. I think it would be helpful, as it is a key concept.
Here is my attempt. I discern three parts: syntax, data, function.
- If I am not mistaken, I've seen the term used to qualify how the syntax works.
const(int*)** p;
By the transitivity rule, this syntax defines a const pointer to a const pointer to an int pointer.
- One part of it is purely data centric.
A const pointer can point to a const data or a mutable data, but offers only a read-only view of it.
For those who still want to fight about it, you could not mutate a mutable class members trough a const pointer (this is not where mutable breaks transitivity), as who could not mutate a global state.
- But what is const transitivity when calling a const function?
I would say that there is currently no such thing as const function transitivity. The only thing that would fit the concept is pure function. Because a const function provides sufficient indirection to mutate some states, the concept of transitivity seems to lose its meaning when applied to a function.
"Logical const breaks transitivity." I cannot say that I agree. Logical const might break /something/. It might impede pure and functional programming, depending on how strong your assumptions are about FP (unshameful self-reference: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=69141
sorry for the grammar), but it does not break transitivity.
This part needs clarification.
More information about the Digitalmars-d
mailing list