From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Dr. Arne Babenhauserheide" Newsgroups: gmane.lisp.guile.user Subject: Re: How to gradually write a procedure using Guile? Date: Fri, 03 May 2024 13:49:35 +0200 Message-ID: <87h6ffyv1s.fsf@web.de> References: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35372"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.12.4; emacs 30.0.50 Cc: guile-user@gnu.org To: =?utf-8?B?SsOpcsOpbXk=?= Korwin-Zmijowski Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Fri May 03 13:50:42 2024 Return-path: Envelope-to: guile-user@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 1s2rR3-0008wC-2M for guile-user@m.gmane-mx.org; Fri, 03 May 2024 13:50:41 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2rQ9-0005r6-60; Fri, 03 May 2024 07:49:45 -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 1s2rQ7-0005qg-Lm for guile-user@gnu.org; Fri, 03 May 2024 07:49:43 -0400 Original-Received: from mout.web.de ([217.72.192.78]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2rQ4-0001RI-OU for guile-user@gnu.org; Fri, 03 May 2024 07:49:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1714736976; x=1715341776; i=arne_bab@web.de; bh=TPmelV7MxI4cWV1XSfnrzFBPw8EGH3+uH/13bptQmHE=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=eN7gScXoEEjXMk5we7H+RSKdEOP2l8FaEtgeW56xuBYHkseLIJUMZeCDELhVmlLi Xdm5rWk9Yni/FrwN9pKeono/aplaid0UI8oxLLVrVFVr934mSYdkvdOMSsXMSG6Db HoEKLrTcpv4TpwhbihLep3Flq47ozhbt5E1Iwu3578WSG92+DJRP2mXutmhNNy9uh r+s26QJHrBBTASFUjCnAmMcAx413/+YM4RieNRoXxH8s8xUy8f+kCsb81IlA4fbz5 SnolFX5toszpO+CmiAP0c9GRFxr5X939NA6XsqqSzMaL+hMDni3HSB0MYXj9tclUh CDxfITlvsdUISKGERA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Original-Received: from fluss ([84.165.16.40]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MhFhg-1sY5Qo2IxG-00et3i; Fri, 03 May 2024 13:49:36 +0200 In-Reply-To: (=?utf-8?B?IkrDqXLDqW15?= Korwin-Zmijowski"'s message of "Fri, 3 May 2024 10:45:11 +0200") X-Provags-ID: V03:K1:BqAD9VW6ta+SzWv2xzjIMk30sDc0tZgt+oiCxFdyq916QYLkcCP v85BE5Ao2Jg0rUajguoufbrFwT0rTUIRjyr1c355CjoGnEzPt0fgSj3WvhBVL9+gULZ7wF7 jtRJBoLiuwhTMSkhZarJwsYZmEIEE8bA/A5Mq3k7CNOxPDXMjuH2g+xcSi8fBgWLF45DFlP zfZ/cfTxK+vG8i/TVKLBA== UI-OutboundReport: notjunk:1;M01:P0:3R4RdFcMhFs=;PaNz5hXvd+v2bdLxPW2kY9f0bfZ D60cMTj/xY7SQK1DKWYgNlK3V7rmo7thT4+DjMELTFAQiVtYrP0f07juWlaZTyQaIkHzs2iKh xY0NWzZRhQFRJ5wCVI6UGF12izhMWSKNqIFzOIkC4ZiYE8zgCdyoo6UX8pK4oG8DzSsr+MAKL V+JYoi7BTMHJMmgx5igtKG1x68eqj33CVTslQJaDkWRm9UOU9xU4p5UQ2QyMCGYwjZf5bhbm8 UMr9WRJ2zU4TIs+POvcdgtsogPU2ftnAXRls0swnrh8ayeMVwWP7iRfyzhtQ9Si4zCIWfF8Wz /Yl9Ly20hTQy4IRr5BUtR8sJJnL0Kb3kXiXq/LtxVgykNl0qnEovayCGnS7DAZfQd1BoZgMoQ fiEzQtpBotX/TWClLNvs1t5rf9gjvxRnOv0zB5a6VfB7LOVV3dx1KRC7Z4OrUj1YLM1x2+txN YW/nUikw2CaoK8BRvEjXtWJGX0QyV87lGpjGYT4ZIvCJVJGjRJkJoLmcCUSzrwZt6VGmle08t EdrisOJ4FJhKvMAiG+b1A0W4FhqLmrwetHg0giPr9CXTICGN239vXJoaitxyfdC4KAzV14N2s 3AF31E4dngr3FXs77lLqhze+R4kaS9H8JAo8XZ4VsYBJ8O4/OvdwePN8SoLtJuRYUglV6GJF/ fLihoITnM3XRTr7qBq5Q0RjcHRSzdRuFD+W0LGwih8oOyHsEcD6IkTeR0YGAbmjeIB3SUdQ3n obeNEonsAzAAEEs1338hETHHpB5wn0ioBaO0tYSs5yZDlOT8Cyox6KkZ/p5nf8z2398VwNVd Received-SPF: pass client-ip=217.72.192.78; envelope-from=arne_bab@web.de; helo=mout.web.de 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19580 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Thomas, I usually work by redefining the whole procedure and running it. Typically I start with the minimal procedure (define (hello) #f) Then =E2=80=94 for nicely testable procedures =E2=80=94 I add a doctest and= get it to run: (define (hello) "Say hello." #((tests ('answers (test-equal "Hello" (hello))))) "Hello") Then I run the tests from Emacs: ;; eval in emacs: (progn (defun test-this-file () (interactive) (save-curre= nt-buffer) (async-shell-command "./hello.scm --test")) (local-set-key (kbd = "") 'test-this-file)) (this relies on https://hg.sr.ht/~arnebab/wisp/browse/examples/doctests.scm) For a game I work on with my kids, I made the module non-declarative, so I could replace all bindings at runtime: (define-module (hello) #:export (hello) #:declarative? #f) Then I could start the kooperative repl server: (import (system repl coop-server)) (define (update dt (poll-coop-repl-server repl))) This relies on Chickadee. See https://notabug.org/ZelphirKaltstahl/guile-ch= ickadee-examples/src/master/example-03-live-coding-repl/main.scm#L15 Then I could open that server, in the repl use ,m (hello) to enter the module, and replace the procedure at runtime to see the effect. I replace it by simply pasting the procedure code into the REPL. (after ,m (hello)) Best wishes, Arne J=C3=A9r=C3=A9my Korwin-Zmijowski writes: > Hi Tomas ! > > You have to make choices in the code weather you want to leverage the > REPL or not. That's fine. I incentivize you to try different > approaches and see how it feels while you work. So you can make your > choices based on actual experience. > > What comes to my mind right now is pretty close to what you imagined. > > You could keep your code as is and on a new line evaluate `(foo)` > every time you make a relevant progress inside the `foo` definition. > Write the first step, see if you can get the right result here, then > go on the next step or fix your code.=E2=80=A6 This is my go to approach > (which I follow in a TDD manner). > > Or you could define `x` and `y` in the REPL as you suggested it and > then write definitions of your steps, one at a time (the original > question remains, how to write the step interactively?). Then, when > all the steps are working, try to integrate them in a `foo` procedure > and see how it goes=E2=80=A6 > > J=C3=A9r=C3=A9my > > Le 03/05/2024 =C3=A0 02:24, Tomas Volf a =C3=A9crit=C2=A0: >> Hello, >> >> I am looking for a workflow advice. I am using Emacs with Geiser. >> >> I am trying to write couple of procedures that are very imperative and I= am not >> sure how to do that nicely in REPL. For example, let us assume I have a >> procedure of following character: >> >> (define (foo) >> (let* ((x (bar-x)) >> (y (bar-y x))) >> (step1 x) >> (step2 y) >> (step3 x y) >> ...)) >> >> Now, each step can be a procedure call, of just few expressions. Now I = would >> like to write the additional steps while utilizing REPL somehow, but I a= m not >> sure what is an efficient way. >> >> Can I somehow run just to the `...' and get a REPL there so that I could= C-x C-e >> the steps within the let* (for x and y)? Should I just (temporarily) >> >> (define x (bar-x)) >> (define y (bar-y x)) >> >> in the REPL so that I can use C-x C-e on the steps? I expect that to ge= t messy >> once the lets start nesting for example. >> >> How do you do it? Are there any resources (blog posts, toots, videos, .= ..) >> regarding guile developer's workflow? I did read few, and I (think I) k= now the >> fundamentals of Geiser and the REPL, but I am straggling a bit in this c= ase not >> to fall back to the "normal" way of "write a function, run it whole agai= nst a >> test". Since this is Scheme, and I *can* evaluate single expressions in= the >> procedure body, I would like to use that to my advantage. Somehow. >> >> I realize this is a very open-ended question/email. >> >> Have a nice day, >> Tomas Volf >> >> -- >> There are only two hard things in Computer Science: >> cache invalidation, naming things and off-by-one errors. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJEBAEBCAAuFiEE801qEjXQSQPNItXAE++NRSQDw+sFAmY0z08QHGFybmVfYmFi QHdlYi5kZQAKCRAT741FJAPD662xEACqUyjHZGE7q2/36KfrvFU9l6HLJm58U1RQ o50SvVRyk/hdkIbZbD3HeeaTUN5Cyg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