Const transitivity is bad sometimes

naryl cy at ngs.ru
Fri Jan 11 17:04:21 PST 2008


For example, I have this piece of (useless) code:

http://paste.dprogramming.com/dpmmwnah

If there were more subscribers the same message would be sent to every one  
of them. And there may be several messages, carrying the same notifier as  
their data. While compiling this I got the following errors (DMD 2.009):

main.d(28): function main.SystemShutdownNotifier.addSubscriber  
(Subscriber) does not match parameter types (Subscriber)
main.d(28): Error: (cmd.notifier).addSubscriber can only be called on a  
mutable object, not const(SystemShutdownNotifier)

I know. Notifier has become const because const is transitive, but in this  
example I don't need transitivity. I can't even think of a workaround for  
that. Maybe someone can help?


More information about the Digitalmars-d-learn mailing list