git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: phillip.wood@dunelm.org.uk
Cc: Philip Peterson via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Emily Shaffer <nasamuffin@google.com>,
	Philip Peterson <philip.c.peterson@gmail.com>
Subject: Re: [PATCH 0/5] promise: introduce promises to track success or error
Date: Mon, 19 Feb 2024 21:57:22 -0500	[thread overview]
Message-ID: <20240220025722.GE2713741@coredump.intra.peff.net> (raw)
In-Reply-To: <bd340a27-bfb4-41b2-a1fa-356ab7dbbd36@gmail.com>

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@sigill.intra.peff.net/

that also references this earlier thread:

  https://lore.kernel.org/git/20160927191955.mympqgylrxhkp24n@sigill.intra.peff.net/

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


  reply	other threads:[~2024-02-20  2:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-18  7:33 [PATCH 0/5] promise: introduce promises to track success or error Philip Peterson via GitGitGadget
2024-02-18  7:33 ` [PATCH 1/5] promise: add promise pattern to track success/error from operations Philip Peterson via GitGitGadget
2024-02-18  7:33 ` [PATCH 2/5] apply: use new promise structures in git-apply logic as a proving ground Philip Peterson via GitGitGadget
2024-02-18  7:33 ` [PATCH 3/5] apply: update t4012 test suite Philip Peterson via GitGitGadget
2024-02-18  7:33 ` [PATCH 4/5] apply: pass through quiet flag to fix t4150 Philip Peterson via GitGitGadget
2024-02-18  7:33 ` [PATCH 5/5] am: update test t4254 by adding the new error text Philip Peterson via GitGitGadget
2024-02-19 14:25 ` [PATCH 0/5] promise: introduce promises to track success or error Phillip Wood
2024-02-20  2:57   ` Jeff King [this message]
2024-02-20 10:53     ` Phillip Wood
2024-02-20 12:19       ` Patrick Steinhardt
2024-02-20 16:20         ` Junio C Hamano
2024-02-21 18:03         ` Jeff King
2024-03-12  4:18           ` Philip

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240220025722.GE2713741@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=nasamuffin@google.com \
    --cc=philip.c.peterson@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).