[Issue 6854] delegates does not work outside of object

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Oct 25 16:52:36 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6854


Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jmdavisProg at gmx.com
         Resolution|                            |INVALID


--- Comment #1 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-10-25 16:51:29 PDT ---
That code is definitely wrong. stdTime is not a static function. It must be
called on an object of type SysTime, not on the type itself. You probably want
something more like this:

import  std.datetime;

alias bool delegate (  )                       predicate;

predicate wait_for_seconds( immutable uint seconds = 0 )
{ 
    auto start = Clock.currTime();

    return delegate ()
    {
        return seconds == 0 ? true
                            : Clock.currTime() - start <
dur!"seconds"(seconds);
    };
}

void main( string [] args )
{
}

though whether that does exactly what you want, I don't know (e.g. I would have
that that you'd want to use >, not < given the function name, but your code has
<).

You might want to check out this article if you want know more about
std.datetime beyond just reading the docs:
http://d-programming-language.org/intro-to-datetime.html

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list