Re: opCmp and unittest as a nested function

2014-04-09 Thread bearophile
Alexandr Druzhinin: http://dpaste.dzfl.pl/f7364d416cb2 Error appeared when I defined opCmp and now I can't understand what's the reason of the error. Why does tween need access to unittest? Try to use static struct instead of a struct. Bye, bearophile

Re: opCmp and unittest as a nested function

2014-04-09 Thread bearophile
And you need to use opEquals: unittest { static struct Point2D { double x, y; bool opEquals(const Point2D rhs) const { return false; } } auto p2d0 = Point2D(0, 0); auto p2d1 = Point2D(1, 0); assert(tween(p2d0, p2d1, 1 / 3.0) == Point2D(1

Re: opCmp and unittest as a nested function

2014-04-09 Thread Alexandr Druzhinin
09.04.2014 13:45, bearophile пишет: Alexandr Druzhinin: http://dpaste.dzfl.pl/f7364d416cb2 Error appeared when I defined opCmp and now I can't understand what's the reason of the error. Why does tween need access to unittest? Try to use static struct instead of a struct. Bye, bearophile

Re: opCmp and unittest as a nested function

2014-04-09 Thread Alexandr Druzhinin
09.04.2014 13:55, bearophile пишет: And you need to use opEquals: unittest { static struct Point2D { double x, y; bool opEquals(const Point2D rhs) const { return false; } } auto p2d0 = Point2D(0, 0); auto p2d1 = Point2D(1, 0);

Re: opCmp and unittest as a nested function

2014-04-09 Thread bearophile
Alexandr Druzhinin: Thank you! It works. But where can I read about this issue? Reading about this issue is not good. What you can read about is how unittests are implemented in D (as functions) and what's the difference between static structs and nonstatic ones when they are defined

Re: opCmp and unittest as a nested function

2014-04-09 Thread Alexandr Druzhinin
09.04.2014 14:13, bearophile пишет: Reading about this issue is not good. What you can read about is how unittests are implemented in D (as functions) and what's the difference between static structs and nonstatic ones when they are defined inside a function. Bye, bearophile I guess I should

Re: opCmp and unittest as a nested function

2014-04-09 Thread bearophile
Alexandr Druzhinin: I guess I should read how tepmlates work. No templates are involved in this code. Bye, bearophile

Re: opCmp and unittest as a nested function

2014-04-09 Thread Alexandr Druzhinin
09.04.2014 15:19, bearophile пишет: Alexandr Druzhinin: I guess I should read how tepmlates work. No templates are involved in this code. Bye, bearophile I mean that nested struct Point2D has additional pointer to frame and when compiler tries to instantiate template function 'tweet' it