Re: GNU Guile 3.0.5 released

2021-01-07 Thread Tim Van den Langenbergh
On 2021年1月7日木曜日 14時09分08秒 CET you wrote:
> We are delighted to announce GNU Guile release 3.0.5, the latest in the
> 3.0 stable release series.
> 
> Compared to the previous release in the 3.0 series, Guile 3.0.5 can
> compile chained "if" expressions into the equivalent of what a C
> compiler does with "switch".  It also adds some new warning passes.
> 
> Compared to the previous stable series (2.2.x), Guile 3.0 adds support
> for just-in-time native code generation, speeding up all Guile programs.
> See the NEWS extract at the end of the mail for full details.
> 
> 
> The Guile web page is located at http://gnu.org/software/guile/, and
> among other things, it contains a copy of the Guile manual and pointers
> to more resources.
> 
> Guile is an implementation of the Scheme programming language, packaged
> for use in a wide variety of environments.  In addition to implementing
> the R5RS, R6RS, and R7RS Scheme standards, Guile includes full access to
> POSIX system calls, networking support, multiple threads, dynamic
> linking, a foreign function call interface, powerful string processing,
> and HTTP client and server implementations.
> 
> Guile can run interactively, as a script interpreter, and as a Scheme
> compiler to VM bytecode.  It is also packaged as a library so that
> applications can easily incorporate a complete Scheme interpreter/VM.
> An application can use Guile as an extension language, a clean and
> powerful configuration language, or as multi-purpose "glue" to connect
> primitives provided by the application.  It is easy to call Scheme code
> from C code and vice versa.  Applications can add new functions, data
> types, control structures, and even syntax to Guile, to create a
> domain-specific language tailored to the task at hand.
> 
> Guile 3.0.5 can be installed in parallel with Guile 2.2.x; see
> http://www.gnu.org/software/guile/manual/html_node/Parallel-Installations.ht
> ml.
> 
> A more detailed NEWS summary follows these details on how to get the
> Guile sources.
> 
> Here are the compressed sources:
>   http://ftp.gnu.org/gnu/guile/guile-3.0.5.tar.lz   (10MB)
>   http://ftp.gnu.org/gnu/guile/guile-3.0.5.tar.xz   (12MB)
>   http://ftp.gnu.org/gnu/guile/guile-3.0.5.tar.gz   (21MB)
> 
> Here are the GPG detached signatures[*]:
>   http://ftp.gnu.org/gnu/guile/guile-3.0.5.tar.lz.sig
>   http://ftp.gnu.org/gnu/guile/guile-3.0.5.tar.xz.sig
>   http://ftp.gnu.org/gnu/guile/guile-3.0.5.tar.gz.sig
> 
> Use a mirror for higher download bandwidth:
>   http://www.gnu.org/order/ftp.html
> 
> Here are the SHA256 checksums:
> 
>   a484eeffbd4d655b0c05b1382df8d40f1e561f7e71b963065762f6a6a497c675 
> guile-3.0.5.tar.lz
> 2d76fb023d2366126a5fac04704f9bd843846b80cccba6da5d752318b03350f1 
> guile-3.0.5.tar.xz
> 222046009a20b432ffa7c11b8d5a1d9ad0d8627be05cc1e8af612bc54ba2ea85 
> guile-3.0.5.tar.gz
> 
> [*] Use a .sig file to verify that the corresponding file (without the
> .sig suffix) is intact.  First, be sure to download both the .sig file
> and the corresponding tarball.  Then, run a command like this:
> 
>   gpg --verify guile-3.0.5.tar.gz.sig
> 
> If that command fails because you don't have the required public key,
> then run this command to import it:
> 
>   gpg --keyserver keys.gnupg.net --recv-keys
> 4FD4D288D445934E0A14F9A5A8803732E4436885
> 
> and rerun the 'gpg --verify' command.
> 
> This release was bootstrapped with the following tools:
>   Autoconf 2.69
>   Automake 1.16.2
>   Libtool 2.4.6
>   Gnulib v0.1-1157-gb03f418
>   Makeinfo 6.7
> 
> An extract from NEWS follows.
> 
> 
> Changes in 3.0.5 (since 3.0.4)
> 
> * New interfaces and functionality
> 
> ** O(1) compilation of `case' and related expressions
> 
> Guile now optimizes chains of eq? comparisons to constants, resulting in
> O(1) dispatch time, regardless of the length of the chain.  This
> optimization is also unlocked in many cases for `match' expressions with
> many similar clauses whose first differentiator are constants.
> 
> ** New (ice-9 copy-tree) module
> 
> This module includes the `copy-tree' procedure that was previously
> implemented in C and present in the default `(guile)' module.  See
> "Copying" in the manual.
> 
> ** New warning: use-before-definition
> 
> This analysis, enabled at `-W1', issues warnings for programs that use
> top-level variables before they are defined.
> 
> ** New warning: non-idempotent-definition
> 
> This analysis, enabled at `-W1', issues warnings for programs that whose
> use of a variable is ambiguous.  For example, in the program:
> 
>   (define saved-add +)
>   (define + error)
> 
> The intention would seem to be to "save" the value of the base `+'
> procedure, then override it locally.  However if this program is ever
> loaded twice, then the second time it is loaded, `+' will be taken from
> the local binding instead of the import.  Users that want this kind of
> behavior should either use lexical bindings instead of top-level
> bindings, or otherwise rename important 

