Re: [PATCH 0/5] promise: introduce promises to track success or error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 19, 2024 at 02:25:29PM +0000, Phillip Wood wrote:

> I think we'd be better served by some kind of structured error type like the
> failure_result in this patch series that is allocated on the stack by the
> caller at the entry point to the library and passed down the call chain.
> That avoids the need for lots of dynamic allocations and allows us to
> continue allocating "out" parameters on the stack. For example
> 
>     int f(struct repository *r) {
> 	struct object_id oid;
> 
> 	if (repo_get_oid(r, "HEAD", &oid))
> 		return error(_("could not parse HEAD"))
> 
> 	/* use oid here */
>     }
> 
> would become
>     int f(struct repository *r, struct error *err) {
> 	struct object_id oid;
> 
> 	if (repo_get_oid(r, "HEAD", &oid))
> 		return error(&err, _("could not parse HEAD"))
> 
> 	/* use oid here */
>     }
> 
> I'm sure this has been discussed in the past but I didn't manage to turn
> anything up with a quick search of the archive on lore.kernel.org.

There's some discussion in this sub-thread:

  https://lore.kernel.org/git/20171103191309.sth4zjokgcupvk2e@xxxxxxxxxxxxxxxxxxxxx/

that also references this earlier thread:

  https://lore.kernel.org/git/20160927191955.mympqgylrxhkp24n@xxxxxxxxxxxxxxxxxxxxx/

I still think this is a reasonable way to go. At one point I had a
proof-of-concept conversion of some of the ref code, but I don't think I
have it any more.

-Peff




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux