namespace Utils { class ReadUtil { name : string; public this (n : string) { name = n } public this () { } public ReadFile () : string { using (sr = System.IO.StreamReader (name)) { sr.ReadToEnd () } } } class WriteUtil { name : string; public this (n : string) { name = n } public WriteFile (contents : string) : void { using (sw = System.IO.StreamWriter (name)) { sw.Write (contents) } } } } [Nemerle.DesignPatterns.Aggregate (Utils.ReadUtil, Utils.WriteUtil)] class ReadWriteUtil { public this (inp : string, outp : string) { _initReadUtil (inp); _initWriteUtil (outp); } } module Bases { public Main () : void { try { def x = ReadWriteUtil("example.txt", "example.txt"); x.WriteFile ("Ala ma kota"); assert (x.ReadFile () == "Ala ma kota"); } finally { try { System.IO.File.Delete ("example.txt") } catch { _ => () } } } } /* BEGIN-OUTPUT END-OUTPUT */