gracelang / language

Design of the Grace language and its libraries
GNU General Public License v2.0
6 stars 1 forks source link

print should be cleverer #93

Closed kjx closed 8 years ago

kjx commented 8 years ago

we need to spec print.

we could make it cleverer, so that it can print any object whatsoever, not just any object that has an "asString" method that works properly. You know, like this one:

object { 
   method asString { Exception.raise "BOOM" }       
}
kjx commented 8 years ago

One way to think about this is what is the type of print:

   method print ( _ : type { } )                                   // print can print anything
   method print ( _ : type { asString -> String } )      // print can print anything that can be converted to a String
   method print ( _ : String )                                     // print can only print Strings