* How to use guile in a development process
@ 2021-04-29 0:35 Anthony Quizon
2021-04-29 2:19 ` Nala Ginrut
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Anthony Quizon @ 2021-04-29 0:35 UTC (permalink / raw)
To: guile-user
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?
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?
Or is there a faster way to do things?
Thanks,
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to use guile in a development process
2021-04-29 0:35 How to use guile in a development process Anthony Quizon
@ 2021-04-29 2:19 ` Nala Ginrut
2021-04-29 7:26 ` Dr. Arne Babenhauserheide
2021-04-29 8:16 ` Adriano Peluso
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Nala Ginrut @ 2021-04-29 2:19 UTC (permalink / raw)
To: Anthony Quizon; +Cc: Guile User
Hi Anthony!
You may use "guile -L ." to add the current path to the load path, then you
can import the module.
Best regards.
On Thu, Apr 29, 2021, 08:57 Anthony Quizon <anthoq88@gmail.com> wrote:
> 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?
> 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?
> Or is there a faster way to do things?
>
> Thanks,
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to use guile in a development process
2021-04-29 2:19 ` Nala Ginrut
@ 2021-04-29 7:26 ` Dr. Arne Babenhauserheide
0 siblings, 0 replies; 7+ messages in thread
From: Dr. Arne Babenhauserheide @ 2021-04-29 7:26 UTC (permalink / raw)
To: Nala Ginrut; +Cc: guile-user, Anthony Quizon
[-- Attachment #1: Type: text/plain, Size: 1713 bytes --]
Hi Anthony,
I typically add doctests to the file (self-written) and bind F9 to
running the file with --test. Here’s an example:
https://hg.sr.ht/~arnebab/dryads-wake/browse/dryads-wake.w?rev=31cced555f13#L16
;; for emacs (progn (defun test-this-file () (interactive) (save-current-buffer) (async-shell-command (concat (buffer-file-name (current-buffer)) " --test"))) (local-set-key (kbd "<f9>") 'test-this-file))
Best wishes,
Arne
Nala Ginrut <nalaginrut@gmail.com> writes:
> Hi Anthony!
> You may use "guile -L ." to add the current path to the load path, then you
> can import the module.
>
> Best regards.
>
> On Thu, Apr 29, 2021, 08:57 Anthony Quizon <anthoq88@gmail.com> wrote:
>
>> 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?
>> 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?
>> Or is there a faster way to do things?
>>
>> Thanks,
>>
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to use guile in a development process
2021-04-29 0:35 How to use guile in a development process Anthony Quizon
2021-04-29 2:19 ` Nala Ginrut
@ 2021-04-29 8:16 ` Adriano Peluso
2021-04-29 14:49 ` Jérémy Korwin-Zmijowski
2021-04-30 2:34 ` Tim Meehan
3 siblings, 0 replies; 7+ messages in thread
From: Adriano Peluso @ 2021-04-29 8:16 UTC (permalink / raw)
To: Anthony Quizon, guile-user
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to use guile in a development process
2021-04-29 0:35 How to use guile in a development process Anthony Quizon
2021-04-29 2:19 ` Nala Ginrut
2021-04-29 8:16 ` Adriano Peluso
@ 2021-04-29 14:49 ` Jérémy Korwin-Zmijowski
2021-04-30 2:34 ` Tim Meehan
3 siblings, 0 replies; 7+ messages in thread
From: Jérémy Korwin-Zmijowski @ 2021-04-29 14:49 UTC (permalink / raw)
To: Anthony Quizon, guile-user
Le jeudi 29 avril 2021 à 10:35 +1000, Anthony Quizon a écrit :
> 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?
I think there is not anything typical in the Guile community.
I usually execute Guile scripts from the command line and I use the
REPL for exploratory work only. But I feel I should use the REPL more
than I do. I am reading all I can find about REPL practices to find
inspiration.
I follow the TDD workflow. So I run my test harness this way :
$ guile -L . tests/xxxx-test.scm
I fire this command anytime I change a file using a watch-based script.
I edit code using Emacs and its Geiser extension to explore Guile
features.
> Or is there a faster way to do things?
Automation. haha
P.S: would you like to join me to code together so I can show what I
wrote above ?
We could pair-program for 1h :-)
Cheers,
Jérémy
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to use guile in a development process
2021-04-29 0:35 How to use guile in a development process Anthony Quizon
` (2 preceding siblings ...)
2021-04-29 14:49 ` Jérémy Korwin-Zmijowski
@ 2021-04-30 2:34 ` Tim Meehan
2021-04-30 11:22 ` Leo Butler
3 siblings, 1 reply; 7+ messages in thread
From: Tim Meehan @ 2021-04-30 2:34 UTC (permalink / raw)
Cc: guile-user
Anthony - thanks for asking that question, I always wind up learning
something interesting on this mailing list.
On Wed, Apr 28, 2021 at 7:57 PM Anthony Quizon <anthoq88@gmail.com> wrote:
> 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?
> 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?
> Or is there a faster way to do things?
>
> Thanks,
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to use guile in a development process
2021-04-30 2:34 ` Tim Meehan
@ 2021-04-30 11:22 ` Leo Butler
0 siblings, 0 replies; 7+ messages in thread
From: Leo Butler @ 2021-04-30 11:22 UTC (permalink / raw)
To: Tim Meehan; +Cc: guile-user
Tim Meehan <btmeehan@gmail.com> writes:
>>
>> How do I load a file from the current path that I'm in?
>> 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?
>> Or is there a faster way to do things?
I use geiser in emacs to run a guile repl and edit source code. This
allows one to write source in a file and compile/load it, or write the
source in the repl and copy it into a file when it is working and either
way works fine.
Leo
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-04-30 11:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 0:35 How to use guile in a development process Anthony Quizon
2021-04-29 2:19 ` Nala Ginrut
2021-04-29 7:26 ` Dr. Arne Babenhauserheide
2021-04-29 8:16 ` Adriano Peluso
2021-04-29 14:49 ` Jérémy Korwin-Zmijowski
2021-04-30 2:34 ` Tim Meehan
2021-04-30 11:22 ` Leo Butler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).