Re: Question about data structures

2020-11-22 Thread Tim Van den Langenbergh
On Sunday, 22 November 2020 19:48:24 CET Zelphir Kaltstahl wrote:
> Hello Guile Users!
>
> I have a question about data structures.
>
> Recently I read a file and the lines in the file would become a list in
> my Guile program. The file was not super big or anything. However, I
> usually try to avoid having to use `append` or `reverse`, whenever
> possible, considering, that they are O(n) operations and in principle I
> do not want to write code, that uses lists in inefficient ways, when
> there is a more efficient way. That said, I hit a little snag:
>
> When I am reading a file and do not know how many lines there are in the
> file, I can use a normal list and construct it using recursive calls
> like `(cons line (iter ...))` where `iter` is the recursive call and.
> Could also be called `process-next-line` or simply `next`. Since I am
> building a recursive data structure, it is OK to have a non-tail
> position recursive call. Then I would return that list and work with it.
> However, what if I ever need to add a list entry and the order of list
> entry matters? I would either have to use `append`, to add it to the
> end, which would be O(n), or I would have to initially construct the
> list of lines in reversed order from initially, so that I can add by
> simply using `(cons new-entry lines)`. However, when I use the list in
> reverse and ever need to output the lines in the list in their original
> order, I would first need to `reverse` the list again.
>
> OK the whole reversing would not be a problem, if I used a vector to
> store the lines. However, then I would need to know the number of lines
> in the file ahead of time or look at the file once for counting the
> lines, then create the vector of that length and then store the lines in
> it. This seems inelegant again, because I look at the lines of the file
> twice. I could read it in as a list and then use `list->vector`, but
> that will also be an additional O(n) for converting every entry to
> vector element.
>
> If I now think about Python, then I have Python lists (actually arrays?)
> and those can be easily appended to in O(1) and random access is also
> O(1) according to https://wiki.python.org/moin/TimeComplexity. This
> means I do not need to think much about how I will use the lines of a
> file, when reading in the file. A Python list will be appropriate.
>
> So in Guile I sometimes feel some mental overhead of thinking about the
> choice of data structure, which I do not feel in Python. Generally I
> like Guile a lot more, so I would like to know how others deal with
> this. Here are some ideas for it:
>
> 1. I could create some abstraction layer for the "sequence of read
> lines", which I use inside the procedure, which reads in the lines and
> all other code, that works with the lines, so that I can rather easily
> later exchange the data structure. A data abstraction. However, that
> might only hide the complexities of some operations behind the
> abstraction and not reduce them.
>
> 2. Perhaps I want Guile's arrays? (Can they be expanded in O(1)? I do
> seem to remember reading, that Guile vectors are only a special case of
> Guile arrays, so that would mean they are not expandable in O(1).)
>
> 3. Just convert list to vector after reading in the file until I hit a
> problem, where that additional O(n) really becomes a problem. (In my
> current project it is not realistically a problem.) But this does not
> satisfy me. I should learn how to solve the problem in general and use
> the best way to do things.
>
> 4. Perhaps I need to write another data structure, that creates a new
> vector, when the previous one is full, managing the expansion myself.
>
> How do you approach this problem? Is it a problem at all?
>
> Best regards,
> Zelphir
>
>

Hey Zelphir,

If you want to use a FIFO data structure, you may want to check out queues.

They're already in ice-9, under (ice-9 q).

Mandatory manual reference:
https://www.gnu.org/software/guile/manual/html_node/Queues.html#Queues

Alternatively, if you want constant-time random access you could try using
Vlists, although they aren't thread-safe.

https://www.gnu.org/software/guile/manual/html_node/VLists.html#VLists

Finally you could implement either a doubly-linked list or array list type
depending on your needs.

If I understand your requirements correctly I would recommend queues. They are
easy to work with.

Sincerely yours,

- Tim


signature.asc
Description: This is a digitally signed message part.


Re: trace-calls-to-procedure

2020-12-25 Thread Tim Van den Langenbergh

On 25/12/2020 13:37, Tim Van den Langenbergh wrote:
trace-calls-to-procedure is a low-level trace procedure that returns a 
trap that you have to install in the trap state. You can either use the 
add-trap! procedure from (use-modules system vm trap-state), or use the 
add-trace-at-procedure-call! procedure from the same module.


That said, there seems to be a bug in add-trace-at-procedure-call! which 
I'm having a hard time figuring out... c'est la vie.


Vale
-Tim Van den Langenbergh


Update: the bug has already been addressed and a patch is awaiting merge:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43102

I imagine this'll get in for 3.0.5.

Vale,
-Tim Van den Langenbergh


OpenPGP_0xF50AF328D9D1E635.asc
Description: application/pgp-keys


OpenPGP_signature
Description: OpenPGP digital signature


Re: trace-calls-to-procedure

2020-12-25 Thread Tim Van den Langenbergh

On 25/12/2020 05:51, Tim Meehan wrote:

I have used ",trace" before and get what it is supposed to do, but I am not
sure what "trace-calls-to-procedure" is supposed to do ...

;; Using Guile 3.0.4
(use-modules (system vm trace))

(define (sqr x)
 (* x x))

(trace-calls-to-procedure sqr)

(sqr 3)

;; ... and nothing happens ... is something supposed to happen?



trace-calls-to-procedure is a low-level trace procedure that returns a 
trap that you have to install in the trap state. You can either use the 
add-trap! procedure from (use-modules system vm trap-state), or use the 
add-trace-at-procedure-call! procedure from the same module.


That said, there seems to be a bug in add-trace-at-procedure-call! which 
I'm having a hard time figuring out... c'est la vie.


Vale
-Tim Van den Langenbergh


OpenPGP_0xF50AF328D9D1E635.asc
Description: application/pgp-keys


OpenPGP_signature
Description: OpenPGP digital signature


Re: guile style

