title: Understanding go composite literal
body: <p>Why a function value assignment to <strong>f</strong> is not a composite literal?</p>
  
  <p>Go lang specification <a href="https://golang.org/ref/spec#Composite_literals" rel="noreferrer">Composite literals</a> says below, hence function value cannot be constructed with composite Literal.</p>
  
  <blockquote>
    <p>Composite literals construct values for structs, arrays, slices, and maps and create a new value each time they are evaluated</p>
  </blockquote>
  
  <p>However, the function value assignment to <strong>f</strong> in the code looks as a composite literal expression for type <strong>func() int</strong>. </p>
  
  <p>Is there a reason function object cannot be constructed as a composite literal?</p>
  
  <pre><code>package main
  import (
      "fmt"
  )
  
  func main(){
      var x int = 0
  
      var f func() int
      f = func() int{ x++; return x * x }  // &lt;---- Why this cannot be a composite literal?
  
      fmt.Println(f())   // 1
      fmt.Println(f())   // 4
      fmt.Println(f())   // 9
  
      // Define a type for "func() int" type 
      type SQUARE func() int
      g := SQUARE{ x++; return x * x}   // &lt;--- Error with Invalid composite literal type: SQUARE 
  
      fmt.Println(g())
  }
  </code></pre>