From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Christine Lemmer-Webber <cwebber@dustycloud.org>
Newsgroups: gmane.lisp.guile.devel
Subject: Re: [PATCH] add language/wisp to Guile?
Date: Mon, 02 Oct 2023 10:48:46 -0400
Message-ID: <87il7pjcnb.fsf@dustycloud.org>
References: <87h6w2fkz8.fsf@web.de> <87ttrblrys.fsf@dustycloud.org>
 <bbd37758-20f0-381c-6fd8-a5e84ab2ecfe@telenet.be>
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="8162"; mail-complaints-to="usenet@ciao.gmane.io"
User-Agent: mu4e 1.10.5; emacs 28.2
Cc: "Dr. Arne Babenhauserheide" <arne_bab@web.de>, 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 16:57:26 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 1qnKMO-0001io-8E
	for guile-devel@m.gmane-mx.org; Mon, 02 Oct 2023 16:57:25 +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 1qnKM7-0007fX-RY; Mon, 02 Oct 2023 10:57:07 -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 <cwebber@dustycloud.org>)
 id 1qnKM5-0007f5-Jj
 for guile-devel@gnu.org; Mon, 02 Oct 2023 10:57:05 -0400
Original-Received: from wout3-smtp.messagingengine.com ([64.147.123.19])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <cwebber@dustycloud.org>)
 id 1qnKM3-0003a0-4m
 for guile-devel@gnu.org; Mon, 02 Oct 2023 10:57:05 -0400
Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46])
 by mailout.west.internal (Postfix) with ESMTP id C4C523200B94;
 Mon,  2 Oct 2023 10:56:58 -0400 (EDT)
Original-Received: from mailfrontend2 ([10.202.2.163])
 by compute2.internal (MEProxy); Mon, 02 Oct 2023 10:56:59 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dustycloud.org;
 h=cc:cc:content-transfer-encoding:content-type:content-type
 :date:date:from:from:in-reply-to:in-reply-to:message-id
 :mime-version:references:reply-to:sender:subject:subject:to:to;
 s=fm2; t=1696258618; x=1696345018; bh=vfiDhe6J6kXh1rkC2MHDeuPcm
 0ETVqtqdhLsHCqztLk=; b=c4o1saHpMKl1RnGpowHoC+FUqFKcbcZC5JpPyl+I6
 0k+tcEGDYDgRfvQsvb+h2AAQmGtxtALCYDfMOpy3Bqg1Lo3J8Gw/wZUMY4Qn/3lw
 l6dQU4tHdM+hBQHGNammPl6NsAfvd6PxkVHe1HgDOFIgBcFhiPJBNsZUb7isO3ad
 Y4eTbdddft5Oh5dvFDWCmmzib+h0cPjy+HmAZfzCMIJ95+RNMRUamJI4J1Rkgd+7
 N8LLPJtY2oaJMP89CI4/mQRMpCEk+Y9wRyew9qlvYEgOH9/3WaQKGaf6YZonhZce
 j2Iuc+BbL8rbojK+GCaeJKFlCjYFzMOWIZlk4K/cnVJZA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:content-type:date:date:feedback-id:feedback-id
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:sender:subject:subject:to:to:x-me-proxy
 :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=
 1696258618; x=1696345018; bh=vfiDhe6J6kXh1rkC2MHDeuPcm0ETVqtqdhL
 sHCqztLk=; b=pHhpr9SuGhYZPKrfhauW6AHxgAGaROrB17tMnsrBwQjMuJn5D49
 r/ao9XOT3AH7v9NW9bLwxK/0b0MlshVH6ZKJRvzecoEnP8zGHQKYx/yyIhrkaErE
 5IQeuPIpieaMgK4XqkfWm/gAPRyMTayvjrrKd6BIZHYAd64zak240PDzwF5TLuqD
 daob7/O3s1EmnwdXSNC6u8ec5hXO37Jmuw5hfxD6+IeMM4kxuIlAZY4Khgu7Po8W
 TlvoWdF5NFKyzpKRwuCGsJAR8a2NwUNpxLZwMFmUU2SDhmT+hOx5V/POCkM5YPOe
 aBrjJFARqg17zD5CZAmFDkl4rl/4CNHCxHA==
X-ME-Sender: <xms:OtoaZUhgyj9XdryaOAkFriN98kKU7htC0MA5WxmWPmsf8QxZpCqmRA>
 <xme:OtoaZdDKAXZ2mrt0aN0wgBVcRV1I4JUuloPt2sGFGOAcZt2Yf115h2hOz-Ks70-qJ
 BrPI6ZB01YBxaO-L2w>
X-ME-Received: <xmr:OtoaZcGSGip5qBM5w2eUSnS5yFSOH43AygFDRUYbxRk8PwWkBd6LGQtwXMr1CRDs0ji9wxHMR4D5-SzXE5AYol1L>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdelgdekgecutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
 uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc
 fjughrpehffgfhvfevufffjgfkgggtgfesthhqredttderjeenucfhrhhomhepvehhrhhi
 shhtihhnvgcunfgvmhhmvghrqdghvggssggvrhcuoegtfigvsggsvghrseguuhhsthihtg
 hlohhuugdrohhrgheqnecuggftrfgrthhtvghrnhepkeffgfeugeeiieeuuefftddtkefg
 vdejvdelvefftdevueetfedtuedtvdehffeunecuffhomhgrihhnpehgihhtlhgrsgdrtg
 homhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegt
 figvsggsvghrseguuhhsthihtghlohhuugdrohhrgh
