From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Newsgroups: gmane.lisp.guile.devel
Subject: Re: [PATCH v4 4/4] load: Display modules depth in output when using
 %load-verbosely.
Date: Mon, 02 Oct 2023 12:13:25 -0400
Message-ID: <87jzs53suy.fsf@gmail.com>
References: <20230925142945.14153-1-maxim.cournoyer@gmail.com>
 <20230925142945.14153-5-maxim.cournoyer@gmail.com>
 <6f5ace52-5ade-cfe2-bbf6-22562db70206@telenet.be>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="22822"; mail-complaints-to="usenet@ciao.gmane.io"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cc: guile-devel@gnu.org
To: Maxime Devos <maximedevos@telenet.be>
Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Mon Oct 02 18:13:54 2023
Return-path: <guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org>
Envelope-to: guile-devel@m.gmane-mx.org
Original-Received: from lists.gnu.org ([209.51.188.17])
	by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
	(Exim 4.92)
	(envelope-from <guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org>)
	id 1qnLYP-0005aZ-OU
	for guile-devel@m.gmane-mx.org; Mon, 02 Oct 2023 18:13:53 +0200
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <guile-devel-bounces@gnu.org>)
	id 1qnLY4-0006Ma-5Y; Mon, 02 Oct 2023 12:13:32 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <maxim.cournoyer@gmail.com>)
 id 1qnLY2-0006KG-Nw
 for guile-devel@gnu.org; Mon, 02 Oct 2023 12:13:30 -0400
Original-Received: from mail-ua1-x936.google.com ([2607:f8b0:4864:20::936])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <maxim.cournoyer@gmail.com>)
 id 1qnLY1-0001LC-68
 for guile-devel@gnu.org; Mon, 02 Oct 2023 12:13:30 -0400
Original-Received: by mail-ua1-x936.google.com with SMTP id
 a1e0cc1a2514c-7b0767462adso1409018241.1
 for <guile-devel@gnu.org>; Mon, 02 Oct 2023 09:13:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1696263207; x=1696868007; darn=gnu.org;
 h=mime-version:user-agent:message-id:in-reply-to:date:references
 :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=FcdxiWihnoTaOQM2CMAWZGfbNPieCfCIkSWwyCfsAzo=;
 b=cVRqYGlMEIgTFDGdZJ06ype1m5oF3OgsgxrFlJBnq3HQ+tq+tRqjO4p16VAa/FixtS
 YHe2+LWuwqBqoYSsXU/O0EFNa4bxjDL0Sf/Sd4Oo3/udXQAyQcGVVDspQ+8KD2wREsfl
 /TCjh73JoMlsaNpDKyd+i7iygLSfN4h9ewxyr16CefkfsStrvD+nRC/6+lS6y64YCVSU
 BbAqznJcZS60Kl503tzmrR1LuaqDonwb0OKsjRgdFMnwJG9e2yv604Mc9BFLMMlGSX0x
 g6ptKAHuupicHS+e1H6WTQkFHqevNxkSawfvVpA/Q+HdYTh6iGyWDEVxsgem8bujiiOL
 YBJQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1696263207; x=1696868007;
 h=mime-version:user-agent:message-id:in-reply-to:date:references
 :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=FcdxiWihnoTaOQM2CMAWZGfbNPieCfCIkSWwyCfsAzo=;
 b=iTLkilRr+r5Xkx9wEyowy/W9lgCG0/x2UYbqT0guU6A5Ngg0muaenv6elER57zDCm9
 E/ruzerlPnhjDFRXlBUr+Zj2L3dl5mYGYpqzzfHmfot8bDYc+z3Xlm29vfgrTQEijqAg
 kePI78xCFPPyiVDpEgMch0+EOuQg2ePH/ADzoIBL3rjlPuzqyWeaZxyqYn2ZILzTo3Xo
 aJOCcFA1gxs7YEGqKrvoGTQ/xoBGQVE977PtSI0IwAu81HQx11zBU1lboIkGCXvZ7B4a
 L7JHhInZ20ra8j1030HYYWLZ2i8FTcdML05lDIo1CJzDvOG/8eVlBJrwlaMhsg/rVZ9M
 T0BQ==
X-Gm-Message-State: AOJu0Yzb9xik9zy79OU7Z/IiYgo2DoKYZF97LSRXb8jV4/FoQ+1yGPGQ
 w1YxP4wtMEheiiN6o/kddBlClExTMDI=
