bug#59596: [PATCH 2/3] Add an interactive session exception error message.

2022-11-25 Thread Yuval Langer
---
 doc/ref/api-data.texi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 8c18b4d40..143434213 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -4798,6 +4798,11 @@ Notice that if we try the same @code{assq-set!} call with
 
 @lisp
 (assq-set! car2-properties 'seat-colour 'black)
+@print{}
+ice-9/boot-9.scm:1669:16: In procedure raise-exception:
+In procedure set-cdr!: Wrong type argument in position 1 (expecting mutable 
pair): (seat-colour . red)
+
+Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
 @end lisp
 
 This is due to the fact that literal alists are immutable. If you want
-- 
2.30.2






bug#59595: [PATCH 1/3] Add examples and incomplete wordings.

2022-11-25 Thread Yuval Langer
---
 doc/ref/api-data.texi | 33 -
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 8658b9785..8c18b4d40 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -4767,7 +4767,7 @@ It also allows further properties to use the same symbols 
among their
 possible values without becoming ambiguous:
 
 @lisp
-(define car1-properties '((colour . red)
+(define car2-properties '((colour . red)
   (transmission . manual)
   (fuel . unleaded)
   (steering . power-assisted)
@@ -4793,6 +4793,37 @@ extract or change individual pieces of information:
  (locking . manual)))
 @end lisp
 
