[nem-pl] Re: [nem-bug] [Nemerle 0000188]: try-in-unless syntax

Kamil Skalski nazgul at nemerle.org
Tue Jul 6 16:32:02 CEST 2004


On Tuesday 06 of July 2004 13:32, Michal Moskal wrote:
>
> What's here?
>
> def f = try { open_file () } catch { _ : Io => null };
> if (f != null) { ... } else { ... }
>
> This is ugly.

mutable opened = false;
try {
  def f = open_file ();
  opened = true;
  read_file (f)
}
catch {
  | _ : lo when !opened => ...
}

Ale w sumie jeśli już z inną składnią, to może po prostu
try {
  def f = open_file ();
} 
catch {
  | _ : lo => ...
}
succeed {
  read_file (f);
}

-- 
Kamil Skalski




More information about the devel-pl mailing list