2021-06-19 Thread Tim Van den Langenbergh
On Saturday, 19 June 2021 02:55:34 CEST jerry wrote:
> I am fairly new to guile and scheme. People tell me that I should use a
> functional style.
>
> I have 3 solutions for project euler problem #1. The first is
> functional, the second is imperative and the third is written in "Little
> Schemer" style.
>
> I was hoping other guile users would comment on preferences or the
> "correct way". Sorry in advance for any wrapping problems that may occur.
>
> #!/usr/local/bin/guile  -s
> !#
> (use-modules (srfi srfi-1) (jpd stdio)) ;; for folds
> (define N 1000)
>
> (define ans
>(fold + 0
>  (filter
>(lambda (x) (or (= 0 (modulo x 3)) (= 0 (modulo x 5
>(iota N
> (print ans)
>
> (define ans 0)
> (for i N
>(if (or (= 0 (modulo i 3)) (= 0 (modulo i 5))) (set! ans (+ ans i
> (print ans)
>
> (define ans
>(let loop ((i 1) (ans 0))
>  (cond
>((>= i N) ans)
>((or (= 0 (modulo i 3)) (= 0 (modulo i 5))) (loop (1+ i) (+ ans i)))
>(else (loop (1+ i) ans)) )))

I'm not 100% sure about how Guile does it, but I know that some Scheme
implementations do some boxing for set! operations, which will make the second
variation poorly optimised. Personally I would use combine the first and third
answers by doing the divisible-by check during the fold, like this:

(use-modules (srfi srfi-1))

(define (divisible-by? divident divisor)
~~(zero? (modulo divident divisor)))

(define N 1000)

(define ans
~~(fold (lambda (i res)
~~(if (or (divisible-by? i 3)
~~(divisible-by? i 5))
(+ i res)
res))
0
(iota N)))

Vale,

-Tim





Re: Simple list of key-value pairs?

2021-07-09 Thread Tim Van den Langenbergh
On Thursday, 8 July 2021 16:37:09 CEST you wrote:
> Hi,
>
> I'm seeking advice for passing simple key-value pairs to a function and
> generate a string out of these values. Neither the names not the number
> of keys is known in advance.
>
> Background: This shall become a generic function for generating URI
> query-strings.
>
> My current approach please see below. Anyhow, I'm wondering whether the
> quite and quasiquote can be replaced by something simpler.
>
> (use-modules (ice-9 match))
>
> (define limit 100)
> (define evaluation "linux")
>
> (define* (api-uri base path #:rest query)
>
>(define (build-query-string kv)
>  (match kv
> ((name #f) #f)
> ((name (? string? value))
>  (string-append name "=" value))  ; FIXME: encode
> ((name (? number? value))
>  (string-append name "=" (number->string value)
>
>
>(format #t "~%Query: ~a~%~%" query)
>(let ((query-string
>   (when query
> (string-join
>  (filter (lambda (x) x) (map build-query-string query))
>  "&"
>  (format #t "~%Query-String: ~a~%~%" query-string)
>  ;; todo: build uri incl. query-string
>))
>
>
> (api-uri "https://ci.guix.gnu.org; "/api/jobs")
> (api-uri "https://ci.guix.gnu.org; "/api/jobs"
>   `("nr" ,limit)
>   `("evaluation" ,evaluation)
>   `("system" ,#f))

Hello,

personally I'd use key-value pairs rather than lists for passing in arguments
and simplify it a bit by using fold-right from SRFI-1, like this:

#+BEGIN_SRC scheme
(use-modules (srfi srfi-1))

(define (api-uri base path . query)
  (string-join
   (fold-right
(lambda (name-value-pair result)
  (if (cdr name-value-pair)
  (cons (string-append (car name-value-pair)
   "="

(object->string (cdr name-value-pair)))
 result)
  result))
'()
query)
   "&"))

(api-uri "https://ci.guix.gnu.org;
 "/api/jobs"
 (cons "nr" limit)
 (cons "evaluation" evaluation)
 (cons "system" #f))
#+END_SRC

Vale,

-Tim





Re: Syntax-Case macro that selects the N-th element from a list

2021-04-05 Thread Tim Van den Langenbergh
On Monday, 5 April 2021 13:30:21 CEST you wrote:
> Hi,
> 
> In dryads-wake I need selection of the element in a list in a macro from
> user-input. Currently I have multiple macros, and the correct one (which
> strips the non-selected choices) is selected in a simple cond:
> 
> (define-syntax-rule (Choose resp . choices)
>"Ask questions, apply consequences"
>(cond
> ((equal? resp 1) ;; resp is user-input. It is a natural number.
>  (Respond1 choices))
> ((equal? resp 2)
>  (Respond2 choices))
> ((equal? resp 3)
>  (Respond3 choices))
> (else
>  #f)))
> 
> For this however I have three syntax-case macros:
> 
> (define-syntax Respond1
>   (lambda (x)
> (syntax-case x ()
>   ((_ ((question consequences ...) choices ...))
> #`(begin
>(respond consequences ...)))
>   ((_ (choices ...))
> #`(begin #f)
> 
> (define-syntax Respond2
>   (lambda (x)
> (syntax-case x ()
>   ((_ (choice choices ...))
> #`(begin
>(Respond1 (choices ...
>   ((_ (choices ...))
> #`(begin #f)
> 
> (define-syntax Respond3
>   (lambda (x)
> (syntax-case x ()
>   ((_ (a b choices ...))
> #`(Respond1 (choices ...)))
>   ((_ (choices ...))
> #`(begin #f)
> 
> 
> I would like to get rid of those three definitions and replace them by
> at most two (one that strips N initial list entries, and Respond1).
> 
> I cannot move to procedures, because I have code that must be executed
> only during final processing, and when I evaluate any of the
> consequences (as it happens with procedure-arguments), then the timing
> of the code execution does not match anymore. So I must absolutely do
> this in macros.
> 
> 
> I’ve tried to get that working, but all my tries failed. Is there a way
> and can you show it to me?
> 
> This is a minimal working example. The output should stay the same,
> except for part 4, which needs this change to work (see at the bottom),
> but I would like to:
> 
> - replace Respond2 and Respond3 by something recursive, so resp can have
>   arbitrary high values (not infinite: max the length of the options) and
> - replace the cond-clause by a call to the recursive macro.
> 
> (define-syntax-rule (respond consequence consequence2 ...)
>   (begin
> (write consequence)
> (when (not (null? '(consequence2 ...)))
>   (write (car (cdr (car `(consequence2 ...
> 
> (define-syntax Respond1
>   (lambda (x)
> (syntax-case x ()
>   ((_ ((question consequences ...) choices ...))
> #`(begin
>(respond consequences ...)))
>   ((_ (choices ...))
> #`(begin #f)
> 
> (define-syntax Respond2
>   (lambda (x)
> (syntax-case x ()
>   ((_ (choice choices ...))
> #`(begin
>(Respond1 (choices ...
>   ((_ (choices ...))
> #`(begin #f)
> 
> (define-syntax Respond3
>   (lambda (x)
> (syntax-case x ()
>   ((_ (a b choices ...))
> #`(Respond1 (choices ...)))
>   ((_ (choices ...))
> #`(begin #f)
> 
> 
> (define-syntax-rule (Choose resp . choices)
>"Ask questions, apply consequences"
>(cond
> ((equal? resp 1)
>  (Respond1 choices))
> ((equal? resp 2)
>  (Respond2 choices))
> ((equal? resp 3)
>  (Respond3 choices))
> (else
>  #f)))
> 
> 
> (display "Choose 1: should be bar:")
> (Choose 1 (foo 'bar) (foo 'war 'har) (foo 'mar) (foo 'tar))
> (newline)
> (display "Choose 2: should be warhar:")
> (Choose 2 (foo 'bar) (foo 'war 'har) (foo 'mar) (foo 'tar))
> (newline)
> (display "Choose 3: should be mar:")
> (Choose 3 (foo 'bar) (foo 'war 'har) (foo 'mar) (foo 'tar))
> (newline)
> (display "Choose 4: should be tar:")
> (Choose 4 (foo 'bar) (foo 'war 'har) (foo 'mar) (foo 'tar))
> (newline)
> (display "Choose 5: should be #f:")
> (Choose 5 (foo 'bar) (foo 'war 'har) (foo 'mar) (foo 'tar))
> (newline)
> 
> 
> Best wishes,
> Arne

Hello, Dr. Arne,

would simply transforming the question . response pairs to a list of lists of 
responses work?

E.G.

#+begin_src scheme
(define-syntax questions->responses
  (syntax-rules ()
((_ (question response ...) choices ...)
 (cons (list response ...)
   (questions->responses choices ...)))
((_ choices ...)
 '(
#+end_src

Vale,

-Tim





Re: dynamic-link sadness

2021-02-23 Thread Tim Van den Langenbergh
On Tuesday, 23 February 2021 04:49:34 CET you wrote:
> Ok - I think that I am missing something important that will allow me to
> dynamically load libraries. :(
> Is this an environment variable or something?
>
> me@expensive:/usr$ find . -type f -name "libm\.*" -print
> ./lib/x86_64-linux-gnu/libm.so
> ./lib/x86_64-linux-gnu/libm.a
> me@expensive:/usr$ guile
> GNU Guile 3.0.1
> Copyright (C) 1995-2020 Free Software Foundation, Inc.
>
> Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
> This program is free software, and you are welcome to redistribute it
> under certain conditions; type `,show c' for details.
>
> Enter `,help' for help.
> scheme@(guile-user)> (dynamic-link "libm")
> ice-9/boot-9.scm:1669:16: In procedure raise-exception:
> In procedure dynamic-link: file: "libm", message: "file not found"
>
> Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
> scheme@(guile-user) [1]> ,q
> scheme@(guile-user)> (dynamic-link "/usr/lib/x86_64-linux-gnu/libm.so")
> ice-9/boot-9.scm:1669:16: In procedure raise-exception:
> In procedure dynamic-link: file: "/usr/lib/x86_64-linux-gnu/libm.so",
> message: "file not found"
>
> Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
> scheme@(guile-user) [1]> ,q

Hey Tim (feels weird typing that),

are you using Guile from your Guix install? I have had issues with that as
well and I needed to use Guile from my regular OS.

If you're not using Guix then I haven't had that problem, so I'm afraid I
can't help.

Vale,

-Tim Van den Langenbergh





Re: guile-hall issues converting my project to a hall project

2021-02-16 Thread Tim Van den Langenbergh
Err, looking at your hall.scm file, you have the fslib file added to your
libraries twice.

Guix environment is not needed if you have all the requirements for building
the package installed locally, but if you want to distribute your package it's
good practise to ensure it builds in a clean environment (see also https://
guix.gnu.org/manual/en/html_node/Invoking-guix-environment.html for more
information about Guix environments).

The "COPYING" file is hardcoded as license file in Hall, to ensure compatibility
with GNU standards: https://www.gnu.org/licenses/gpl-howto.en.html

Hope this helps,

Vale

-Tim





Re: guile-hall issues converting my project to a hall project

2021-02-07 Thread Tim Van den Langenbergh
s I can remove the sample hook
> files and then try again …
> 
> … Now it complains about my tag files in .git! It seems I cannot run
> `hall scan` successfully.
> 
> This is it so far. This is as far as I got and I have no idea, whether I
> am anywhere close to a functioning package.
> 
> Can you help me out? How do I proceed from here? Please assume no
> knowledge about "things that are obvious" about any of guile-hall or
> autotools, automake, make and the like.
> 
> Do I really have to move my source files into the directory hall created
> and change all my import expressions in the source code? That can be
> arranged. Although this seems to hint at an unfortunate coupling of
> project name and directory in which source files reside. Similar to what
> docker-compose is doing with container names and the folder inside which
> you run it. Such a thing can be quite annoying.
> 
> How do I fix that "unsupported file type" thing?
> 
> I feel like there are so many files and stuff hall added, that if only I
> understood more about what exactly GNU Guix _must_ find in the project
> directory to use it as a package, I might be better off creating that
> stuff manually, but perhaps to make a package I must have all this
> stuff? I have no idea, whether the license must be in COPYING, or having
> it inside LICENSE is fine too. I think I will ask for a complete list of
> all things required by Guix on the Guix mailing list. The verdict is not
> out yet though. I still hope to make everything work with guile-hall,
> hoping anyone can help.
> 
> Best regards,
> Zelphir

Hi Zelphir,

the prefix is a part of the project name that you do not want to include in the 
name of whichever module/library you are making, for example if I want to make 
a project called "Guile-Utils" which exports a library called "utils" I would 
use the prefix argument to add "guile" in front. Without it I could make a 
library called "utils" but hall would complain if I didn't have a library 
called "guile-utils" as well.

You also raised various good points, especially about what a pain it is to run 
hall scan after running hall dist (which we really should warn people not to 
do).

Basically the way to think of hall is like an inverse git, where instead of 
excluding certain files with a .gitignore, you keep track of files through your 
hall.scm.

If you don't want to restart the conversion of your project to a hall project 
from scratch I fear you may have to edit your hall.scm by hand.

Feel free to contact me if you have more questions.

Vale,

-Tim Van den Langenbergh





Re: Can guile be implementation independent?

2021-12-18 Thread Tim Van den Langenbergh
On 17/12/2021 17:26, Dr. Arne Babenhauserheide wrote:
> The short of this: Call guile with --r7rs and the main incompatibility
> is missing reading of circular data structures with datum labels.
> 
> Best wishes,
> Arne

Well, Guile is also missing digit-value, which is easily mocked-up by using 
char->integer and subtracting 48 from it.


OpenPGP_signature
Description: OpenPGP digital signature


Re: How to capture pid of (system process?

2021-12-14 Thread Tim Van den Langenbergh
On 13/12/2021 22:01, Jacob Hrbek wrote:
> I wrote this potato-make  definition 
> (was simplified):
> 
> #:SRC_BEGIN sheme-mode
> #!/usr/bin/env sh
> exec guile -s "$0" "$@"
> !#
> 
> (use-modules (ice-9 futures)
>  (potato make))
> (initialize)
> 
> (: "watch" '()
>    (~ (do ((i 1 (1+ i)))
>       ((> i 6))
>     (future (system
>      "emacs"))
>     ;;(let ((emacs_pid (getpid)))
>      ;; (kill emacs_pid SIGTERM)
> 
> (execute)
> #:SRC_END
> 
> expecting to capture emacs's pid and kill it, but the issue is that using 
> `getpid` gets me the PID of potato-make and `getppid` of the shell -> How can 
> i capture just the emacs's pid?
> 
> FWIW the projected end-goal is 3600 loop that checks if the `my-theme.el` 
> file has been changed to re-launch emacs with the theme loaded used for theme 
> development.
> 

Hello,

I hope this day finds you well.

While Guile does not directly provide a function to get the PID of an arbitrary 
process, we could use pgrep to find what we need.

#+begin_src scheme
  (use-modules (ice-9 popen)
   (ice-9 textual-ports))

  (map string->number
   (string-split (let ((port (open-input-pipe "pgrep emacs"))
   (s (get-string-all port)))
   (close-pipe port)
   s)
 #\newline))
  ;; => (1220 #f)
#+end_src

I hope this helps!

Vale,

-Tim


OpenPGP_signature
Description: OpenPGP digital signature


Re: GNU Shepherd 0.9.0 released

2022-04-08 Thread Tim Van den Langenbergh


Ognen Duzlevski  writes:

> Ludovic Courtès  writes:
>
>> [[PGP Signed Part:Undecided]]
>> We are pleased to announce the GNU Shepherd version 0.8.1.  This release
>> represents 49 commits by 3 people, bringing a new concurrent,
>> event-driven core, improved logging, and on-demand service startup.
>
> Does Shepherd only run on Linux?
>
> Thanks,

Hey,

from the README:

> It is intended for use on GNU/Hurd, but it is supposed to work on every
> POSIX-like system where Guile is available.  In particular, it has been
> tested on GNU/Linux.

So if you prefer to run the Hurd rather than Linux, it should work fine.

Vale,

- Tim



Re: [EXT] Re: Chickadee 0.8.0 released

2022-06-01 Thread Tim Van den Langenbergh


"Thompson, David"  writes:

> Hi Bill,
>
> Unfortunately there has been no release that fixes the configure script to
> allow Guile 3. There is no actual incompatibility beyond that.
>
> I (and the Guix project) just patch guile-opengl's configure.ac and
> Makefile.am so that it works for Guile 3.  See:
> https://git.dthompson.us/chickadee.git/tree/guix.scm#n64
>
> Hope this helps!
>
> - Dave
>

I wonder if guile-opengl is ready for another stable release, Andy added 3.0 to
GUILE_PKG back in August 2019, and also updated the packed-struct
implementation.



Re: Guile Steel: a proposal for a systems lisp

2022-07-11 Thread Tim Van den Langenbergh


Christine Lemmer-Webber  writes:

> A little blogpost this morning, not actual software, but software
> desiderata:
>   https://dustycloud.org/blog/guile-steel-proposal/
>
> I'd love to see something like the above happen.  I'd love to help make
> it happen.  So this is more of a call to arms than anything else.
>
> Can we have a "systems lisp"?  Can we do better than Rust?  Let's put
> some interesting things on that compiler tower of ours!

Dear Christine,

creating a Lisp-inspired systems programming language is indeed an interesting
idea, I have also been thinking about something similar (though I wasn't
thinking of tying it to Guile in any way).

Your talk about propagators is also quite interesting, it may take me a lot of
mental processing power to map them to "hey hardware, give me this many bytes
on the stack"-style output, I ought to play around with them over the weekend.

My own thoughts on a systems programming language primarily revolve around
stealing interesting ideas from other projects: taking some notation from
Cakelisp and Coalton, parts of the type system from Coalton and Rust, the
memory management from Rust,...

As I am a big fan of the GNU project I was thinking of targetting GCC's GENERIC
as an initial compilation target, though I am aware that a lot of projects seem
to prefer LLVM instead.  Unfortunately it seems like GCC's documentation
doesn't match up well against that of LLVM, so adding some advanced
functionality may take some code reading (or putting GCC through GDB, that
could be fun).

The part of designing a language for systems programming I dread most is
getting the predictability right.  Being able to tell in advance what gets
allocated on the stack, what on the heap, what gets freed when is very
important.  Of course manual memory management has been a major cause of bugs,
so having the language manage it properly is of prime importance, which makes
it hard to get the predictability right without hampering the ergonomics of the
language.

I am looking forward to reading your further thoughts as you start tinkering
around with the idea.  The Lisp revolution could use another stride forwards.

Vale,

- Tim



Re: Using guile (running on a port) in Org Mode

2022-07-15 Thread Tim Van den Langenbergh


Munyoki Kilyungi  writes:

> [[PGP Signed Part:Undecided]]
>
> Hi Guilers!
>
> Recently I worked out a way to point an org src
> block to any python environment I want:
> .
> WRT to scheme code, is there a way to tell a
> scheme source block to run a guile interpreter
> that runs on a given port?

Hello there,

it's been a little while since I looked at the ob-scheme code, but I believe
that you should be able to use an existing Geiser session as the execution
session for your Org buffer.  So if you connect Geiser to a running Guile
instance, give the Geiser buffer a unique name, and use that name as the
session parameter for your src block (plus or minus earmuffs) I think it should
work.

Vale,

- Tim