+Notice that if we try the same @code{assq-set!} call with
+@code{car2-properties}, we get an exception:
+
+@lisp
+(assq-set! car2-properties 'seat-colour 'black)
+@end lisp
+
+This is due to the fact that literal alists are immutable. If you want
+to mutate an alist, you must define it using the @code{acons}
+constructor:
+
+@lisp
+(define car3-properties (acons 'colour 'red
+(acons 'transmission 'manual
+(acons 'fuel 'unleaded
+(acons 'steering 'power-assisted
+(acons 'seat-colour 'red
+(acons 'locking 'manual '(
+
+(assq-ref car3-properties 'seat-colour) @result{} red
+(assq-set! car3-properties 'seat-colour 'black)
+@result{}
+((colour . red)
+ (transmission . manual)
+ (fuel . unleaded)
+ (steering . power-assisted)
+ (seat-colour . black)
+ (locking . manual)))
+(assq-ref car3-properties 'seat-colour) @result{} black
+@end lisp
+
 Hash tables also have keys, and exactly the same arguments apply to the
 use of symbols in hash tables as in association lists.  The hash value
 that Guile uses to decide where to add a symbol-keyed entry to a hash
-- 
2.30.2






bug#59597: [PATCH 3/3] Change order of the resulting alist - a new entry is added to the start of the alist.

2022-11-25 Thread Yuval Langer
---
 doc/ref/api-data.texi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 143434213..2f603fb8f 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -4785,11 +4785,11 @@ extract or change individual pieces of information:
 
 (assq-set! car1-properties 'seat-colour 'black)
 @result{}
-((colour . red)
+((seat-colour . black)
+ (colour . red)
  (transmission . manual)
  (fuel . unleaded)
  (steering . power-assisted)
- (seat-colour . black)
  (locking . manual)))
 @end lisp
 
-- 
2.30.2






bug#68362: Segmentation fault when a procedure is called with no arguments

2024-01-09 Thread Yuval Langer
I get the following output:

Backtrace:
In ice-9/boot-9.scm:
  1736:10  7 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
   6 (apply-smob/0 #)
In ice-9/boot-9.scm:
718:2  5 (call-with-prompt _ _ #)
In ice-9/eval.scm:
619:8  4 (_ #(#(#)))
In rsv2scm:
13:12  3 (main _)
In rsv/arbitrary-null.scm:
   133:33  2 (rsv->scm #f #)
   111:33  1 (row->scm #f 0 #)
81:20  0 (read-null-value _ _ _)

rsv/arbitrary-null.scm:81:20: In procedure read-null-value:
Wrong number of arguments to Segmentation fault

When running the commands:

git clone https://codeberg.org/kakafarm/guile-rsv/ # Clone my repository.
cd guile-rsv
git checkout segmentation-fault # Should be commit number
790ee10036f3dcb425fbf5619ff0e452a73d459d
printf "\xfe" | ./rsv2scm # This is the offending command.

I accidentally called the procedure read-null-value without any
arguments, while the procedure needs three arguments.  Instead of
showing a useful error, it results with in a segmentation fault.

My guile --version:

guile (GNU Guile) 3.0.9

It came from a Guix installed on a Debian installation.  The Guix
repository commit obtained from the guix describe command is
3de361d9c9d320aefbd43710124d7b07af891de1.

Thank you,
Yuval Langer.





bug#68362: Wrong Guile version and a new error message

2024-01-09 Thread Yuval Langer
Sorry,

I have provided the wrong version number used to produce the
segmentation fault.  The true version is:

guile (GNU Guile) 3.0.5
Packaged by Debian (3.0.5-deb+3.0.5-4)
Copyright (C) 2021 Free Software Foundation, Inc.

License LGPLv3+: GNU LGPL 3 or later <http://gnu.org/licenses/lgpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

as that is the one specified in ./rsv2scm's shebang.

Using the Guix version:

$ printf "\xfe" | guile -L . -e main -s rsv2scm

I get the following error:

Backtrace:
In ice-9/boot-9.scm:
  1752:10  7 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
   6 (apply-smob/0 #)
In ice-9/boot-9.scm:
724:2  5 (call-with-prompt _ _ #)
In ice-9/eval.scm:
619:8  4 (_ #(#(#)))
In rsv2scm:
13:12  3 (main _)
In rsv/arbitrary-null.scm:
   144:23  2 (rsv->scm #f #)
   116:11  1 (row->scm #f 0 #)
 84:4  0 (read-null-value _ _ _)

rsv/arbitrary-null.scm:84:4: In procedure read-null-value:
Wrong number of arguments to 254

The byte value being piped into guile is 254.  Weird.

Thank you,
Yuval Langer.





bug#68734: Minor typo correction.

2024-01-26 Thread Yuval Langer
Hi,

I hope this is a correct correction to the error.

Many thanks,
Yuval Langer.
From 8d8b3e4d80311f80754fc1e38f779e96c6031198 Mon Sep 17 00:00:00 2001
From: Yuval Langer 
Date: Fri, 26 Jan 2024 13:04:08 +0200
Subject: [PATCH] Fix minor typo.

---
 doc/ref/history.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/ref/history.texi b/doc/ref/history.texi
index 60d839ac3..8e911f219 100644
--- a/doc/ref/history.texi
+++ b/doc/ref/history.texi
@@ -216,7 +216,7 @@ and debugger, SSAX XML integration, bytevectors, a dynamic FFI,
 delimited continuations, module versions, and partial support for R6RS.
 
 @item 2.2 --- 15 March 2017
-The virtual machine and introduced in 2.0 was completely rewritten,
+The virtual machine introduced in 2.0 was completely rewritten,
 along with much of the compiler and toolchain.  This speeds up many
 Guile programs as well as reducing startup time and memory usage.
 Guile's POSIX multithreading was improved, stacks became dynamically
-- 
2.30.2



bug#70640: A Texinfo aware `,describe` command.

2024-04-28 Thread Yuval Langer
Hello hackers,

I have noticed there are many docstrings containing Texinfo markup,
but when one runs the `,describe` command, one gets the Texinfo markup
source, not a render of those Texinfo commands.

I wish to write a better `,describe` command that would render Texinfo
in a pleasant way.  Attached are some procedures I wrote for this
purpose.  They are far from being complete, but I wish to start a
conversion about the topic.

I searched for the describe command in the guile source code and found:

https://git.savannah.gnu.org/cgit/guile.git/tree/module/system/repl/command.scm#n346

Is that the right place?

Also, the code of these files is currently stored in:

https://codeberg.org/kakafarm/guile-fancy-describe/

Also also, previous message related to this:

https://lists.gnu.org/archive/html/guile-devel/2024-04/msg00015.html
(define-module (fancy-docstrings)
  #:use-module (srfi srfi-1)
  #:use-module (texinfo)
  #:use-module (ice-9 documentation)
  #:use-module (ice-9 match)
  #:use-module (ice-9 pretty-print))

(define ansi-begin-bold "\x1b[1m")
(define ansi-begin-underline "\x1b[4m")
(define ansi-end-it-all "\x1b[0m")

;;;(pretty-print texi-command-specs)

(define (display-fancy-string str)
  "Display a fancy @var{str}."
  (display ansi-begin-underline)
  (display ansi-begin-bold)
  (display str)
  (display ansi-end-it-all))

(define (display-fancy-stexi-para stexi)
  "Display fancy @var{stexi} paragraph."
  (let loop ((stexi stexi))
(match stexi
  (() '())
  ((('var (and (? string?) str)) . rest-of-elements)
   (display-fancy-string str)
   (loop rest-of-elements))
  ((('code (and (? string?) str)) . rest-of-elements)
   (display-fancy-string str)
   (loop rest-of-elements))
  (((some-tag (and (? string?) str)) . rest-of-items)
   ;; TODO: What about the rest of them?
   (error "Still unsupported stexi element:" some-tag str)
   (loop rest-of-items))
  (((and (? string?) str) . rest-of-items)
   (display str)
   (loop rest-of-items))
  (_
   (error "Unknown stexi value:" stexi)

(define (display-fancy-stexi-fragment stexi)
  (let loop ((stexi stexi))
(match stexi
  (() '())
  (('*fragment* ('para . first-paragraph) . rest-of-paragraphs)
   (display-fancy-stexi-para first-paragraph)
   (loop rest-of-paragraphs))
  ((('para . paragraph) . rest-of-paragraphs)
   (display "\n\n")
   (display-fancy-stexi-para paragraph)
   (loop rest-of-paragraphs))
  ((element . rest-of-elements)
   (error "Unknown stexi element" element)
(use-module (fancy-describe))

(define find-stexi (texi-fragment->stexi (object-documentation find)))

(pretty-print find-stexi)

(display-fancy-stexi-fragment find-stexi) (newline)

(display-fancy-stexi-fragment (texi-fragment->stexi "poop")) (newline)

(let* ((text "a @var{a} b.

c @var{moo} d.


@var{@@moo}


e @code{gah} f.
")
   (stexi (texi-fragment->stexi text)))
  (pretty-print stexi)
  (display-fancy-stexi-fragment stexi))

(newline)

(let* ((text "@var{moo}
@code{gah}
")
   (stexi (texi-fragment->stexi text)))
  (pretty-print stexi)
  (display-fancy-stexi-fragment stexi))
(newline)


bug#71416: Dead link in the Guile manual

2024-06-07 Thread Yuval Langer
In the documentation page:

https://www.gnu.org/software/guile/manual/html_node/Syntax-Rules.html#Further-Information

the link to "Joe Marshall’s syntax-rules Primer for the Merely
Eccentric" is dead:

https://sites.google.com/site/evalapply/eccentric.txt

There's an extant (and cleaned up by Wolfgang Corcoran-Mathe, a.k.a.
Zipheir) version of the document on:

https://www.sigwinch.xyz/misc/jrms_syntax-rules_primer.txt

Another version:

https://hipster.home.xs4all.nl/lib/scheme/gauche/define-syntax-primer.txt

Thank you,
Yuval Langer.





bug#75413: Fix faulty example of SRFI-31 in the manual.

2025-01-06 Thread Yuval Langer

From aac75ef98ca6b008fd7d16f42dcb90d22b8ed43c Mon Sep 17 00:00:00 2001
From: Yuval Langer 
Date: Fri, 3 Jan 2025 06:37:43 +0200
Subject: [PATCH] Fix faulty SRFI-31 example.

---
 doc/ref/srfi-modules.texi | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi
index d77bc1c90..1373409f0 100644
--- a/doc/ref/srfi-modules.texi
+++ b/doc/ref/srfi-modules.texi
@@ -3367,8 +3367,9 @@ The second syntax can be used to create anonymous recursive functions:
 
 @lisp
   guile> (define tmp (rec (display-n item n)
-   (if (positive? n)
-   (begin (display n) (display-n (- n 1))
+   (when (positive? n)
+   (display item)
+   (display-n item (- n 1)
   guile> (tmp 42 3)
   424242
   guile>
-- 
2.47.1



bug#75413: Fix faulty example of SRFI-31 in the manual.

2025-01-08 Thread Yuval Langer
Adding a `(newline)` in this patch.

On Tue, Jan 7, 2025 at 3:23 AM Rob Browning  wrote:
>
> Yuval Langer  writes:
>
> > diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi
> > index d77bc1c90..1373409f0 100644
> > --- a/doc/ref/srfi-modules.texi
> > +++ b/doc/ref/srfi-modules.texi
> > @@ -3367,8 +3367,9 @@ The second syntax can be used to create anonymous 
> > recursive functions:
> >
> >  @lisp
> >guile> (define tmp (rec (display-n item n)
> > -   (if (positive? n)
> > -   (begin (display n) (display-n (- n 1))
> > +   (when (positive? n)
> > +   (display item)
> > +   (display-n item (- n 1)
> >guile> (tmp 42 3)
> >424242
> >guile>
>
> Looks good overall -- strictly speaking, might need a (newline) in there
> if we want the output to match (or the output could be changed).
>
> --
> Rob Browning
> rlb @defaultvalue.org and @debian.org
> GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
> GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
From 98a81d3c91b61eed53b1b3d242c8d4f1508e84e7 Mon Sep 17 00:00:00 2001
From: Yuval Langer 
Date: Fri, 3 Jan 2025 06:37:43 +0200
Subject: [PATCH] Fix faulty SRFI-31 example.

---
 doc/ref/srfi-modules.texi | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi
index d77bc1c90..85dbc2b96 100644
--- a/doc/ref/srfi-modules.texi
+++ b/doc/ref/srfi-modules.texi
@@ -3367,8 +3367,9 @@ The second syntax can be used to create anonymous recursive functions:
 
 @lisp
   guile> (define tmp (rec (display-n item n)
-   (if (positive? n)
-   (begin (display n) (display-n (- n 1))
+   (when (positive? n)
+ (display item) (newline)
+ (display-n item (- n 1)
   guile> (tmp 42 3)
   424242
   guile>
-- 
2.30.2



bug#75413: Fix faulty example of SRFI-31 in the manual.

2025-01-08 Thread Yuval Langer
Sorry about the flood.  I have added `(newline)`, but the example
output did not have the literal newlines, so in this patch I have
added both the `(newline)` call and the example output newlines.


On Thu, Jan 9, 2025 at 6:01 AM Yuval Langer  wrote:
>
> Adding a `(newline)` in this patch.
>
> On Tue, Jan 7, 2025 at 3:23 AM Rob Browning  wrote:
> >
> > Yuval Langer  writes:
> >
> > > diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi
> > > index d77bc1c90..1373409f0 100644
> > > --- a/doc/ref/srfi-modules.texi
> > > +++ b/doc/ref/srfi-modules.texi
> > > @@ -3367,8 +3367,9 @@ The second syntax can be used to create anonymous 
> > > recursive functions:
> > >
> > >  @lisp
> > >guile> (define tmp (rec (display-n item n)
> > > -   (if (positive? n)
> > > -   (begin (display n) (display-n (- n 1))
> > > +   (when (positive? n)
> > > +   (display item)
> > > +   (display-n item (- n 1)
> > >guile> (tmp 42 3)
> > >424242
> > >guile>
> >
> > Looks good overall -- strictly speaking, might need a (newline) in there
> > if we want the output to match (or the output could be changed).
> >
> > --
> > Rob Browning
> > rlb @defaultvalue.org and @debian.org
> > GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
> > GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
From 55b689307972cd705a1b315cd62125429112d4c8 Mon Sep 17 00:00:00 2001
From: Yuval Langer 
Date: Fri, 3 Jan 2025 06:37:43 +0200
Subject: [PATCH] Fix faulty SRFI-31 example.

---
 doc/ref/srfi-modules.texi | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi
index d77bc1c90..353867a82 100644
--- a/doc/ref/srfi-modules.texi
+++ b/doc/ref/srfi-modules.texi
@@ -3367,10 +3367,13 @@ The second syntax can be used to create anonymous recursive functions:
 
 @lisp
   guile> (define tmp (rec (display-n item n)
-   (if (positive? n)
-   (begin (display n) (display-n (- n 1))
+   (when (positive? n)
+ (display item) (newline)
+ (display-n item (- n 1)
   guile> (tmp 42 3)
-  424242
+  42
+  42
+  42
   guile>
 @end lisp
 
-- 
2.30.2



bug#76163: Badly treated eol-style (end of line style) in R6RS transcoders.

2025-02-09 Thread Yuval Langer
When running the `transcoders.scm` script (file attached) in Guile:

```
$ guile transcoders.scm
```

I get the output:

```
"abc\r"
```

but it should be:

```
"abc"
```

When running Chez Scheme:

```
$ chezscheme --script transcoders.scm
```

I get the right output:

```
"abc"
```

This is due to faulty transcoders in Guile, maybe?

My `guile --version` says `guile (GNU Guile) 3.0.9`, and `chezscheme
--version` says `9.5.4`.

Many thanks,
Yuval Langer.
(import
 (rnrs io ports)
 (rnrs bytevectors))

(let* ([x (string->utf8 "abc\r\ndef\r\n")]
   [input-port-from-bytevector (open-bytevector-input-port x)]
   [transcoder (make-transcoder (utf-8-codec)
(eol-style crlf))]
   [text-port (transcoded-port input-port-from-bytevector
   transcoder)]
   [a-line (get-line text-port)])
  (write a-line)
  (newline)
  a-line) ;; => "abc\r", but should be "abc"


bug#78908: Fix typo in the guile-opengl manual.

2025-06-26 Thread Yuval Langer
Hi,

there is a typo in the manual.

This patch fixes it.

Many thanks,
Yuval Langer.

p.s. Also sent to bug-guile-...@gnu.org by accident.  Sorry about that.
From ee6008784886b38eb877bc99b609e929b3db5a62 Mon Sep 17 00:00:00 2001
From: Yuval Langer 
Date: Fri, 27 Jun 2025 00:17:31 +0300
Subject: [PATCH] Fix typo in manual.

---
 doc/gl.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/gl.texi b/doc/gl.texi
index 92845fd..7ad7911 100644
--- a/doc/gl.texi
+++ b/doc/gl.texi
@@ -91,7 +91,7 @@ For the X window system, there is a standard API for creating a GL
 context given a window (or a drawable), @dfn{GLX}.  @xref{GLX}, for
 more information on its binding in Guile.
 
-Bseides creating contexts from native windows or drawables, each
+Besides creating contexts from native windows or drawables, each
 backend also supports functions to make a context @dfn{current}.  The
 OpenGL API is stateful; you can think of each call as taking an
 implicit @dfn{current context} parameter, which holds the current
-- 
2.30.2