title: Is using Scala's Iterator ++ (concat) recursively stack-safe?
body: <p>Suppose you are using an API that allows you to scroll through a resultset in pages. Each page returns an ID for the subsequent page.</p>
  
  <p>It's an established idiom that you can use Scala Iterator and its lazy concat (++) operator recursively to do this:</p>
  
  <pre><code>def allResults: Iterator[Result] = {
    def nextPage(pageId: String): Iterator[Result] = {
      val page = invoke api
      Iterator(page.results) ++ nextPage(page.nextPageId)
    }
    val firstPage = invoke api
    Iterator(firstPage.results) ++ nextPage(firstPage.nextPageId)
  }
  </code></pre>
  
  <p>Is this idiom stack-safe? Or are there other efficiency gotchas to worry about?</p>