digitalmars.D.learn - Error: cannot call public/export function someFunction from invariant
- simendsjo (9/9) Oct 18 2013 See topic. Why is this not allowed? The function in question is
- bearophile (5/14) Oct 18 2013 It being not virtual is not important. In what cases is
- Jonathan M Davis (5/23) Oct 18 2013 Yeah, it's probably because someFunction calls the invariant before and ...
- simendsjo (4/29) Oct 18 2013 Ah, good point - stupid me :) I'll rather move some checking to
- Andrej Mitrovic (2/4) Oct 18 2013 I can also be private, the diagnostic is pretty clear about that. :)
See topic. Why is this not allowed? The function in question is not virtual. struct S { void someFunction() const {} const invariant() { someFunction(); } } void main() { S s; }
Oct 18 2013
simendsjo:See topic. Why is this not allowed? The function in question is not virtual. struct S { void someFunction() const {} const invariant() { someFunction(); } } void main() { S s; }It being not virtual is not important. In what cases is invariant() called, simendsjo? I sense an infinite loop. Bye, bearophile
Oct 18 2013
On Friday, October 18, 2013 11:04:25 bearophile wrote:simendsjo:Yeah, it's probably because someFunction calls the invariant before and after it's called. If you want to call a member function from an invariant, it should be static, or it should be a free function. - Jonathan M DavisSee topic. Why is this not allowed? The function in question is not virtual. struct S { void someFunction() const {} const invariant() { someFunction(); } } void main() { S s; }It being not virtual is not important. In what cases is invariant() called, simendsjo? I sense an infinite loop.
Oct 18 2013
On Friday, 18 October 2013 at 09:08:53 UTC, Jonathan M Davis wrote:On Friday, October 18, 2013 11:04:25 bearophile wrote:Ah, good point - stupid me :) I'll rather move some checking to pre/post contracts.simendsjo:Yeah, it's probably because someFunction calls the invariant before and after it's called. If you want to call a member function from an invariant, it should be static, or it should be a free function.See topic. Why is this not allowed? The function in question is not virtual. struct S { void someFunction() const {} const invariant() { someFunction(); } } void main() { S s; }It being not virtual is not important. In what cases is invariant() called, simendsjo? I sense an infinite loop.
Oct 18 2013
On 10/18/13, Jonathan M Davis <jmdavisProg gmx.com> wrote:If you want to call a member function from an invariant, it should be static, or it should be a free function.I can also be private, the diagnostic is pretty clear about that. :)
Oct 18 2013