X-ME-Proxy: <xmx:OtoaZVRO-bmvfXSpQLdLkk8NPGD7qa5gLN39IwdfDNcJolOXrrMX3g>
 <xmx:OtoaZRyWOXW-R2DAz5ryHCrKSWftbpo2MDCyNVYagGEw9SmRIVRISg>
 <xmx:OtoaZT6uGNHpXh8oQf15yTFuUgkWQkgpS2BAmP5vz43Abp8t4eW2dQ>
 <xmx:OtoaZSpQRGphuwwa4ruFa33Xxu8DGWdhBpfrUott1uc1lH9zYH3NYg>
Feedback-ID: i006446df:Fastmail
Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon,
 2 Oct 2023 10:56:57 -0400 (EDT)
In-reply-to: <bbd37758-20f0-381c-6fd8-a5e84ab2ecfe@telenet.be>
Received-SPF: pass client-ip=64.147.123.19;
 envelope-from=cwebber@dustycloud.org; helo=wout3-smtp.messagingengine.com
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 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,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-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:22003
Archived-At: <http://permalink.gmane.org/gmane.lisp.guile.devel/22003>

Maxime Devos <maximedevos@telenet.be> writes:

> [[PGP Signed Part:Undecided]]
> Op 30-09-2023 om 15:17 schreef Christine Lemmer-Webber:
>> Haven't fully caught up on this thread, but as a side note I have a
>> mostly-finished implementation of a Wisp parser which takes a very
>> different approach than Arne's, and was more understandable to me
>> personally, a bit more functional and recursive-descent style.
>> I could make it available if anyone is curious.
>> Would love to see Wisp in Guile proper!
>
> I think I technically can't count as =E2=80=98curious=E2=80=99 here, as I=
 don't think
> I'll actually read this other implementation, but I would be
> interested in it nonetheless (to potentially replace Arne's
> implementation later, once it's complete), because it sounds like you
> might have avoided the REPR (*) bug thing from Arne's implementation.
>
> (*) Extremely unlikely to be a problem in practice, but still a bug.
>
> Best regards,
> Maxime Devos.

Well it looks like I did make it available already, I just forgot, and
didn't advertise it much:

https://gitlab.com/dustyweb/rewisp/-/blob/main/rewisp.scm?ref_type=3Dheads

It really isn't very complete, but here's some of the example data I was
using:

(define wisp-fac-noinfix-repeat
  "\
define : factorial n  ; foo
__  if : zero? n
____   . 1
____   * n : factorial : - n 1

define : factorial n
__  if : zero? n
____   . 1
____   * n : factorial : - n 1")


scheme@(rewisp)> ,pp (parse-lines->sexp (call-with-input-string wisp-fac-no=
infix-repeat read-wisp-lines))
$6 =3D
((define (factorial n)
   (if (zero? n) 1 (* n (factorial (- n 1)))))
 (define (factorial n)
   (if (zero? n) 1 (* n (factorial (- n 1))))))


What's kind of interesting is to look at it before the parse-lines->sexp
step though:

scheme@(rewisp)> ,pp (call-with-input-string wisp-fac-noinfix-repeat read-w=
isp-lines)
$7 =3D
(#<<line> indent: 0 args: (#<syntax:unknown file:1:0 define> (#<syntax:unkn=
own file:1:9 factorial> #<syntax:unknown file:1:19 n>))>
 #<<line> indent: 4 args: (#<syntax:unknown file:2:4 if> (#<syntax:unknown =
file:2:9 zero?> #<syntax:unknown file:2:15 n>))>
 #<<line> indent: 7 args: (#<<DOT> source-loc: #(#f 2 7)> #<syntax:unknown =
file:3:9 1>)>
 #<<line> indent: 7 args: (#<syntax:unknown file:4:7 *> #<syntax:unknown fi=
le:4:9 n> (#<syntax:unknown file:4:13 factorial> (#<syntax:unknown file:4:2=
5 -> #<syntax:unknown file:4:27 n> #<syntax:unknown file:4:29 1>)))>
 #f
 #<<line> indent: 0 args: (#<syntax:unknown file:6:0 define> (#<syntax:unkn=
own file:6:9 factorial> #<syntax:unknown file:6:19 n>))>
 #<<line> indent: 4 args: (#<syntax:unknown file:7:4 if> (#<syntax:unknown =
file:7:9 zero?> #<syntax:unknown file:7:15 n>))>
 #<<line> indent: 7 args: (#<<DOT> source-loc: #(#f 7 7)> #<syntax:unknown =
file:8:9 1>)>
 #<<line> indent: 7 args: (#<syntax:unknown file:9:7 *> #<syntax:unknown fi=
le:9:9 n> (#<syntax:unknown file:9:13 factorial> (#<syntax:unknown file:9:2=
5 -> #<syntax:unknown file:9:27 n> #<syntax:unknown file:9:29 1>)))>)

So what it does is rewisp builds up a set of lines and parses each
line individually, noting its indentation level and the "arguments" that
appear in it.  It then has a separate step to assemble it into a sexp
structure by examining the indentation level and whether or not it sees
the special <DOT> record.  Guile's syntax records are used so that this
would be able to work correctly with the rest of Guile's tools.

So, that's it... first, read each line one by one, don't try to figure
out its relationship to the other lines, and we have a flat structure.
Next, turn that flat structure into a nested structure.

I thought the design was pretty good.

 - Christine