-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu Nov 17 06:10:20 2011, Niko Matsakis wrote:
> 
> On Nov 16, 2011, at 11:07 AM, Brian Anderson wrote:
> 
>> I had thought to redefine result as result<T> { ok(T); err(any); 
>> } once that was possible, but I do think maybe creating an exn 
>> type as David proposed could be better.
> 
> I am somewhat indifferent as to the precise type of exceptions, so 
> long as you can print it out it's good enough 99% of the time.  I 
> could imagine this being a good place for an interface, too. 
> Something like:
> 
> iface failure { fn msg() -> str; fn data() -> any; }

Here's a reworked version with two macros and one type.

#throw[val] //if `val` has type T
            //result typescheme: forall A, A
            //return typescheme: forall A, result::t<A, exn>

#do[val]    //if `val` has type A
            //result typescheme: A
            //return typescheme: result::t<A, exn>

type exn = {
//Public API:
  spec: any

//Private API, for debugging only:
  #[cfg(debug)]
  stack: list::t<pos>//Added and updated by #throw and #do
}


All of `#throw`, `#do` and `exn` are trivial to implement (or, well,
will be once we really have macros :) ) and neither should hurt.

Cheers,
 David
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)

iQEcBAEBAgAGBQJOxTX8AAoJED+FkPgNe9W+XhUH/0srKVq2WKP8AvS2B7bZXCLr
ZvAtuYoMsOSsTLWXuZhZxmk/bXkUGUpKuSuaN2uRUJ7Wbkir9E6iXTmTkyb949x+
aQPYkSTS25N3uUo+6011IWtQKNo9cP59LZGJ/ieypXGsXbWa4hoHcdeSSk0ehoSZ
vrPhGxIWoLZpnEKs0KHKQICi6Sedko+0/7yIsdT31WWtuH3zEMgPMBM/WB1OFyIc
vZtqd0PcKsof9Z+RlQx/SXO66pk9N9azuBY3olOAERq+mcaivcQn9mFL1vWksM0M
j8NlD6BOeyL3hgACdrzWBGRxojRpr9HpCXQ7mxoTxtL7/kKkZUVIIjOz4irg80k=
=SzZ/
-----END PGP SIGNATURE-----
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to