title: What does it mean for a constant to be untyped?
body: <p>The <a href="http://golang.org/ref/spec#Constants" rel="nofollow noreferrer">Go Programming Language Specification</a> says that:</p>
  
  <blockquote>
    <p>Constants may be typed or untyped</p>
  </blockquote>
  
  <p>I am having a little doubt in my understanding.
  Consider this example in the spec:</p>
  
  <pre><code>const l = "hi"             // l == "hi"  (untyped string constant)
  const m = string(k)        // m == "x"   (type string)
  </code></pre>
  
  <p>The spec says:</p>
  
  <blockquote>
    <p>constant may be given a type explicitly by a constant declaration or
    conversion, or implicitly when used in a variable declaration or an
    assignment or as an operand in an expression</p>
  </blockquote>
  
  <p>By this statement, why isn't <code>l</code> typed since it is clearly a constant declaration?</p>
  
  <p>This behaviour is clearer with another <a href="http://play.golang.org/p/h1ghL-ec-t" rel="nofollow noreferrer">example</a></p>
  
  <pre><code>type Foo string
  func f(a Foo) {}
  
  func main() {
    f("sarkozy")
  
    const t = "julie gayet"
    f(t)
  
    s := "hollande"
  
    //compile error
    // f(s)
  
    f(Foo(s)) // ok
  }
  </code></pre>
  
  <p>Is the reason that <code>f("sarkozy")</code> compiles be due to this statement on Assignability in the spec?</p>
  
  <blockquote>
    <p>x is an untyped constant representable by a value of type T.</p>
  </blockquote>
  
  <p>My argument is the following:</p>
  
  <ul>
  <li>"sarkozy" a an untyped literal.</li>
  <li>Thus "sarkozy" being representable by <code>Foo</code> means I can type coerce like this <code> Foo("sarkozy") </code></li>
  <li><code>f(s)</code> fails because s is not <em>untyped</em>.</li>
  </ul>