Get weather forecast with the D programming language. It first gets your longitude and latitude using Then uses them to look up your weather using




Boost Software License - Version 1.0


  1. import std.stdio : stdout, stderr; import weather_forecast : getForecast, WeatherData; getForecast(delegate(WeatherData weather_data, Exception err) { if (err) { stderr.writefln("%s", err); } else { stdout.writefln("latitude: %s", weather_data.latitude); stdout.writefln("longitude: %s", weather_data.longitude); stdout.writefln("city: %s",; stdout.writefln("region: %s", weather_data.region); stdout.writefln("country: %s",; stdout.writefln("postal: %s", weather_data.postal); stdout.writefln("temperature: %s", weather_data.temperature); stdout.writefln("summary: %s", weather_data.summary); } });

  • Declaration

    struct WeatherData;

    Data gathered in WeatherData:

    1. struct WeatherData { string latitude; string longitude; string city; string region; string country; string postal; string temperature; string summary; }

  • Declaration

    void getForecast(void delegate(WeatherData weather_data, Exception err) cb);

    Returns the weather forecast using a callback.


    void delegate(WeatherData weather_data, Exception err) cb

    The callback to fire when weather info has been downloaded. The callback sends the WeatherData data and an Exception if there was any problem.