From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Adriano Peluso Newsgroups: gmane.lisp.guile.user Subject: Re: How to use guile in a development process Date: Thu, 29 Apr 2021 10:16:03 +0200 Message-ID: <870f3cf9e676b0dc4d95ba5956aba07a6d16d195.camel@riseup.net> References: Reply-To: randomlooser@riseup.net Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24068"; mail-complaints-to="usenet@ciao.gmane.io" To: Anthony Quizon , guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Thu Apr 29 10:16:25 2021 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 1lc1qS-0006AQ-UB for guile-user@m.gmane-mx.org; Thu, 29 Apr 2021 10:16:25 +0200 Original-Received: from localhost ([::1]:51324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lc1qS-0004QT-1r for guile-user@m.gmane-mx.org; Thu, 29 Apr 2021 04:16:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lc1qG-0004QN-Jy for guile-user@gnu.org; Thu, 29 Apr 2021 04:16:12 -0400 Original-Received: from mx1.riseup.net ([198.252.153.129]:40436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lc1qE-0008St-Cx for guile-user@gnu.org; Thu, 29 Apr 2021 04:16:12 -0400 Original-Received: from fews1.riseup.net (fews1-pn.riseup.net [10.0.1.83]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "Sectigo RSA Domain Validation Secure Server CA" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4FW7cR6ThCzDxbY; Thu, 29 Apr 2021 01:16:07 -0700 (PDT) X-Riseup-User-ID: 35AF1CA48B84DF8650BDA7B0D1732ACF158A52A43D45BAC802BCEC620171E5CD Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews1.riseup.net (Postfix) with ESMTPSA id 4FW7cQ5p0Tz5vbG; Thu, 29 Apr 2021 01:16:06 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=198.252.153.129; envelope-from=randomlooser@riseup.net; helo=mx1.riseup.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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.23 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" Xref: news.gmane.io gmane.lisp.guile.user:17471 Archived-At: Il giorno gio, 29/04/2021 alle 10.35 +1000, Anthony Quizon ha scritto: > Hello, > > I'm having trouble finding a good development process with guile. > > I have a file foo.scm and I'm trying to load it into the repl. > However, I couldn't find any documentation on how to easily do this. > I tried looking up ",help module" in the repl which told me to use > ",load > FILE". > But when I tried this I got the error "In procedure primitive-load- > path: > Unable to find file "system/repl/foo.scm" in load path" > > I don't know where to look to change my load file for the repl. > > I read in a forum somewhere to add (add-to-load-path ".") in my .guile > file > but that didn't work. > > How do I load a file from the current path that I'm in? at the Guile REPL, you can issue: scheme@(guile-user)> (load "path/to/your/file.scm") The path/to/your/file.scm is relative to some position in the file system Which one ? You can know that with scheme@(guile-user)> (getcwd) So, say, for example, that getcwd returns some path scheme@(guile-user)> (getcwd) $1 = "/home/anthony" and say that you project is in /home/anthony/projects/guile-musings/ In order to load your file, tou need to issue scheme@(guile-user)> (load "projects/gule-musings/foo.scm") That will compile your file and store the compiled file in some position buried in your home folder In this way, when you'll load the file again it won't be recompiled, unless it has changed Now, having to write a long path can be annoying, can't it ? If you have the so called "read-line" thing activated, you can use the up arrow on your keyboard to scroll up the lines that you issied previoulsy, so you won't have to type the path again In a file named ".guile" in your home folder, paste these 2 lines (use-modules (ice-9 readline)) (activate-readline) then launch Guile again This will give you the read-line thing I suggest you to add 2 more lines to your .guile file (use-modules (ice-9 pretty-print)) (use-modules (texinfo reflection)) this will give you a slighlty less frustrating experience but I won't go into that now, this post would be too long So now there are 2 more things you can consider to lessen the burden of having to load a file every time 1) you can cd to the folder containing your project BEFORE launching Guile So in this Guile session, getcwd will return the path to you project and so (load "foo.scm") will be enough, no long paths 2) At the Guile REPL you can issue (assuming you started Guile in your home folder) scheme@(guile-user)> (chdir "projects/guile-musings") This will change what getcwd returns, as you can guess scheme@(guile-user)> (getcwd) $1 = "/home/anthony/projects/guile-musings" So now you can just scheme@(guile-user)> (load "foo.scm") I hope this helps > But more importantly, what is the typical workflow when using guile? > Do people write files to the filesystem and load them in the repl to > try it > out? Eh, this is a whole different question Honestly, I'm a bit confused about this myself, after so many years of fighting with Guile So there are several levels of interaction with Guile you can keep 2 windows opened, one with a Guile REPL where you can try out things nad onother one with a Guile source file You can load the file in the REPL and then continue trying out things using stuff that was defined in the file this is level 1 With some more setup and machinery, you can have unit tests available in the terminal and maybe even in the REPL (I'm not sure) So you can write little bits and test then out as soon as you want There's a Guiler (Jecko) who wrote a series of blog posts about using extensively unit testing to develop e Guile things Another possibility is an Emacs module called Geiser Geiser provides some sort of an IDE for Guile, based on Emacs With IDE I mean you can have things like autocompletion (if you can deal with the Emacs packages quagmire) and jump to definition and interactively consult the documentation for a procedure Another possibility is a project called Guile Studio Guile Studio is also based on Emacs but it aims to mimick Racket's DrRacket, where you have 2 panes, in one you have a REPL and issu code bits at it, in another you have a sort of a canvas where you can see the results of evaluating your code It also has some sort of pictures language, with which you can manipulate 2D drawings with in scheme But it's at a very early stage, so I don't know how usable it is actually There are 2 things that can be frustrating that I want to suggest you 1) Guile stores some information about your source code in compiled files so error messages can be slightly more accurate/informative when using compiled files If you are issuing bits of code at the REPL the error messages could be less helpful 2) the debugger doen't work yet. It can do some things but not all you'd expect from something called "debugger" (as far as I understand) So people actually use a procedure called "pk" pk prints its argument to the REPL (so you can see what it is) and returns it as it is So say you want to see what some variable buried deep in your code is, you can wrap it in a call to pk like this (some-procedure (pk my-thing)) some-procedure will receive your thing but you'll also see it printed I hope this helps too