X-Google-Smtp-Source: AGHT+IGa2WkLlnfzJ57aQ8AjBxWQ9ZFdeq+1z5scVVo9MXice6t/j+dgZcPiGfF61e+nxTGcXiAe4Q==
X-Received: by 2002:a05:6102:51a:b0:44e:ac98:c65d with SMTP id
 l26-20020a056102051a00b0044eac98c65dmr7354900vsa.27.1696263207251; 
 Mon, 02 Oct 2023 09:13:27 -0700 (PDT)
Original-Received: from hurd (dsl-10-136-90.b2b2c.ca. [72.10.136.90])
 by smtp.gmail.com with ESMTPSA id
 c17-20020a0cca11000000b0065b21f1b687sm5497317qvk.80.2023.10.02.09.13.26
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 02 Oct 2023 09:13:26 -0700 (PDT)
In-Reply-To: <6f5ace52-5ade-cfe2-bbf6-22562db70206@telenet.be> (Maxime Devos's
 message of "Thu, 28 Sep 2023 16:23:58 +0200")
Received-SPF: pass client-ip=2607:f8b0:4864:20::936;
 envelope-from=maxim.cournoyer@gmail.com; helo=mail-ua1-x936.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: guile-devel@gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Developers list for Guile,
 the GNU extensibility library" <guile-devel.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/guile-devel>,
 <mailto:guile-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/guile-devel>
List-Post: <mailto:guile-devel@gnu.org>
List-Help: <mailto:guile-devel-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guile-devel>,
 <mailto:guile-devel-request@gnu.org?subject=subscribe>
Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org
Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org
Xref: news.gmane.io gmane.lisp.guile.devel:22005
Archived-At: <http://permalink.gmane.org/gmane.lisp.guile.devel/22005>

Hi Maxime,

Maxime Devos <maximedevos@telenet.be> writes:

> Something I didn't notice previously:
>
> Op 25-09-2023 om 16:29 schreef Maxim Cournoyer:
>> +  if (scm_is_string (args)) {
>> +      /* C code written for 3.9 and earlier expects this function to
>> +         take a single argument (the file name).  */
>> +      filename = args;
>> +      depth = scm_from_int(0);
>> +    }
>
> IIUC, args is always a list and never a string.  However, it might be
> a list of one element (being a string) or two elements.

Surprisingly perhaps, this works, I guess because a string is an array.
See the 2009 commit 31ab99de563027fe2bceb60bbd712407fcaf868e which
exploits the same feature.

>>+  else {
>>+    /* Starting from 3.10, this function takes 1 required and 1 >optional
>>+       arguments. */
>>+    long len;
>>+
>>+    SCM_VALIDATE_LIST_COPYLEN (SCM_ARG1, args, len);
>>+    if (len < 1 || len > 2)
>>+      scm_error_num_args_subr (FUNC_NAME);
>>+
>>+    filename = SCM_CAR (args);
>>+    SCM_VALIDATE_STRING (SCM_ARG1, filename);
>>+
>>+    depth = len > 1 ? SCM_CADR (args) : scm_from_int(0);
>
> While I suppose this would work, you are using the rest argument to
> manually implement optional elements.  I think it would be quite a bit
> simpler to just use the optional elements instead. (I.e., set opt=1
> instead of rst=1 and keep req=1 in SCM_DEFINE).
>
> Adding an extra argument is, however, a C API and ABI break, so I'd
> rename it to scm_primitive_load2 and let scm_primitive_load be a small
> wrapper for scm_primitive_load2.
>
> ... now I think about it and re-read the C comments, maybe the (lack
> of) C API/ABI break is why you are using rest arguments here?  I think
> a new function is cleaner and less risky though -- I don't think you
> are supposed to do (primitive-load (list "a" 0)) in Scheme yet this
> code allows that.
>
> Likely the same applies to s_scm_primitive_load_path.

Yes, the extra complications on the C side are to preserve backward
compatibility.

>> * doc/guile-api.alist (%load-announce, %load-hook): Add DEPTH argument.
>
> Technically backwards-incompatible but I don't know any actual users
> of %load-hook etc. outside Guile itself.

%load-hook is carefully crafted as to accept both one or two arguments
(for backward compatibility).  I didn't pay attention to %load-announce
and I'm surprised it's a public API, as its sole function seems to be
the default %load-hook value.  

-- 
Thanks,
Maxim