From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jacob Hrbek Newsgroups: gmane.lisp.guile.devel Subject: Re: Feature request: Ability to document variables like defvar in elisp Date: Sat, 05 Nov 2022 04:19:16 +0000 Message-ID: References: <890c5ce4-8191-54a6-dcd3-3c4b0f846415@abou-samra.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32272"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "guile-devel@gnu.org" To: Jean Abou Samra Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sat Nov 05 14:14:12 2022 Return-path: 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 ) id 1orJ00-00089w-G9 for guile-devel@m.gmane-mx.org; Sat, 05 Nov 2022 14:14:12 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orIz2-0007Y2-7C; Sat, 05 Nov 2022 09:13:12 -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 ) id 1orAeZ-0000xf-Mj for guile-devel@gnu.org; Sat, 05 Nov 2022 00:19:31 -0400 Original-Received: from mail-4318.protonmail.ch ([185.70.43.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orAeW-0003Zo-8P for guile-devel@gnu.org; Sat, 05 Nov 2022 00:19:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rixotstudio.cz; s=protonmail; t=1667621963; x=1667881163; bh=IJQsE4BGR8QGb/1Npu2BBlRpVqbkooujAVpwroaLG9o=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=a1fX3U734swBZiLLtFK7otHqPD/TH6fZkvMxOVNdUHVke/lgBlAp1QOk6qMcbNkMw l1jrW7athDL/sJydLTjWP4bkvO2CqVeNJU8sVhGMFrQnR/nA32DOdlXQGBnbsZeyzv KVd93dQZpG/N/sTrWL4T7pwZEu6qi+RjP6sUB3aLJLFjTERkqvda9PfHnfENGl6p3e 0lTEN5JY4R9FVYj/kb9Xw6FookSCrchfiRvMq0ynlh7dXGzBp/BGIUyu/H5pXdcKu2 J40sObmIAC9rDDnUBFjZ0PFpDyTUYHqtGOFhJcKta2VzHTUPWiRsBOBsqDAcL3A6K2 sZGp2bCKx2L9Q== In-Reply-To: <890c5ce4-8191-54a6-dcd3-3c4b0f846415@abou-samra.fr> Feedback-ID: 30491181:user:proton Received-SPF: pass client-ip=185.70.43.18; envelope-from=kreyren@rixotstudio.cz; helo=mail-4318.protonmail.ch 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 05 Nov 2022 09:13:05 -0400 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "guile-devel" Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:21464 Archived-At: To clarify I don't want to set the docstring to the value, but to the **var= iable name** like elisp, defining the docstring to the value seems insane t= o me. First of all can we agree that the proposed syntax is a good idea that we w= ant implemented?: (define variable value docstring) ^^^^^^^^^ As to me it seems as very logical and intuitive solution. Then if we can't implement it in guile due to it's current limitations then= I propose to track the expected implementation as a bug and in the meantim= e declare e.g. macro in srfi-X that defines the immeiate and then uses the = variable name to set the docstring to the variable name through appropriate= code such as the one provided by Mikael Djurfeldt to be e.g. the familiar = defvar or even define*: (defvar variable value docstring) =3D> (define variable value) =3D> (set-object-property! (module-variable (current-module) 'variable)= 'documentation "Documentation here") So that the common useless comments above variable definition can be remove= d from guile scripts and development environments such as https://github.co= m/Johni0702/guile-language-server adjusted to show the popup in emacs and w= hen guile is able to use the proposed syntax to just s#defvar#define#gm -- Jacob "Kreyren" Hrbek ------- Original Message ------- On Wednesday, November 2nd, 2022 at 9:28 AM, Jean Abou Samra wrote: > Le 02/11/2022 =C3=A0 02:08, Jacob Hrbek a =C3=A9crit : >=20 > > The ability to document variables is critical for many projects such > > as libfive where the variables is used to declares functional computer > > aided design structure and other projects where variables influence > > the workflow. > >=20 > > Thus proposing to change the 'define' behavior for variables to impleme= nt: > >=20 > > (define variable default-value docstring) > > ^^^^^^ > >=20 > > Where docstring is optional and in case it's provided to call for examp= le: > >=20 > > (set-procedure-property! variable 'documentation docstring) >=20 >=20 >=20 >=20 >=20 > The problem is that in Scheme, you cannot attach metadata to immediate > values. According to the Scheme standards and the Guile documentation, >=20 >=20 > (define a 5) > (define b 5) >=20 > (eq? a b) =3D> may be #t or #f >=20 > (eq? a a) =3D> may be #t or #f >=20 >=20 >=20 > So it's considerably more complicated than using an object property, > because that would not work reliably for variables defined to immediates > like numbers and characters. Instead you would need to attach the > metadata to the name you're defining the variable to, like Elisp does, > but unlike Guile does with procedures right now, and it's not as simple > in Scheme due to lexical scoping. >=20 > Best, > Jean