Note: This website is archived. For up-to-date information about D projects and development, please visit

Function Literal / Anonymous Function

Part of FunctionLiteralsCategory


Function Literals enable embedding anonymous functions directly into expressions.


import std.stdio;

int function(char c) fp;

void main() { 
  fp = function int(char c) { 
    return 6;
  }; //note the semi-colon at the end 

  writefln(fp('A')); // Prints 6

More Information

For more details, see the D Specification.


Based on which was copied from (dead link).