There is slightly annoyed to write every time close.
out := `temp`.toFile.out
out.print(
"""using tests
class B:A{}""")
out.close
New method arm:
out := `temp`.toFile.out.arm{
print(
"""using tests
class B:A{}""")
}
In OutSream.fan:
Bool arm(|This| f){
try
f(this)
finally
return close
}
tacticsFri 26 Mar 2010
Something like this might be useful. However, it's quite as bad in Fantom as other language, since all write and print methods for streams return this. So, you can chain calls together:
Though chaining close is not a good idea - it should stay in the finally block.
brianFri 26 Mar 2010
The current convention is to call that method use (for example on Locale).
There was debate previously about C# style using clause that would automatically close one or more objects versus using a method like use with an it-block.
AkcelistoFri 26 Mar 2010
"Using clause" is unnecessary complication. "Extension methods" can take the place "Using clause" when Brian will add them.
Akcelisto Fri 26 Mar 2010
There is slightly annoyed to write every time
close.out := `temp`.toFile.out out.print( """using tests class B:A{}""") out.closeNew method
arm:out := `temp`.toFile.out.arm{ print( """using tests class B:A{}""") }In
OutSream.fan:Bool arm(|This| f){ try f(this) finally return close }tactics Fri 26 Mar 2010
Something like this might be useful. However, it's quite as bad in Fantom as other language, since all
writeandprintmethods for streams returnthis. So, you can chain calls together:File(`temp`).out.print("Hello world").write('\r').write('\n').closekatox Fri 26 Mar 2010
Though chaining close is not a good idea - it should stay in the finally block.
brian Fri 26 Mar 2010
The current convention is to call that method
use(for example on Locale).There was debate previously about C# style
usingclause that would automatically close one or more objects versus using a method likeusewith an it-block.Akcelisto Fri 26 Mar 2010
"Using clause" is unnecessary complication. "Extension methods" can take the place "Using clause" when Brian will add them.
Bool use(this Closeable res, |This| f){ try f(res) finally return res.close }I think, now may be just add
useinOutStream. Later, will be to removeusefromOutStreamwhen "Extension methods" appears.