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
.New method
arm
:In
OutSream.fan
:tactics Fri 26 Mar 2010
Something like this might be useful. However, it's quite as bad in Fantom as other language, since all
write
andprint
methods for streams returnthis
. So, you can chain calls together:katox 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
using
clause that would automatically close one or more objects versus using a method likeuse
with 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.
I think, now may be just add
use
inOutStream
. Later, will be to removeuse
fromOutStream
when "Extension methods" appears.