Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-174

Round Peg, Square Hole

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • 1.0
    • 1.1-rc-1
    • groovy-jdk
    • None

    Description

      Currently if you want to do something with a character stream i.e. Reader its common to provide multiple methods.

      doSomething(Reader)
      doSoemthing(File)
      doSomething(URL)
      doSomething(String)

      And the File, URL, String methods will do extra operations to create a reader before calling doSomething(Reader).

      The other option is to only have the reader method and make the caller perform those operations.

      It would be nice if groovy could mash an object into another type to fit the parameters. i.e. If you called a method taking a Reader and you passed a File, it would create a new FileReader for you.

      Maybe it looks for a method called toReader on the parameter?

      Obviously this can create problems, like oversimplifying character encoding issues with readers etc. And may lead to bad APIs when called from Java. But its a timesaving feature. Any thoughts.

      Attachments

        Activity

          People

            paulk Paul King
            yuri Yuri Schimke
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: