Re: Make a game with Hoot for the Lisp Game Jam!

2024-05-15 Thread Dr. Arne Babenhauserheide
"Thompson, David"  writes:

> We've put together a ready-to-use game template project [1] so it's
> easy to jump right in and start making games!
>
> Read our blog post for all the details:
>
> https://spritely.institute/news/make-a-game-with-hoot-for-the-lisp-game-jam.html
>
> I hope some of you join in! Happy jamming!

I’m seriously considering to enter ☺

I’ve always wanted to make a graphical beat-em-up, and with Hoot I may
even be able to publish it in directly playable format on my website.

> [0] https://itch.io/jam/spring-lisp-game-jam-2024
>
> [1] https://gitlab.com/spritely/guile-hoot-game-jam-template/

Best wishes,
Arne


signature.asc
Description: PGP signature


Re: define-typed: checking values on proc entry and exit

2024-05-14 Thread Dr. Arne Babenhauserheide
"Dr. Arne Babenhauserheide"  writes:

> Zelphir Kaltstahl  writes:
>> https://codeberg.org/ZelphirKaltstahl/guile-examples/src/commit/0e231c289596cb4c445efb30168105914a8539a5/macros/contracts

> And the *-versions are ominous: optional and keyword arguments may be
> the next frontier.
>
> I’m not sure how to keep those simple.

I now have a solution: 
https://www.draketo.de/software/guile-snippets#define-typed

┌
│ (import (srfi :11 let-values))
│ (define-syntax-rule (define-typed (procname args ...) (ret? types ...) body 
...)
│   (begin
│ (define* (procname args ...)
│   ;; create a sub-procedure to run after typecheck
│   (define (helper)
│ body ...)
│   ;; use a typecheck prefix for the arguments   
│   (map (λ (type? argument)
│  (let ((is-keyword? (and (keyword? type?)
│  (keyword? argument
│(when (and is-keyword? (not (equal? type? argument)))
│  (error "Keywords in arguments and types are not equal ~a ~a"
│type? argument))
│(unless (or is-keyword? (type? argument))
│  (error "type error ~a ~a" type? argument
│(list types ...) (list args ...))
│   ;; get the result
│   (let-values ((res (helper)))
│ ;; typecheck the result
│ (unless (apply ret? res)
│   (error "type error: return value ~a does not match ~a"
│  res ret?))
│ ;; return the result
│ (apply values res)))
│ (unless (equal? (length (quote (args ...))) (length (quote (types ...
│   (error "argument error: argument list ~a and type list ~a have 
different size"
│ (quote (args ...)) (quote (types ...
│ ;; add procedure properties via an inner procedure
│ (let ((helper (lambda* (args ...) body ...)))
│   (set-procedure-properties! procname (procedure-properties helper))
│   ;; preserve the name
│   (set-procedure-property! procname 'name 'procname
└

This supports most features of regular define like docstrings, procedure
properties, multiple values (thanks to Vivien!), keyword-arguments
(thanks to Zelphir Kaltstahl’s [contracts]), and so forth.

Basic usage:

┌
│ (define-typed (hello typed-world) (string? string?)
│   typed-world)
│ (hello "typed")
│ ;; => "typed"
│ (hello 1337)
│ ;; => type error ~a ~a # 1337
│ (define-typed (hello typed-world) (string? string?)
│   "typed" ;; docstring
│   #((props)) ;; more properties
│   1337) ;; wrong return type
│ (procedure-documentation hello)
│ ;; => "typed"
│ (procedure-properties hello)
│ ;; => ((name . hello) (documentation . "typed") (props))
│ (hello "typed")
│ ;; type error: return value ~a does not match ~a (1337) #
└

Multiple Values and optional and required keyword arguments:

┌
│ (define-typed (multiple-values num) ((λ(a b) (> a b)) number?)
│   (values (* 2 (abs num)) num))
│ (multiple-values -3)
│ ;; => 6
│ ;; => -3
│ (define-typed (hello #:key typed-world) (string? #:key string?) "typed" 
#((props)) typed-world)
│ (hello #:typed-world "foo")
│ ;; => "foo"
│ ;; unused keyword arguments are always boolean #f as input
│ (hello)
│ ;; => type error ~a ~a # #f
│ ;; typing optional keyword arguments
│ (define (optional-string? x) (or (not x) (string? x)))
│ (define-typed (hello #:key typed-world) (string? #:key optional-string?)
│   (or typed-world "world"))
│ (hello)
│ ;; => "world"
│ (hello #:typed-world "typed")
│ ;; => "typed"
│ (hello #:typed-world #t)
│ ;; => type error ~a ~a # #t
│ ;; optional arguments
│ (define-typed (hello #:optional typed-world) (string? #:optional 
optional-string?)
│   (or typed-world "world"))
│ (hello)
│ ;; => "world"
│ (hello "typed")
│ ;; => "typed"
│ (hello #t)
│ ;; => type error ~a ~a # #t
└

Best wishes,
Arne


signature.asc
Description: PGP signature


Re: define-typed: checking values on proc entry and exit

2024-05-14 Thread Dr. Arne Babenhauserheide
Olivier Dion  writes:

> On Fri, 10 May 2024, "Dr. Arne Babenhauserheide"  wrote:
>
> This is entirely off topic, sorry, but how do you do the following in Emacs:
>
>> ┌
>> │ ...
>> └
>
> I usualy use:
>
> --8<---cut here---start->8---
> ...
> --8<---cut here---end--->8---
>
> but I found your format to be easier to read.

I wrote that code example in org-mode and used export to text ⇒ unicode.

That came naturally, because it’s how I write my website:
https://www.draketo.de/software/guile-snippets#define-typed

source: 
https://hg.sr.ht/~arnebab/draketo/browse/software/guile-snippets.org#L394

Best wishes,
Arne


signature.asc
Description: PGP signature


Re: define-typed: checking values on proc entry and exit

2024-05-14 Thread Dr. Arne Babenhauserheide
Zelphir Kaltstahl  writes:

> On 10.05.24 15:47, Dr. Arne Babenhauserheide wrote:
> You might also be interested in my repository for function contracts
> using CK macros:
>
> https://codeberg.org/ZelphirKaltstahl/guile-examples/src/commit/0e231c289596cb4c445efb30168105914a8539a5/macros/contracts
>
> I hope I can check out your macro soon and hope to be able to understand it : 
> )

These sound pretty powerful — thank you for sharing!

I went for the simplest option that I thought could work, and CK-macros
seem to be much bigger (from skimming the code).

And the *-versions are ominous: optional and keyword arguments may be
the next frontier.

I’m not sure how to keep those simple.

Best wishes,
Arne


signature.asc
Description: PGP signature


Re: define-typed: checking values on proc entry and exit

2024-05-14 Thread Dr. Arne Babenhauserheide
Vivien Kraus  writes:

> Hello!
>
> This is an interesting approach, thank you.
>
> Le vendredi 10 mai 2024 à 09:47 +0200, Dr. Arne Babenhauserheide a
> écrit :
>> │   ;; get the result
>> │   (let ((res (helper)))
>> │ ;; typecheck the result
>> │ (unless (ret? res)
>> │   (error "type error: return value ~a does not match ~a"
>> │  res ret?))
>> │ ;; return the result
>> │ res))
>
> A nice improvement would be to support multiple return values, for
> instance by using call-with-values, and checking the return value with
> (apply ret? res) instead of (ret? res).
>
> What do you think?

That’s a nice idea!

With some experimentation I got it working:

┌
│ (import (srfi :11 let-values))
│ (define-syntax-rule (define-typed (procname args ...) (ret? types ...) body 
...)
│   (begin
│ (define (procname args ...)
│   ;; create a sub-procedure to run after typecheck
│   (define (helper)
│ body ...)
│   ;; use a typecheck prefix for the arguments
│   (map (λ (type? argument)
│  (unless (type? argument)
│(error "type error ~a ~a" type? argument)))
│(list types ...) (list args ...) )
│   ;; get the result
│   (let-values ((res (helper)))
│ ;; typecheck the result
│ (unless (apply ret? res)
│   (error "type error: return value ~a does not match ~a"
│  res ret?))
│ ;; return the result
│ (apply values res)))
│ ;; add procedure properties via an inner procedure
│ (let ((helper (lambda (args ...) body ...)))
│   (set-procedure-properties! procname (procedure-properties helper))
│   ;; preserve the name
│   (set-procedure-property! procname 'name 'procname
└

This supports most features of regular define like docstrings, procedure
properties, multiple values (thanks to Vivien!), and so forth.

┌
│ (define-typed (hello typed-world) (string? string?)
│   typed-world)
│ (hello "typed")
│ ;; => "typed"
│ (hello 1337)
│ ;; => type error ~a ~a # 1337
│ (define-typed (hello typed-world) (string? string?)
│   "typed"
│   #((props))
│   typed-world)
│ (procedure-properties hello)
│ ;; => ((name . hello) (documentation . "typed") (props))
│ (define-typed (multiple-values num) ((λ(a b) (> a b)) number?)
│   (values (* 2 (abs num)) num))
│ (multiple-values -3)
│ ;; => 6
│ ;; => -3
└


Best wishes,
Arne


signature.asc
Description: PGP signature


define-typed: checking values on proc entry and exit

2024-05-10 Thread Dr. Arne Babenhauserheide
Hi,

in #guile on IRC¹, old talked about Typed Racket so I thought whether
that could be done with define-syntax-rule. So I created define-typed.
This is also on my website², but I wanted to share and discuss it here.

I follow the format by [sph-sc], a Scheme to C compiler. It declares
types after the function definition like this:

┌
│ (define (hello typed-world) (string? string?)
│   typed-world)
└

┌
│ (define-syntax-rule (define-typed (procname args ...) (ret? types ...) body 
...)
│   (begin
│ (define (procname args ...)
│   ;; define a helper pro
│   (define (helper)
│ body ...)
│   ;; use a typecheck prefix for the arguments
│   (map (λ (type? argument)
│  (unless (type? argument)
│(error "type error ~a ~a" type? argument)))
│(list types ...) (list args ...) )
│   ;; get the result
│   (let ((res (helper)))
│ ;; typecheck the result
│ (unless (ret? res)
│   (error "type error: return value ~a does not match ~a"
│  res ret?))
│ ;; return the result
│ res))
│ ;; add procedure properties
│ (let ((helper (lambda (args ...) body ...)))
│   (set-procedure-properties! procname (procedure-properties helper))
│   ;; preserve the name
│   (set-procedure-property! procname 'name 'procname
└

This supports most features of regular define like docstrings, procedure
properties, and so forth.

┌
│ (define-typed (hello typed-world) (string? string?)
│   typed-world)
│ (hello "typed")
│ ;; => "typed"
│ (hello 1337)
│ ;; => type error ~a ~a # 1337
│ (define-typed (hello typed-world) (string? string?)
│   "typed"
│   #((props))
│   typed-world)
│ (procedure-properties hello)
│ ;; => ((name . hello) (documentation . "typed") (props))
└

This should automate some of the guards of [Optimizing Guile Scheme], so
the compiler can optimize more (i.e. if you check for `real?') but keep
in mind that these checks are not free: only typecheck outside tight
loops.

They provide a type boundary instead of forcing explicit static typing.

Also you can do more advanced checks by providing your own test
procedures and validating your API more elegantly, but these then won’t
help the compiler produce faster code.

But keep in mind that this does not actually provide static program
analysis like while-you-write type checks. It’s simply [syntactic sugar]
for a boundary through which only allowed values can pass. Thanks to
program flow analysis by the just-in-time compiler, it can make your
code faster, but that’s not guaranteed. It may be useful for your next
API definition.

My question now: do you have an idea for a better name than
define-typed?


[sph-sc] 

[Optimizing Guile Scheme]


[syntactic sugar]



¹ https://web.libera.chat/?nick=Wisp|?#guile
² https://www.draketo.de/software/guile-snippets#define-typed


Best wishes,
Arne


signature.asc
Description: PGP signature


Re: How to gradually write a procedure using Guile?

2024-05-03 Thread Dr. Arne Babenhauserheide
Hi Thomas,


I usually work by redefining the whole procedure and running it.


Typically I start with the minimal procedure

(define (hello) #f)


Then — for nicely testable procedures — 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-current-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-chickadee-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érémy 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.… 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…
>
> Jérémy
>
> Le 03/05/2024 à 02:24, Tomas Volf a écrit :
>> 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 am 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 get 
>> 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) know 
>> the
>> fundamentals of Geiser and the REPL, but I am straggling a bit in this case 
>> not
>> to fall back to the "normal" way of "write a function, run it whole against 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.


signature.asc
Description: PGP signature


Re: Some issues with guile

2024-04-27 Thread Dr. Arne Babenhauserheide
Nikolaos Chatzikonstantinou  writes:

> I don't mean to just complain. There needs to be some documentation
> consistency and once established it needs to be championed, and that's
> what I'm trying to accomplish...

Would you like to start with sending some small and easy to review
patches? As long as they are small enough and uncontroversial (and don’t
break anything), I can commit and push them.

Best wishes,
Arne


signature.asc
Description: PGP signature


Re: Some issues with guile

2024-04-27 Thread Dr. Arne Babenhauserheide
Nikolaos Chatzikonstantinou  writes:

> Of course there can be more features, such as unit tests in
> documentation, but I don't consider them essential. I don't know what

I was missing these badly when I started, so I wrote support for them
myself:

Usage:
https://hg.sr.ht/~arnebab/wisp/browse/examples/doctests-test.scm?rev=tip
Module:
https://hg.sr.ht/~arnebab/wisp/browse/examples/doctests.scm?rev=tip
Minimal example:
https://hg.sr.ht/~arnebab/wisp/browse/examples/doctests-testone.scm?rev=tip

These don’t put the tests into the documentation (where it would be
prone to parsing complexities — I got burned by Python ☺) but instead
attaches them as procedure properties (which is possible, because in
Scheme code and data are uniform: you can write code as a
datastructure).

Best wishes,
Arne


signature.asc
Description: PGP signature


Re: Changes to Guile not effecting built binary

2024-03-21 Thread Dr. Arne Babenhauserheide

Ryan Raymond  writes:

> For example, I modified "parse-http-method" and completely removed all error 
> throwing capabilities but I am still getting an error thrown from
> within that function.
> (bad-request "Invalid method: ~a" (substring str start end))
>
> I am assuming that the modules are not being rebuilt. My workflow is as 
> follows:
> 1. Modify the source code
> 2. ./configure
> 3. make
> 4. make install
>
> Can anyone point out a mistake I might be making?

A shot into the blue would be that some dependencies aren’t marked
correctly in the Makefile so some file is not being rebuilt and includes
the old version of the function via a macro.

Does it also happen when you add a `make clean` step?

Does it happen when you directly run meta/guile instead of installing?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Guile Hoot v0.3.0 released!

2024-01-30 Thread Dr. Arne Babenhauserheide

Daniel Skinner  skribis:

> congratulations on the release!

> Thompson, David  wrote:
…
>> https://fosdem.org/2024/schedule/event/fosdem-2024-2339-scheme-in-the-browser-with-guile-hoot-and-webassembly/
…
>> https://fosdem.org/2024/schedule/event/fosdem-2024-2331-spritely-guile-guix-a-unified-vision-for-user-security/

That’s great! Congratulations!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: GNU Shepherd 0.10.3 released

2024-01-07 Thread Dr. Arne Babenhauserheide

Ludovic Courtès  writes:

> We are pleased to announce the GNU Shepherd version 0.10.3, a bug-fix
> release of the new 0.10.x series, representing 51 commits over 6
> months.

Congratulations!

>   ** Fix portability issues to GNU/Hurd
>
>   Previous versions in the 0.10.x and 0.9.x series did not work on GNU/Hurd.
>   This is now fixed, although some features are still implemented in a
>   suboptimal way.

wow — nice!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Screaming-Fist: a JIT framework for Guile

2023-12-03 Thread Dr. Arne Babenhauserheide

Nala Ginrut  writes:
> Hi Folks!
> I'd like to introduce our new project named screaming-fist which is a JIT
> framework based on libgccjit.
> (import (screaming-fist jit))
>
> (jit-define (square x)
>   (:anno: (int) -> int)
>   (* x x))
> (square 5)

That looks interesting!

Do you already have performance data?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Guile Hoot v0.1.0 RELEASED!

2023-10-16 Thread Dr. Arne Babenhauserheide

Christine Lemmer-Webber  writes:

> GOOD NEWS!  Spritely's Scheme -> WASM compiler's first release is OUT!
> That's right... Scheme in your browser!!!
>
>   https://spritely.institute/news/guile-hoot-v010-released.html

Thank you! That’s awesome!

> Docs here: https://spritely.institute/files/docs/guile-hoot/0.1.0
>
> And it's already in Guix
>
>   $ guix pull
>   $ guix shell --pure guile-next guile-hoot

And since some (most) seem to have missed it when you showed the thing
that blew my mind: In Guix you can already see the example with a single
shell command:

guix shell google-chrome-unstable -- google-chrome-unstable 
https://spritely.institute/news/scheme-wireworld-in-browser.html

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Ideas for making Guile easier to approach

2023-10-05 Thread Dr. Arne Babenhauserheide

Maxime Devos  writes:

> [[PGP Signed Part:No public key for 49E3EE22191725EE created at 
> 2022-02-09T22:07:58+0100 using EDDSA]]
> Christine Lemmer-Webber schreef op wo 09-02-2022 om 10:18 [-0500]:
>> I'd like to actually see Guile integrate Wisp as a core language and
>> think about what it would be like to support it as a recommended
>> alternate way of writing programs.  I think with the new block-level
>> highlighting that Arne has written, Wisp could be near ready for prime
>> time.  This could mean:
>> 
>>  - Getting wisp actually in Guile's official languages
>>  - Figuring out how to get geiser to be nicely integrated
>>  - Figuring out how to make importing Wisp modules be as easy as
>>    importing parenthetical-lisp ones
>
> I thought that Wisp = Scheme + a custom (non-parenthetical) reader,
> so I importing Wisp modules would work the same way as Guile modules I
> think?
>
> (use-modules (some wisp foo))
>
> AFAIK the only issue here is file extensions (mapping foo/bar.go to
> foo/bar.THE-FILE-EXTENSION-OF-WISP).

You can enable that via commandline flags to Guile, but you have to
precompile wisp files for that:

$ echo "define-module : foo
  . #:export : bar

define : bar
  . 'bar
" > foo.w

$ guild compile -f wisp foo.w
$ guile -L . -x .w

scheme@(guile-user)> (import (foo))
scheme@(guile-user)> (bar)
$1 = bar


This is not the most convenient of options, but it already provides a
way to actually ship wisp to people without them having to know about
it.


Aside: this is my header for wispwot:

#!/usr/bin/env bash
# -*- wisp -*-
exec -a "$0" ${GUILE:-guile} --language=wisp -x .w -L "$(dirname "$(realpath 
"$0")")" -C "$(dirname "$(realpath "$0")")" -e '(run-wispwot)' -c '' "$@"
; !#


Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Brainstorming Wisp and Guile for financial bookkeeping

2023-10-04 Thread Dr. Arne Babenhauserheide

Christine Lemmer-Webber  writes:

> 2020-03-30 * "Starting balance"
>   Assets:Retirement:IRA1321.84 USD 
>   Equity:OpeningBalance

I wondered whether we could make this executable as it is, but for that
we’d have to create one procedure for every date.

Since accounts have to be declared with something like

account ArneBab:Assets:Autorenhonorar:epubli

creating a proc per account would actually give us some compile-time
validation.

import : ice-9 optargs


define USD 'USD
define-syntax-rule (account name)
  define* (name #:optional value currency)
list (quote name) value currency
define (entry description
account-name1 value1 currency1
account-name2 value2 currency2)
  ;; do something useful
  . description


define-syntax date
  λ : x
syntax-case x : *
  : _ * description account1 account2
#' apply entry : cons description : append account1 account2


define-syntax-rule : 2020-03-30 args ...
  date args ...


;; Missing piece: Running
;; define-syntax-rule (the-date args ...) (date args ...)
;; for each possible date.



And actually implementing some state tracking …

This already works (but only returns "Starting balance"):


account Assets:Retirement:IRA
account Equity:OpeningBalance
2020-03-30 * "Starting balance"
  Assets:Retirement:IRA1321.84 USD 
  Equity:OpeningBalance


Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Breaking hygiene with syntax-rules?

2023-08-12 Thread Dr. Arne Babenhauserheide

Walter Lewis  writes:

>> By the way, I'm rather confused as to why you deem this caching
>> useful. A priori, I would expect a simple bytevector->pointer call
>> would be just as fast as a to-pointer call. Do you somehow create
>> lots of pointers to the contents of the same bytevector so that weak
>> references they hold incur a noticeable GC overhead?
>
> To be honest I don't know enough about C to know the performance of
> bytevector->pointer, so I was assuming Chickadee's approach was done
> for a reason.

Chickadee is pretty heavily optimized (it’s by dthompson who AFAIR once
showed millions of interacting points with Guile 3). I would expect that
the to-pointer becomes fully inlined, so it’s optimized away.

> But if you think it's not a big deal then I'm happy to
> simplify things! I think I will remove this caching for now.
>
> Thanks for your help, and Arne as well for digging into the issue.

Glad to help :-) — though I cannot yet help beyond "this looks like a
bug to me".

Best wishes,
Arne

PS: I just realized that GNU is turning 40 on Sep. 30 this year … 
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Breaking hygiene with syntax-rules?

2023-08-11 Thread Dr. Arne Babenhauserheide

Jean Abou Samra  writes:

>  the macro. So I would expect this to create different identifiers for
>  different values of the-pair, just like it creates different identifiers
>  when instead of (car the-pair) I use fetch (also passed from outside).
>
> You're right, that's confusing.
>
> I don't have the time to investigate, though.

No problem — thank you for your support so far!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: [ANN] Guile-SMC 0.6.2 released

2023-08-11 Thread Dr. Arne Babenhauserheide
Hello Artyom,

"Artyom V. Poptsov"  writes:

> Hello Dr. Arne Babenhauserheide!
>
>> Very cool!
>
> Thanks.
>
>> Can Guile-SMC be used as a linter for plantuml?
>
> Yes, to some extent.  The thing is that Guile-SMC currently supports
> only a small subset of PlantUML format.  Namely it can read PlantUML
> state diagrams (obviously that was first priority for me to implement),
> but even here not all diagram features are supported.
>
> With that said, I'm planning to expand the supported subset of PlantUML
> state diagram features in the near future.

That sounds great.

> As the core parser of PlantUML format itself is compiled from PlantUML
> description with Guile-SMC, it is quite easy to add new features from
> my experience.

Just out of interest: can you post a part of the code you really like?

(I’m currently working on a webservice for work that has a state machine
in the background and it would be interesting to me to see whether I
could build a simple version of it with Guile for fun ☺ — trying to find
more elegance in this)

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: [ANN] Guile-SMC 0.6.2 released

2023-08-11 Thread Dr. Arne Babenhauserheide

"Artyom V. Poptsov"  writes:

> I'm pleased to announce Guile State Machine Compiler (Guile-SMC), version
> 0.6.2:
>   https://github.com/artyom-poptsov/guile-smc/releases/tag/v0.6.2

Very cool!

> This release fixes some new-found bugs, namely in the state-machine
> profiler.  Also now it's possible to specify "pre-action" and
> "post-action" procedures in PlantUML "legend" block.

> - A transition table can be verified and checked for dead-ends and
>   infinite loops.

Can Guile-SMC be used as a linter for plantuml?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Breaking hygiene with syntax-rules?

2023-08-11 Thread Dr. Arne Babenhauserheide

Jean Abou Samra  writes:

> This is a known limitation in Guile. Please read
> https://www.gnu.org/software/guile/manual/html_node/Hygiene-and-the-Top_002dLevel.html

I would not expect that effect from the description, because in

(define-syntax unhygienic
  (syntax-rules ()
((_ the-pair fetch)
 (begin
   (define the-head (car the-pair))
   (define (the-proc) the-head)
   (define (fetch) the-head)

the-head depends on (car the-pair) and the-pair is a variable passed to
the macro. So I would expect this to create different identifiers for
different values of the-pair, just like it creates different identifiers
when instead of (car the-pair) I use fetch (also passed from outside).

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Breaking hygiene with syntax-rules?

2023-08-10 Thread Dr. Arne Babenhauserheide

Walter Lewis via General Guile related discussions  writes:

> (define-syntax unhygienic
>   (syntax-rules ()
> ((_ the-pair fetch)
>  (begin
>(define the-head (car the-pair))
>(define (fetch) the-head)
>
> (unhygienic '(1) fetch1)
> (unhygienic '(2) fetch2)
>
> (fetch1)
>
> ;; => 2

I just tested this and see the same problem:

(unhygienic '(a) name1)
(unhygienic '(b) name2)
(name1) ;; => b
(name2) ;; => b

So it’s reproduced. Thank you for the minimal example!

> It seems that the second call to unhygienic shadows the previous
> definition of the-head. I expected syntax-rules to generate fresh
> names for it each time.
>
> Is this expected, and if so, is there any way to generate an internal
> definition using syntax-rules? For my case, I was writing a macro to
> generate SRFI-9 record definitions, but I noticed some of the getters
> and setters which I intended to be private were shadowing each other.

I did not expect this.

To track this:

(define-syntax unhygienic
  (syntax-rules ()
((_ the-pair fetch)
 (begin
   (define the-head (car the-pair))
   (define (the-proc) the-head)
   (define (fetch) the-head)
   (display the-proc)

(display the-head)
;; => error Unbound variable: the-head (step out of the debugger with C-d)
(unhygienic '(a) name1)
;; => # (the proc has a long suffix, 
looks good)
(display the-head)
;; => error: Unbound variable: the-head (looks good?)
(name1) ;; => a
(unhygienic '(b) name2)
;; # (the suffix of the proc is the 
same as for the one in a?)
(name1) ;; => b

Maybe this is just, because the procedure is *the same*?
Let’s use fetch in the-proc:

(define-syntax unhygienic
  (syntax-rules ()
((_ the-pair fetch)
 (begin
   (define the-head (car the-pair))
   (define (the-proc) fetch)   
   (define (fetch) the-head)
   (display the-proc)
(unhygienic '(a) name1)
;; => #
(unhygienic '(b) name2)
;; => #
(name1)
;; => b


Now the proc is no longer the same, but the variable still collides.

Auto-completion in the REPL
the-head-
;; => the-head-3f6c11022fffe02

the-head also has a suffix, as it should have, but there is only one.

Does the counter go wrong?

One more check:

(define-syntax unhygienic
  (syntax-rules ()
((_ the-pair fetch)
 (begin
   (define the-head fetch)
   (define (the-proc) fetch)   
   (define (fetch) the-head)
   (display the-proc)

Now using fetch in the-head I get two different variables in the shell.

Maybe detection of external data is missing that the-pair is external?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: GNU Shepherd 0.10.2 released

2023-07-17 Thread Dr. Arne Babenhauserheide

Ludovic Courtès  writes:

> We are pleased to announce the GNU Shepherd version 0.10.2, a bug-fix
> release of the new 0.10.x series, representing 28 commits over 7 weeks.
>
> The 0.10.x series is a major overhaul towards 1.0, addressing shortcomings
> and providing new features that help comprehend system state.

>   https://www.gnu.org/software/shepherd/

The changes look really cool! Thank you all!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Evaluation with function whitelist

2023-07-16 Thread Dr. Arne Babenhauserheide

Mike Gran  writes:
> So I went ahead and checked in a working version of
> my constrained REPL plus a constrained environment in the
> (sandy sandy) module found here:
> https://github.com/spk121/guile-web-sandbox/tree/master/module/sandy

"Containerized web repl" — that sounds awesome!

If you want to use websockets to communicate with it, you may be able to
take some of my code from dryads wake:

https://hg.sr.ht/~arnebab/dryads-sun/browse/game-helpers.w?rev=tip#L458

There were some hacks needed to cleanly forward the websocket to ports
in fibers.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Evaluation with function whitelist

2023-07-15 Thread Dr. Arne Babenhauserheide

Ryan Raymond  writes:

> Thank you, all. I think it's safe to consider this matter concluded!

Great to hear that — good luck!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Evaluation with function whitelist

2023-07-15 Thread Dr. Arne Babenhauserheide
Hi Mike,

Mike Gran  writes:

>>good choice. Basically, I want the user to be able to open a repl shell,
>>but by default it should have *no* bindings except the ones I whitelisted.
> Define a module in a file with the "#:pure" option so that it starts off 
> empty.
…
> Using the real repl is probably a no-go, since it has meta-commands
> like ",m" that would let the user ignore your whitelist.
>
> I didn't really test this, but it should be mostly correct.

Sandboxed Evaluation may also be interesting for this:
https://www.gnu.org/software/guile/manual/html_node/Sandboxed-Evaluation.html
(to prevent users from blocking the process)

If you want a long term view for the most powerful approach that
preserves allow-listing, see Spritely Goblins:
https://spritely.institute/files/docs/guile-goblins/latest/A-simple-greeter.html

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Python slices in Scheme

2023-06-24 Thread Dr. Arne Babenhauserheide

Damien Mattei  writes:

> really easy and powerful, but i dislike decorator, i prefer scheme's macro
> but i think too it has no sense to write big macros, in my opinion they
> should be short and avoid them when possible.

Do you know my Zen for Scheme? In that I tried to capture what I learned
about Scheme programming in my first decade with Scheme:
https://www.draketo.de/software/zen-for-scheme

The point that applies here is:

WM:
Use the Weakest Method that gets the job done,
but know the stronger methods to employ them as needed.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Python slices in Scheme

2023-06-18 Thread Dr. Arne Babenhauserheide

Damien Mattei  writes:

> yes it needs SRFI 105 Curly infix to allow full notation.
> It defines the optional $bracket-apply$ procedure or macro (here a macro)
> as described in SRFI 105. The code is in attachment (not in my github
> because there is a lot of work again to have the same powerful and easy
> affectation between 2 arrays than in Python)

thank you!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Python slices in Scheme

2023-06-18 Thread Dr. Arne Babenhauserheide
Hi Damien,

> {#(1 2 3 4 5 6 7)[2 / 5]}
> #(3 4 5)

that looks pretty interesting. Is it compatible to curly infix / SRFI-105?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: [ANN] Guile-PNG 0.4.0 released

2023-05-01 Thread Dr. Arne Babenhauserheide

"Artyom V. Poptsov"  writes:

> I'm pleased to announce Guile-PNG 0.4.0, Portable Network Graphics
> (PNG)[1] library for GNU Guile, implemented in pure scheme:
>   https://github.com/artyom-poptsov/guile-png/releases/tag/v0.4.0

Very cool! Thank you!

A thought: One Guile can be compiled to wasm (the project by Spritely
and Andy Wingo), that would mean that we’d have an alternative to
canvas: creating PNGs and replacing them at runtime.

> References:
> 1. https://www.rfc-editor.org/rfc/rfc2083
> 2. https://notabug.org/guile-zlib/guile-zlib/
> 3. https://github.com/artyom-poptsov/guile-smc

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: GPT-4 knows Guile! :)

2023-03-19 Thread Dr. Arne Babenhauserheide

Nala Ginrut  writes:

> GPT is interesting, to whom may also interested in, I've tried to use GPT to 
> generate friend error message for compiler.
>
> https://nalaginrut.com/archives/2023/03/12/use%20chatgpt%20for%20compiler%20error%20regeneration

I asked ChatGPT whether it would rather break a law or break the
community-rules. After some tries to evade the question, this happened:

> An error occurred. If this issue persists please contact us through our help 
> center at help.openai.com. 

This is concerning — but expected. At least it didn’t lie.

https://www.draketo.de/politik/kommentare#chatgpt-geltendes-recht

(translated:
https://www-draketo-de.translate.goog/politik/kommentare?_x_tr_sl=de&_x_tr_tl=en&_x_tr_hl=de&_x_tr_pto=wapp#chatgpt-geltendes-recht
 )

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: GPT-4 knows Guile! :)

2023-03-19 Thread Dr. Arne Babenhauserheide

 writes:

> which has tried to be free (in both senses). For images, there is
> Stable Diffusion (disclaimer:I don't know much about them). For
> raw data, there's Common Crawl [3], which is Stable Diffusion's

Stable diffusion has one of the most evil licenses I’ve read till now:
using its images seems to be allowed for almost all proprietary uses,
but illegal for free culture use. See the explicit questions about that
here: https://github.com/CompVis/stable-diffusion/issues/131

A license that makes its output only usable for proprietary creations
but not for free culture is like the polar opposite of the GPL or CC
by-sa: making a tool that gives proprietary creations an advantage over
Free Culture.

Some quotes:

> Does this mean that the CreativeML Open RAIL-M license makes output
> from the model incompatible with copyleft Free Culture and Free
> Software licenses, so it would for example be illegal to use any of
> the output in Wikipedia? Is there legal uncertainty about that?
…
> The first thing to say is that this license is about as far away from
> open source as it could possibly get.
…
>> "No use of the output can contravene any provision as stated in the 
>> License.".

> A Japanese lawyer I know told me that, in general terms, releasing
> output under the CC-BY could be a violation of the license if such a
> provision exists. (* He is not familiar with this license and has not
> reviewed it in detail)

No answer from the developers.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Does declaration order matter in guile?

2023-02-14 Thread Dr. Arne Babenhauserheide

wolf  writes:

>> 1. You bind 'foo' to the syntax transformer.
>> 
>> 2. During the compilation of (foo y), the compiler calls the syntax 
>> transformer to
>>affect the generation of code, so it will do the right thing.
>
> Interesting, I think I understand the difference. So in some ways this can be
> compared to the C pre-processor? Is there a way to view the resulting code
> after all the transformations were applied?

In the guile shell you can use

,expand (foo 1)

to see what it expands to.

Also see

,h compile

> Meaning that if I want to use the many guile- libraries available under guix
> and elsewhere, the most pragmatic approach would be to just not care about 
> R6RS
> vs R7RS all that much, and just do what guile manual recommends. Correct?

R7RS vs. R6RS isn’t that big of a difference in Guile, because it mostly
supports both and you can mostly use either of them.

R7RS is cleaner is some ways and managed to re-unite some of the Scheme
implementations (that were split between R5RS and R6RS). So knowing R7RS
means that you can make your code run in a much larger number of
domains, and you can keep many of your skills even when moving from
mostly server-side webdev (i.e. Chicken or Guile¹) to embedded (Chibi),
or to shipping binaries(i.e. Gambit or bigloo), or even Java/JWM (kawa),
or to others (see https://ecraven.github.io/r7rs-benchmarks/).

Why Guile? https://www.draketo.de/software/guile-10x
Why others? 
https://wingolog.org/archives/2013/01/07/an-opinionated-guide-to-scheme-implementations

¹: partially moving into clientside via Guilescript or others:
   https://www.draketo.de/software/wisp#guilescript-2023-01-10
   https://srfi-email.schemers.org/schemeweb/msg/11606995/
   https://github.com/schemeweb/wiki/wiki/frontend

Also Spritely started working on Guile on WebAssembly:
https://spritely.institute/news/guile-on-web-assembly-project-underway.html

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Does declaration order matter in guile?

2023-02-13 Thread Dr. Arne Babenhauserheide

Sascha Ziemann  writes:

> Am So., 12. Feb. 2023 um 20:52 Uhr schrieb Taylan Kammer
> :
>>
>> On 12.02.2023 19:46, wolf wrote:
>>
>> > 1. When does order matter? What is going on here?
>>
>> The order matters in this case because the SRFI-9 implementation in Guile 
>> defines
>> syntax (macros) rather than just variables bound to procedures.
>
> This is a huge problem of Scheme in general, that you can not
> distinguish between
> procedures and macros just by looking at the code. You have to know it
> or you have
> to look it up in the manual.

I see this as a strength, because it allows me to start with a procedure
and switch it to be a macro later on if I need to.

That way I can start with the weaker but easier to reason about
construct and move to the stronger one when needed.

> You also can not ask Scheme about macros, because macros are not
> first-class-citizens.

Actually you can, though you need to take a detour through modules:

(define-syntax-rule (foo) #f)
(define (bar) #f)

(macro? (module-ref (current-module) 'foo))
;; => #t
(macro? (module-ref (current-module) 'bar))
;; => #f

(that’s from the info reference manual)

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Spritely Goblins v0.10 released for both Guile and Racket!

2023-01-30 Thread Dr. Arne Babenhauserheide

Christine Lemmer-Webber  writes:

> Hey everyone!  I'm excited to announce a *huge* release of Goblins!
> The whole engineering team (Jessica Tallon, David Thompson, and of
> course myself) have been plugging away hard on this release and now
> we're thrilled to announce Goblins 0.10 for both Guile and Racket:
>
>   
> https://spritely.institute/news/spritely-goblins-v010-for-guile-and-racket.html

That’s awesome! Thank you for all your work!

> For more about Goblins, read its homepage:
>
>   https://spritely.institute/goblins/
>
> Or the Heart of Spritely whitepaper!
>
>   https://spritely.institute/static/papers/spritely-core.html
>
> That's all!  If you make something cool with Goblins, please let us
> know!

I so much want to … this would also make for awesome student-projects.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Static site generator

2023-01-13 Thread Dr. Arne Babenhauserheide

Sascha Ziemann  writes:

> All you need is quasiquote, unquote and a function which formats SXML as XML.
>
> (html
>  `(""

I use something like this with Guile:

https://hg.sr.ht/~arnebab/guile-freenet/browse/fetchpull-standalone.scm?rev=tip#L604

(define (website-content port)
  (define title "Fetch-Pull-Stats re-woven")
  (sxml->xml
`(*TOP*
(html
   (head (title ,title)
  (meta (@ (charset "utf-8"
   (body (h1 ,title)
 (p (img (@ (src "fetchpull.png") (alt "fetch-pull-statistics"
 (p "created with " 
 (a (@ (href 
"https://bitbucket.org/ArneBab/freenet-guile/src/default/fetchpull.w;) (title 
"link to project"))
   "fetchpull.w"))
 (p "plotted with "
 (a (@ (href "fetchpull-plot.gnuplot"))
   "fetchpull-plot.gnuplot")
port))


More complex version with more examples for solutions to needs:

https://hg.sr.ht/~arnebab/guile-freenet/browse/fetchpull.w?rev=tip#L794
(this one is with wisp: https://www.draketo.de/software/wisp )

define : website-content port
_ define title "Fetch-Pull-Stats re-woven"
_ sxml->xml
_   ` *TOP*
_   html
_  head : meta : @ (charset "utf-8")
_ title ,title
_  body : h1 ,title
_p "These are the fetch-pull statistics. They provide an estimate 
of lifetimes of real files in Freenet and a somewhat early warning when network 
quality should degrade."
_p "Realtime are 80 bytes. Small are 128 kiB. Bulk is 1MiB."
_p "Further details are explained below the diagrams."
_,@ map : λ (attributes) : ` p : img ,attributes ;; create multiple 
images without unnecessary ceremony
_  '
_@ (src "fetchpull-lifetime-realtime-success-count.png") (alt 
"lifetime plot: successes per month, realtime")
_@ (src "fetchpull-lifetime-small-success-count.png") (alt 
"lifetime plot: successes per month, small bulk")
_@ (src "fetchpull-lifetime-bulk-success-count.png") (alt 
"lifetime plot: successes per month, large bulk")
_@ (src "fetchpull-get-realtime.png") (alt "fetch-pull realtime 
download graph")
_@ (src "fetchpull-get-small.png") (alt "fetch-pull small 
download graph")
_@ (src "fetchpull-get-bulk.png") (alt "fetch-pull bulk 
download graph")
_@ (src "fetchpull-get-failed-realtime.png") (alt "fetch-pull 
failed realtime download graph")
_@ (src "fetchpull-get-failed-small.png") (alt "fetch-pull 
failed small download graph")
_@ (src "fetchpull-get-failed-bulk.png") (alt "fetch-pull 
failed bulk download graph")
_@ (src "fetchpull-put.png") (alt "fetch-pull upload graph")
_@ (src "fetchpull-put-failed.png") (alt "fetch-pull failed 
upload graph")
_@ (src "fetchpull-lifetime-realtime.png") (alt "lifetime plot: 
time per download, realtime")
_@ (src "fetchpull-lifetime-small.png") (alt "lifetime plot: 
time per download, small bulk")
_@ (src "fetchpull-lifetime-bulk.png") (alt "lifetime plot: 
time per download, large bulk")
_h2 "explanation"
_p "Files uploaded regularly with the download attempted after some 
delay. 
Realtime is uploaded with realtime priority, small and bulk with bulk priority. 
Details are available in fetchpull.w (see sources)"
_p "Realtime is a raw KSK without any redirect. Size 80 bytes, 
Uploaded and downloaded in realtime mode without compression, using all tricks 
to reduce latency. This is the fake chat-message: What you would use for 
interactive status updates and such."
_p "Small is a KSK splitfile (a KSK that has the links to about 7 
CHKs, needs 3-4). Size 128kiB uncompressed, around 80kiB compressed, Uploaded 
and downloaded in bulk mode."
_p "Bulk is a KSK which forwards to a CHK splitfile that has around 
40 blocks, needs about 20 to download. Size 1MiB uncompressed, around 650kiB 
compressed, uploaded and downloaded in bulk mode."
_p "This page is generated by running " : code "./fetchpull.w 
--site fetchpullstats"
_;; the following is just for fun. Not ready for production. 
You have been warned :-)
_. " " ,(> and then ,(string-append "uploaded" " " "with") 
freesitemgr (from pyFreenet ,{1 + 2}) as freesite.)
_br
_. "Feel free to create your own version."
_h2 "Sources"
_ul
_  li "created with " 
_  a : @ (href "fetchpull.w") (title "link to exact file which 
generated this site")
_. "fetchpull.w"
_  li "from project "
_  a : @ (href "https://bitbucket.org/ArneBab/freenet-guile;) 
(title "link to project")
_. "guile-fcp"
_  li "plotted 

Re: Fibers 1.2.0 released

2022-12-23 Thread Dr. Arne Babenhauserheide

Aleix Conchillo Flaqué  writes:

> - Support streaming responses in Fibers' web server to allow for bigger
> responses.

That’s very cool — thank you!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: [ANN] Guile-PNG 0.3.0 released

2022-12-18 Thread Dr. Arne Babenhauserheide

"Artyom V. Poptsov"  writes:

> I'm pleased to announce Guile-PNG 0.3.0, Portable Network Graphics
> (PNG)[1] library for GNU Guile, implemented in pure scheme:
>   https://github.com/artyom-poptsov/guile-png/releases/tag/v0.3.0
>
> This version adds ability to draw polygons and filled rectangles, as
> well as fixes line drawing algorithm.  Also now Guile-PNG allows to
> create PNG images from scratch.

That sounds great!

I’ve been missing a way to create images with minimal dependencies, and
this may just fill that gap.

Thank you!

> Also this is the third project of mine that uses Guile State Machine
> Compiler (Guile-SMC)[3].

Very cool!

> References:
> 1. https://www.rfc-editor.org/rfc/rfc2083
> 2. https://notabug.org/guile-zlib/guile-zlib/
> 3. https://github.com/artyom-poptsov/guile-smc

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: relocatable guile on windows

2022-12-04 Thread Dr. Arne Babenhauserheide

"Dr. Arne Babenhauserheide"  writes:

> Mike Gran  writes:
>> There is a README-win.txt file that explains how you might use it to
>> distribute a game jam game on Windows.
>>
>>   https://github.com/spk121/guile/blob/reloc-package/README-win.txt
>
> This may be just a hack, but it is absolutely awesome!

> It finally solves the problem of getting Guile-tools to Windows-using
> friends. (now I just have to learn how to follow that)

And this sounds like it could make games actually feel like standalone
games:

> The purpose of this is to allow someone to just double-click on the
> Guile executable to launch an app without requiring a shell script.

https://github.com/spk121/guile/blob/reloc-package/README-win.txt

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: relocatable guile on windows

2022-12-04 Thread Dr. Arne Babenhauserheide

Mike Gran  writes:
> There is a README-win.txt file that explains how you might use it to
> distribute a game jam game on Windows.
>
>   https://github.com/spk121/guile/blob/reloc-package/README-win.txt

This may be just a hack, but it is absolutely awesome!

It finally solves the problem of getting Guile-tools to Windows-using
friends. (now I just have to learn how to follow that)

Thank you very much!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Looking for a computation benchmark in Guile

2022-11-10 Thread Dr. Arne Babenhauserheide

Olivier Dion via General Guile related discussions  writes:

>  1. No I/O
>  2. No delimited computation (no rewind of the stack)
>  3. No foreign call
>  4. Can be multi-thread (would be great actually)
>  5. Reproducible (pure computation are great candidate)
>
> Also, maybe there's already standardized benchmark also for Scheme.  If
> so a link to them or an implementation in Guile would be awesome.
>
> If you have a scenario like that, please contact me!

There is a set of benchmarks on
https://ecraven.github.io/r7rs-benchmarks/

I expect that you’ll find a matching benchmark there, and you can then
also see how the overhead compares to the spread of speeds of different
Scheme implementations.

Code: https://github.com/ecraven/r7rs-benchmarks

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: speed difference between Guile and Racket (and Python)

2022-11-07 Thread Dr. Arne Babenhauserheide

Damien Mattei  writes:

> when comparing the (almost) same code running on Guile and Racket i find
> big speed difference:

Schemes differ a lot in speed of different tasks, but Racket is one of
the fastest ones. Factor 2 difference sounds plausible. For a
comparison, see the r7rs benchmarks:
https://ecraven.github.io/r7rs-benchmarks/

That said, I have seen 10x speedups in Guile code when people went for
optimizing it.

> last version of code is here:
> https://github.com/damien-mattei/library-FunctProg/blob/master/guile/logiki%2B.scm#L3092

Could you give the shell commands to setup and run your speed-test?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Fibers web server: use multiple server sockets

2022-11-02 Thread Dr. Arne Babenhauserheide

 writes:
> As far as I understand Vivien, interfaces come and go during the
> server's lifetime. I.e. it's not just a "boot" thing. This seems
> like a valid use case.
On some servers you might actually pull out an interface during runtime
to hotswap a new one — for example because it signaled that it is short
of failing.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Web development without connections to external repl (in geiser)

2022-10-16 Thread Dr. Arne Babenhauserheide

Dmitry Polyakov  writes:

>> Using fibers, I thought I could run the web server in seperate thread
>> that dont block current one where, for example, I could rebind the
>> handler (via ice-9 atomics or something). But it's not, after eval
>> (run-server handler), repl get stuck. May be I misunderstood something?
>> This is code:
>
> May this is because of main thread is blocked by REPL?

Have a look at the cooperative REPL in chickadee:
https://www.gnu.org/software/guile/manual/html_node/Cooperative-REPL-Servers.html
https://dthompson.us/manuals/chickadee/Live-Coding.html

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: The Spritely Institute publishes A Scheme Primer (the long-requested "Guile tutorial"?)

2022-07-07 Thread Dr. Arne Babenhauserheide

Luis Felipe  writes:

> [[PGP Signed Part:No public key for 39E0C7637A39C6A9 created at 
> 2022-07-07T15:21:16+0200 using RSA]]
> On Thursday, July 7th, 2022 at 06:04, Dr. Arne Babenhauserheide 
>  wrote:
>
>> A also think, since this is an org-file, it would be a natural fit to
>> turn this into a printed tutorial. Just make it a PDF, add a title page,
>> and you can get it printed as POD (i.e. https://www.epubli.de/ ) —
>> including access via the usual webshops for books.
>
> +1

I tried that now and hit the roadblock of codeblocks in footnotes.

I’m not yet sure how to proceed with those huge footnotes :-)

But I’m sure we’ll find a way.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: The Spritely Institute publishes A Scheme Primer (the long-requested "Guile tutorial"?)

2022-07-07 Thread Dr. Arne Babenhauserheide

Christine Lemmer-Webber  writes:

> Hello all!
>
> I'm thrilled to announce that The Spritely Institute has published A
> Scheme Primer:
>
>   
> https://spritely.institute/news/the-spritely-institute-publishes-a-scheme-primer.html
>   https://spritely.institute/static/papers/scheme-primer.html
>
> Source:
>   https://gitlab.com/spritely/scheme-primer

Very cool!

> and yes since the source is a .org file, there's a .info export:
>   https://spritely.institute/static/papers/scheme-primer.info

> I've considered making a Guix package of the .info version.  What do
> people think?  Would that be useful?

I think that would be useful, yes.

A also think, since this is an org-file, it would be a natural fit to
turn this into a printed tutorial. Just make it a PDF, add a title page,
and you can get it printed as POD (i.e. https://www.epubli.de/ ) —
including access via the usual webshops for books.

If you don’t want to do that, I can do it for you (I’ve been doing that
for roleplaying books for some years now; also exported from org mode).

The only thing I can’t do is a nice logo for the cover, but I have the
feeling that that isn’t the biggest of hurdles for you?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Wiki && Re: [feature request] merge sxml->html from (haunt html) into guile?

2022-06-29 Thread Dr. Arne Babenhauserheide

Maxime Devos  writes:

> Blake Shaw schreef op wo 29-06-2022 om 01:34 [+0700]:
>> Which brings up another thing I've been considering working on thats
>> been discussed in the Guix community: the need for click-to-edit
>> wiki, written in Guile. [...]
>
> I don't think ‘written in Guile’ has been discussed?
>
> Also, I don't see the point in writing our own wiki software in Guile
> when there's already plenty of Wiki software in existence with lots of
> tools for moderation, version control, backups, lots of testing, etc.
> Why not reuse pre-existing work instead of reinventing the wheel (likely
> poorly, at least at first)?

There are at least two good reason for re-inventing the wheel:

- learning the domain
- experimenting with how the ways to a good implementation differ in another 
language

If those were rejected out of hand, most existing wiki software would
have never been written.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: 64-bit Guile on Windows

2022-06-28 Thread Dr. Arne Babenhauserheide

Maxime Devos  writes:

> [[PGP Signed Part:No public key for 49E3EE22191725EE created at 
> 2022-06-28T18:14:22+0200 using EDDSA]]
> Thomas Thiriez via General Guile related discussions schreef op di 28-
> 06-2022 om 16:41 [+0200]:
>> Jean Abou Samra  writes:
>> 
>> > Le 27/06/2022 à 15:56, Thomas Thiriez via General Guile related
>> > discussions a écrit :
>> [...]
>> > > (* 999 999 999) -> -76738825
>> [...]
>> > 
>> > We had exactly the same problem at LilyPond, and this was the 
>> > fix:
>> > 
>> > https://gitlab.com/lilypond/lilypond/-/blob/master/release/binaries/lib/dependencies.py#L721
>> > 
>> > Namely, you need to patch libguile/conv-integer.i.c and
>> > conv-uinteger.i.c to replace "SIZEOF_TYPE < SIZEOF_SCM_T_BITS"
>> > with "SIZEOF_TYPE < SIZEOF_LONG".
>> > 
>> > HTH,
>> > Jean
>> 
>> Thanks for the info. I have tried this, but it doesn't appear to 
>> be helping.
>> 
>> I did a few tests with lilypond, and here is what I found. I have 
>> a test.scm file containing:
>> 
>> (display (* 999)) (newline)
>> (display (* 999 999)) (newline)
>> (display (* 999 999 999)) (newline)
>> 
>> lilypond.exe -e '(load \"test.scm\")' test.ly
>> GNU LilyPond 2.23.10 (running Guile 2.2)
>> 999
>> 998001
>> 997002999
>> 
>> That is fine. Now, if I try compiling test.scm to test.go, I get:
>> 
>> lilypond.exe -e '(use-modules (system base compile))(compile-file 
>> \"test.scm\" #:output-file \"test.go\")' test.ly
>> GNU LilyPond 2.23.10 (running Guile 2.2)
>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>> In procedure bytevector-u64-set!: Value out of range: -149659645
>
> Possibly fixnum-related, so maybe:
>
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=42060
>
> Maybe 32-bit <-> 64-bit related, so maybe:
>
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28920
>
> Also, guile@2.2 is not developed anymore AFAICT.

From what I see, Guile 2.2 does still get fixes, but no larger changes.
See https://git.savannah.gnu.org/cgit/guile.git/log/?h=stable-2.2

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Curiosity: Microkernel implemented in Guile ?

2022-06-26 Thread Dr. Arne Babenhauserheide

Ricardo Wurmus  writes:

> "Dr. Arne Babenhauserheide"  writes:
>
>> - The compilation-messages (I hate them; these also hurt when writing
>>   interactive utilities for the command-line, and I have too many
>>   half-working fixes in script files to still be comfortable; I think I
>>   once had a fix in configuration, but I lost it again — or maybe I had
>>   just hacked Guile)
>
> I use compilation (of Wisp) in the GWL and I silence output while
> compiling by redirecting the current-error-port / current-output-port.

Those are my half-working fixes, too :-)

But from time to time I have a real error in a file and don’t get the
compilation messages (like "using unbound variable"). That’s why I think
that they are only half-working.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Curiosity: Microkernel implemented in Guile ?

2022-06-26 Thread Dr. Arne Babenhauserheide

Jean Abou Samra  writes:
> (Also replying to Nala.) On the one hand, you have Guile without
> compiled
> bytecode, which is slow to run, and more importantly painful to use
> because there are no error locations and often no function names in
> error messages. On the other hand, Guile with bytecode takes compilation
> time, which is an impediment in applications where it is merely being
> used as a language that is practical to use for small extensions to an
> existing program, without a need for optimized code. It forces you to
> recompile even if you just touched one file, since otherwise it emits
> ;;; messages about outdated .go files that create noise and/or affect
> correctness. The compilation is impractical to set up when interfacing
> with C if your main function is on the C side since compiling is started
> from the Scheme side. There is no dependency tracking, so you need to
> recompile everything whenever you change one file, which does not
> encourage
> quick experiments. Bytecode is fussy to integrate in installers: when
> the user
> unpacks an archive, you need to ensure that the .go files are unpacked
> after the .scm files, otherwise Guile will consider them outdated. I
> could list more …

Please do! I’ve been trying to get a concrete list for issues hurting
Lilypond for a long time.

To summarize what I understood so far (with notes):

- The compilation-messages (I hate them; these also hurt when writing
  interactive utilities for the command-line, and I have too many
  half-working fixes in script files to still be comfortable; I think I
  once had a fix in configuration, but I lost it again — or maybe I had
  just hacked Guile)

- No dependency tracking for the explicit compilation, so changes to
  Guile-code used elsewhere require an expensive re-compilation step,
  even though compile-times are just what you want to avoid with a
  scripting language ⇒ auto-compilation should just work and be
  *silent*. Could this be fixed with a tool that recovers those
  dependencies from Scheme-files? Something like
  ./list-dependent-files.scm --start foo.scm bar.scm baz.scm moo.scm goo.scm
  ⇒ bar.scm
baz.scm

> Sorry for not exactly bringing enthusiasm to this otherwise interesting
> thread.

Don’t worry. I asked, and I’m glad you answered. There might be things
that cannot be fixed, but I have not yet seen one here.

Though I don’t want to give false hope: I am not a core developer, so I
cannot promise fast fixes. I can only promise that I will help pushing
Guile more into the direction that Lilypond needs.

Because for me, Lilypond is one of the most important tools that use
Guile. I use several Guile-using tools nowadays, but the only one I
could really not do without is Lilypond.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Curiosity: Microkernel implemented in Guile ?

2022-06-24 Thread Dr. Arne Babenhauserheide

Ognen Duzlevski  writes:

> I considered embedding a scheme interpreter into a kernel for fun (!)
> but even then (non-commercial interest), I only thought of kernels that
> are actually used by others ;)

There actually are people using the Hurd. Not many, but some. And with
Guix, the hurd is just a service definition away:

 (services (append
(list
 ; login to temporary hurd-vm via sudo herd start childhurd && ssh 
root@localhost -p 10022
 (service hurd-vm-service-type
  (hurd-vm-configuration
   (options '("--snapshot" "-cpu host"))
   (disk-size (* 30 (expt 2 30))) ;30G
   (memory-size 8192))) ;8192MiB
;; ... other services ...
)))

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Curiosity: Microkernel implemented in Guile ?

2022-06-24 Thread Dr. Arne Babenhauserheide

Jean Abou Samra  writes:

>> Le 24 juin 2022 à 03:13, Nala Ginrut  a écrit :
>> 
>> Agreed, Guile's design was widened.

> Let’s be honest: it wasn’t widened, but shifted. I don’t think today’s Guile 
> is a good fit for an extension language.

Why? Which change caused it to not be good as extension language?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Curiosity: Microkernel implemented in Guile ?

2022-06-23 Thread Dr. Arne Babenhauserheide

Nala Ginrut  writes:

> Agreed, Guile's design was widened. But I think we are talking about
> different "low-level", for Hurd, Guile can be used to write OS
> components, say, filesystem. However, except for GNU Mach, most OS
> components are implemented in userland, and Guile is good for that,
> this is what it's designed for. The "low-level" in my mind is to write
> GNU Mach part, which is not suitable for Guile.

Ah, there’s you’re right.

Though the loko linked by Ricardo sounds interesting. The license is
AGPL compatible.

And the tagline is neat: “Give it some RAM and a supported machine, and
it gives you a REPL.”

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Curiosity: Microkernel implemented in Guile ?

2022-06-23 Thread Dr. Arne Babenhauserheide

"Ricardo G. Herdt"  writes:

> Never tried it myself, but in case you are interested in exploring
> Scheme for this kind of development, check Loko Scheme, which runs on
> bare-metal and is developed to be a "platform for application and
> operating system development":
>
> https://scheme.fail/
>
> There is also a #loko channel on libera.

And loko is crazy fast. See https://ecraven.github.io/r7rs-benchmarks/

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Curiosity: Microkernel implemented in Guile ?

2022-06-23 Thread Dr. Arne Babenhauserheide

Nala Ginrut  writes:
> Many folks shared great Scheme for lower-level. I think I have to clarify
> that I agree that Scheme is good for low-level, depends on implementation.
> But we are talking about Guile, and Guile was not designed for that
> purpose, it's dedicated to extend C program, so the better choice is to
> extend a C microkernel with Guile. That is what it was designed for,
> originally.

In recent years the scope of Guile widened in that respect, so it’s very
suited to implement many more parts of the system than it was with Guile
1.x — with Guile 3 it starts to compete in performance.

It might be suitable for many parts of the kernel nowadays.

And the Hurd is a good way to get low level with much fewer risks than
Linux kernel hacking.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Curiosity: Microkernel implemented in Guile ?

2022-06-23 Thread Dr. Arne Babenhauserheide

Ognen Duzlevski  writes:

> Matias Jose Seco Baccanelli  writes:
>> Isn't a cool mix the functional approach of Guile and the modular one
>> of Microkernel ? (and loads of more features i suppose!)
>
> What I think would be easier to do is embed Scheme inside an OS kernel

With the Hurd you reduce the scope of what is the kernel, so Scheme can
do lots of jobs usually reserved for lower-level languages. You could
for example write your complete filesystem or networking layer in
Scheme.

This may sound strange at first, but LuaJIT is already used for packet
filtering, so it’s not that far out. For the performance critical parts,
you can still FFI to Rust or C.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Curiosity: Microkernel implemented in Guile ?

2022-06-23 Thread Dr. Arne Babenhauserheide
Moin Matias,

Matias Jose Seco Baccanelli  writes:
> Isn't a cool mix the functional approach of Guile and the modular one
> of Microkernel ? (and loads of more features i suppose!)
>
> Feels like a nice recipe for User Empowerment !

The most practical way forwards for that might be Guile bindings for the
Hurd. Those would enable to move more Guile in incrementally while
always keeping a working state.

The incubator already has bindings for common-lisp.¹ Those could be a
good starting point. And there is Guix for the Hurd.

http://git.savannah.gnu.org/cgit/hurd/incubator.git/?h=clisp

Those bindings would allow for stuff like this to be done in Guile:

Deferred Authorization translator for the Hurd
https://www.draketo.de/software/hurd-authorization-translator

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Fibers 1.1.1 released

2022-06-04 Thread Dr. Arne Babenhauserheide

Aleix Conchillo Flaqué  writes:

> On behalf of the Fibers team, I am excited to announce Fibers 1.1.1.
>
> Fibers is a lightweight concurrency facility for Guile that supports 
> non-blocking input and output, millions of concurrent threads, and Concurrent
> ML-inspired communication primitives. For more information, see the web 
> version of the manual at:
>
>   https://github.com/wingo/fibers/wiki/Manual
> * Changes since 1.1.0
>
> - Always add file descriptors finalizer in (schedule-task-when-fd-active).
> - Do not load 'epoll.so' during cross-compilation.
> - Pass '--target' and '-L' to 'guild compile' when cross-compiling.
> - Do not refer to 'epoll.so'-provided variables at expansion time.
> - Install .go files to …/site-ccache, not …/ccache.

Very cool! Thank you for the release!

I use fibers in dryads wake,¹ and it allowed me to wrap my head around
mapping websockets to standard input and output without running into
concurrency problems, and that’s pretty awesome!

¹: https://dryads-wake.1w6.org

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: [EXT] Use Chickadee to render animation to file?

2022-06-01 Thread Dr. Arne Babenhauserheide
Hi Jack,

Jack Hill  writes:

> Thanks for the positive response and, of course for Chickadee (and
> Haunt, etc.)! I might give it a go, but no promises as it could very
> well be too much for me to bite off at this time.

If you get to do this, I’d love to hear about it!

I’m working with my daughter on a small game with Chickadee and
rendering animations to file would provide a great way to create screen
captures to showcase games for those who can’t run them yet.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: [ANN] Guile-INI 0.4.0 released

2022-03-14 Thread Dr. Arne Babenhauserheide

"Artyom V. Poptsov"  writes:

>   https://github.com/artyom-poptsov/guile-ini/releases/tag/v0.4.0
>
> * Version 0.3.0 (2022-03-13)
> ** Update to use the new Guile-SMC 0.4.0 API
> ** Add =guix.scm= to the repository
>The file contains GNU Guix package recipe.
> 2: https://github.com/artyom-poptsov/guile-smc

Very cool! Thank you!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: [ANN] Guile-SMC 0.4.0 released

2022-03-11 Thread Dr. Arne Babenhauserheide

"Artyom V. Poptsov"  writes:

> A transition table can be verified and checked for dead-ends and
> infinite loops.  Also Guile-SMC FSMs gather statistics when they run.
…
> ** Add =guile-standalone= compilation target
>This compilation target produces GNU Guile FSM code in a single file that
>does not dependent on Guile-SMC.
>
>All required Guile-SMC procedures will be copied to the output stream, and
>the extra procedures that are not used in the output code are removed by
>pruning.

Wow, that’s pretty cool! Thank you!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Guile optimizations slowing down the program?

2022-03-09 Thread Dr. Arne Babenhauserheide

Jean Abou Samra  writes:

>>> There is also a felicitous feedback effect in that because the
>>> baseline compiler is much smaller than the CPS compiler, it takes less
>>> time to macro-expand — 
>>> https://wingolog.org/archives/2020/06/03/a-baseline-compiler-for-guile
>
> As far as I understand, this is about the speed of compilation. For
> the reason explained above, it doesn't factor into the speed of
> LilyPond.

The speed of compilation is only part of it. The blog post also shows
that the optimizations gain factor 4 in speed for the compiled code, but
if there are lots of macros to expand in the *.ly files, unoptimized
code (which is smaller, because it is higher-level) might actually be
faster.

This as all highly speculative on my side, though …

> Thanks for responding!

In my opinion Lilypond is one of the most important Guile-Programs.
Since I started running Guix as Distro, Lilypond is no longer *the* most
important Guile program for me (since without Guix my system would
simply not run), but Lilypond is still the one tool I really need.

All the other Guile-using utilities I have are nice to have conveniences
(or code I wrote myself). Lilypond is the only mission-critical tool for
which I would not be able to find a replacement, because I require it to
improve my songbook. There’s just nothing like it.

Thank you very much for working on Lilypond!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Guile optimizations slowing down the program?

2022-03-09 Thread Dr. Arne Babenhauserheide

Maxime Devos  writes:
> Jean Abou Samra schreef op wo 09-03-2022 om 00:31 [+0100]:
>> In summary, the less Guile optimizes, the faster LilyPond runs. Is that
>> something expected?
>
> I don't think so, but I don't have a clue how this happens ...

Do I understand it correctly that Lilypond has lots of snippets that are
executed exactly once? In that case it could be expected that the
overhead of optimization dominates — maybe even the overhead of
increased code-size from inlining?

Also the new baseline compiler is already pretty good:
https://wingolog.org/archives/2020/06/03/a-baseline-compiler-for-guile

Maybe this?

> There is also a felicitous feedback effect in that because the
> baseline compiler is much smaller than the CPS compiler, it takes less
> time to macro-expand — 
> https://wingolog.org/archives/2020/06/03/a-baseline-compiler-for-guile

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Fibers 1.1.0 released

2022-02-01 Thread Dr. Arne Babenhauserheide

Aleix Conchillo Flaqué  writes:

> On behalf of the Fibers team, I am very excited to announce Fibers 1.1.0.
…
>   https://github.com/wingo/fibers/wiki/Manual

That’s awesome! Thank you!

> - Added benchmarks.

Do you know the skynet benchmark?
https://github.com/atemerev/skynet/tree/master/guile-fibers

It would be interesting to know how 1.1.0 changes the skynet results :-)

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: GuileScript 0.0.0 released

2022-01-18 Thread Dr. Arne Babenhauserheide

Aleix Conchillo Flaqué  writes:

> I'm excited to announce GuileScript 0.0.0. GuileScript aims to be a Guile
> to JavaScript compiler. It currently doesn't do much but there are some
> working examples like fibonacci, binary search and reversing a vector.
…
> https://github.com/aconchillo/guilescript
>
> Comments, suggestions, patches and full rewrites are welcomed. :-)

That’s really cool! 

I currently use biwascheme¹ for simple tools,² and it would be great to
be able to move from it to Guile, because biwascheme breaks Scheme’s
scoping.

It might be pretty hard to really get this right, though. There’s some
existing work for the compile with the full runtime:
https://lists.gnu.org/archive/html/guile-devel/2021-10/msg00018.html

¹: https://www.biwascheme.org/
²: https://www.draketo.de/software/vorlesung-netztechnik#nummer-zu-sprache

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Scheme+

2021-12-20 Thread Dr. Arne Babenhauserheide

Damien Mattei  writes:

> I finished today the first version of Scheme+.
> Scheme+ is an extension of the syntax of the Scheme language.
> Scheme+ makes it easy the assignment of Scheme objects in infix (works also
> in prefix) notation with a few new operators  ← (or  <-), [ ],⥆ (or <+) .
>
> https://damien-mattei.github.io/Scheme-PLUS-for-Guile/Scheme+io.html

Does this build on SRFI-105?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Can guile be implementation independent?

2021-12-18 Thread Dr. Arne Babenhauserheide

Tim Van den Langenbergh  writes:
> 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.
>
> Well, Guile is also missing digit-value, which is easily mocked-up by using 
> char->integer and subtracting 48 from it.

Are there any more missing parts?

I think for those that are easy to mock, we just should fix the 
incompatibilities.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Can guile be implementation independent?

2021-12-17 Thread Dr. Arne Babenhauserheide
>>> On Fri, Dec 17, 2021, 09:43 Jacob Hrbek  wrote:
>>>Is there a way to do the same on GNU Guile? Like writing a code
>>>that can
>>>be interpreted by implementations that are following the IEEE
>>>1178-2008
>>>or R7RS standard?
>> On 12/17/21 03:53, Nala Ginrut wrote:
>>> Hi Jacob!
>>> You may take a look at akku.scm
>>> You can write r7rs code and use Guile as one of the compiler alternatives.
>> On 17 Dec 2021, at 03:01, Jacob Hrbek  wrote:
>> Looks interesting, are there any known limitations in relation to Guile?
silas poulson  writes:
> Uncertain if anymore but Guile provides list of r7rs incompatiblities
> here
> 

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
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: [ANN] Guile-DSV 0.5.0 released

2021-12-12 Thread Dr. Arne Babenhauserheide

poptsov.art...@gmail.com (Artyom V. Poptsov) writes:

> Also there are important API changes in 'dsv' options: '--table-borders'
> parameter names are changed to be more concise.  And now there's
> '--with-header' option that instructs 'dsv' to use the first row of
> input data as the table header.
>
> Also I added "org" table preset as suggested by Arne Babenhauserheide --
> now 'dsv' can produce a tables compatible with org-mode format.

Ooh — very cool! Thank you! Once it’s in Guix, I’ll have to test it
right away!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: [ANN] Guile-DSV 0.4.1 released

2021-12-11 Thread Dr. Arne Babenhauserheide

poptsov.art...@gmail.com (Artyom V. Poptsov) writes:

> I'm pleased to announce Guile-DSV 0.4.1:
>   https://github.com/artyom-poptsov/guile-dsv/releases/tag/v0.4.1

Wow, congrats!

> The main changes in this release are related to the 'dsv' tool: now it
> allows to print the DSV data as fancy tables using extended table
> parameters and table presets.  See the full list of user-visible changes
> below.
>
> Examples:
>
> $ echo -e "a1,b1,c1\na2,b2,c2\n" | dsv -D, -b "ascii"
> .-.
> | a1  | b1  | c1  |
> |-+-+-|
> | a2  | b2  | c2  |
> '-'

Does the ascii-version cope mith headers?

Would it be possible to add org-mode output?

Wisful thinking:

$ echo -e "ah,bh,ch\na1,b1,c1\na2,b2,c2\n" | dsv -D, --with-header -b "org"
| ah  | bh  | ch  |
|-+-+-|
| a1  | b1  | c1  |
| a2  | b2  | c2  |

With this I could easily convert a CSV to org-mode and then add
#+TBLFM: @2$1..@>$>='(arbitrary-lisp-code @# $# $0)
for complex evaluation of the data.

See https://orgmode.org/manual/Field-and-range-formulas.html
and https://orgmode.org/manual/Formula-syntax-for-Calc.html
and https://orgmode.org/manual/Formula-syntax-for-Lisp.html

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Thanks all!

2021-10-24 Thread Dr. Arne Babenhauserheide

paul  writes:

> I have just made a release of my app [1] which integrates a Guile
> runtime -- since i received invaluable pointers from this mailing 
> list, i thought folks might be curious as to what i was building.
…
> 1. Spotiqueue on Github, https://github.com/toothbrush/Spotiqueue

Very cool! Congratulations!

> Scratches my itch, no other guarantees granted

Great definition of purpose! (thumbs up!)

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Summer of Code Recap

2021-10-10 Thread Dr. Arne Babenhauserheide

Christine Lemmer-Webber  writes:

> I have pushed one more merge with master to the compile-to-js-merge
> branch.  I've taken the bold move of pushing this to origin... I think
> it's a good idea to try to get this in, so it's worth it not just
> sitting in my own personal repo.

wow — thank you!

Is there a short example on how to use this branch for the features that
already work?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Chickadee 0.8.0 released

2021-10-08 Thread Dr. Arne Babenhauserheide

"Thompson, David"  writes:

> I'm happy to announce that Chickadee 0.8.0 has been released!

Hell yeah! Thank you!

And thank you for the link to https://itch.io/jam/autumn-lisp-game-jam-2021

Something fun I collected for a chickadee-based game:
https://opengameart.org/content/art-for-drachi


Most technically interesting part of the game itself:


define-module : drachi drachi
  . #:export : drachi
  . #:declarative? #f

define drachi-sprite #f
define drachi-atlas #f
define drachi-batch #f
define repl #f
define provide-repl #f

define : load
set! drachi-sprite : load-image "walking_dragon-red.png"
set! drachi-atlas : split-texture drachi-sprite 144 128
set! drachi-batch : make-sprite-batch drachi-sprite
when provide-repl
  set! repl : spawn-coop-repl-server

;; …

define : update dt
  when provide-repl
  poll-coop-repl-server repl
  update-drachi dt

define : drachi args
  when : member "--repl" args
 set! provide-repl #t
  run-game #:update update #:load load #:draw draw


And then:

guix environment -l guix.scm -- ./run-drachi.w  --repl &
telnet localhost 37146
,m drachi drachi

And then:

define : draw-drachi
  sprite-batch-clear! drachi-batch
  sprite-batch-add! drachi-batch
  vec2 256.0 17.0 ;; replace 176.0 by 17.0
  . #:texture-region : texture-atlas-ref drachi-atlas (+ 6 drachi-index)
  draw-sprite-batch drachi-batch

and Drachi moved downwards.


Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Demanding Interoperability to Strengthen the Free (Libre) Web: Introducing DISFLUID

2021-07-31 Thread Dr. Arne Babenhauserheide

Vivien Kraus via General Guile related discussions  writes:

> It is not tied to a particular framework, the specification is based on
> HTTP. Guile has by default almost everything we need, 
> https://www.gnu.org/software/guile/manual/guile.html#Web
>
> The missing parts are a couple of HTTP headers that are simple to
> handle.

Maybe some hacks I needed for my (unfinished) implementation of the
downloadmesh can be useful to you:

https://hg.sr.ht/~arnebab/wispserve/browse/wispserve/serve.w

custom headers:
https://hg.sr.ht/~arnebab/wispserve/browse/wispserve/serve.w?rev=ab4c95b7a9ff#L115

handle multi-part uploads:
https://hg.sr.ht/~arnebab/wispserve/browse/wispserve/serve.w?rev=ab4c95b7a9ff#L627

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: re-writing algorithms in Guile

2021-06-29 Thread Dr. Arne Babenhauserheide

Tim Meehan  writes:

> Say for instance, I have found an algorithm for scalar function
> minimization on a website, written in C. It is posted with a license for
> use.

What do you mean by „license for use“? Does it restrict what you want to
do?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: re-writing algorithms in Guile

2021-06-29 Thread Dr. Arne Babenhauserheide

> Your program in Guile Scheme which realizes an algorithm is not a
> derivative work of the program you read, which program is written in
> C.  Even in the case that your program realizes the same algorithm as
> the C program does.  The above official article of the US Copyright
> Office clearly states this.

That is only true, if you do not re-use any structure of the original
program that is not part of the algorithm.

If you want to be sure, you need a cleanroom re-implementation: Have
someone else read the code and write down the pure algorithm. Then
implement that without ever having seen the original code.
https://en.wikipedia.org/wiki/Clean_room_design

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: [ANN] Guile-SMC 0.2.0

2021-06-06 Thread Dr. Arne Babenhauserheide

Artyom V. Poptsov  writes:

> Oh, I forgot to attach the NEWS part.  So here it goes, the "List of
> User-Visible Changes":

very cool! Thank you!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: define anywhere

2021-06-06 Thread Dr. Arne Babenhauserheide

Linus Björnstam  writes:

> Andy did a marvellous thing
…
> So TL/DR: guiles way is the correct way. 

Thank you for the clarification!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: define anywhere

2021-06-06 Thread Dr. Arne Babenhauserheide

Linus Björnstam  writes:

> becomes ONE letrec under gulie3, whereas my library turns it into
> (letrec ((a 2) (b 3))
>   (display "hej")
>   (letrec ((c 3))
> (+ a b c)))
>
> That should be an easy fix, again if there is any interest.

I’m not sure which approach I prefer. Your approach is more precise, but
I slightly lean towards the Guile3-version, because it does not change
behaviour when I put a pretty-print between two defines.

Though I would want a precise approach inside other forms (like when:
separating inside when and outside when).

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: define anywhere

2021-06-05 Thread Dr. Arne Babenhauserheide

Taylan Kammer  writes:

> On 05.06.2021 00:27, Damien Mattei wrote:
>> hello,
>> i'm was considering that i want to be able to define a variable anywhere in
>> code, the way Python do. Few scheme can do that (Bigloo i know)
>> ( the list here is not exact:
>> https://www.reddit.com/r/scheme/comments/b73fdz/placement_of_define_inside_lambda_bodies_in/
>> )
>>  is it possible in guile to do it? i do not know, so could it be added to
>> the language specification for future release?
>> 
>> regards,
>> Damien
>> 
>
> It's possible since 3.0, see here:
>
> https://www.gnu.org/software/guile/manual/html_node/Internal-Definitions.html#Internal-Definitions

It is currently possible almost anywhere:

Works:

(define (a) (when #f #t) (define a 'b) a)

Does not work:

(define (a) (when #t (define a 'b) a))

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Summer of Code Recap

2021-05-11 Thread Dr. Arne Babenhauserheide

Christopher Lemmer Webber  writes:

> Anyway, is there support from the maintainers from getting this merged
> if I can get things working again?  I'd really like to see this effort
> not go to waste... I'd even like to write a few demos using it.

I’m no maintainer, but I would love having the js backend merged! I
tried biwascheme to write Scheme on the web[1] but found it lacking (it
combines the gotchas from javascript (no hygiene) with the gotchas from
transpiling), and I would love to have a canonical source of Guile-code
for Javascript-tools on my website and for small games.

Best wishes,
Arne

[1]: This pseudo-random language-assignment generator is written in biwascheme:
 https://www.draketo.de/software/vorlesung-netztechnik#nummer-zu-sprache
 https://www.draketo.de/software/matrikellanguage.scm
 
   (load "matrikellanguage.scm")
   (let loop ()
   (wait-for "#matrikelnummer" "input")
   (set-content! "#result" (matrikel->pair (get-content 
"#matrikelnummer")))
   (console-log "ok.")
   (loop))
 
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Announcement: goof-loop 0.1

2021-05-11 Thread Dr. Arne Babenhauserheide

Linus Björnstam  writes:

> I am rather pleased to announce the first beta release of goof-loop, an 
> extensible, powerful and fast looping facility for (guile) scheme. It is 
> based on (chibi loop), but adds quite a bit of nice things - most notably 
> subloops and a higher order loop protocol based on srfi-158-styled 
> generators. 
>
> The repo can be found here: https://git.sr.ht/~bjoli/goof-loop
> Hosted documentation: https://bjoli.srht.site/doc.html
…
> Pattern matching, here extracting all keys in an alist
> (loop/list (((key . val) (in-list '((a . 0) (b . 1) (c .2)
>   key)
>
> Higher order loop protocol (for the :for clause scheme-value)
> (loop/list ((key (in-list '(true false sant falskt wahr falsch vrai faux)))
> (scheme-value (in-cycle (in-list '(#t #f)
>   (cons key scheme-value))
>
> The loop expansion is usually as fast as a named let.

Very cool!

Congrats for the release — and thank you very much for sharing!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: How to use guile in a development process

2021-04-29 Thread Dr. Arne Babenhauserheide
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 "") 'test-this-file))

Best wishes,
Arne

Nala Ginrut  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  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


signature.asc
Description: PGP signature


Re: Python-on-guile

2021-04-25 Thread Dr. Arne Babenhauserheide

Stefan Israelsson Tampe  writes:

> (define-syntax-rule (letec f)
>   (let/ec x (f x
>
> Actually lead to similar speeds as python3.

Please keep in mind that this is math. There are parts of Python that
are heavily optimized, for example reading strings from disk. Guile will
likely have a hard time to compete with that.

But for math Guile is quite a bit faster than Python :-)

(next frontier: compete with math that’s implemented via numpy — you
can find RPython implementations of the basics of numpy in the
pypy-sources:
https://foss.heptapod.net/pypy/pypy/-/tree/branch/default/pypy/module/micronumpy
)

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Python on guile v1.2.3.7

2021-04-17 Thread Dr. Arne Babenhauserheide

Stefan Israelsson Tampe  writes:

> I have continued to debug python for guile 3.1 and I am now getting much
> less warnings and also I can run test cases and it looks good. Tip, To run
> unit tests one can do from the module directory in the dist
>
> python language/python/module/unittest/tests/test_case.py
>
> to see what's working and what's not working.
>
> I am also working on getting it to behave better and especially take
> advantage
> of guile's new reader to introduce python source code numbering instead of

Thank you for your work! It’s pretty awesome to see Python on Guile!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Python on guile v1.2.3.7

2021-04-11 Thread Dr. Arne Babenhauserheide

Maxim Cournoyer  writes:

> Hi Stefan,
>> This release includes
>> * pythons new match statement
>> * dataclasses
>> * Faster python regexps through caching and improved datastructures
>> * Numerous bug fixes found while executing the python unit tests.

That’s really cool! Thank you!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


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

2021-04-05 Thread Dr. Arne Babenhauserheide
Hi Linus,

thank you for your tipps!

Linus Björnstam writes:

> Can you use the procedural part of syntax-rules? You have the power of 
> using scheme at expansion time, which means you could do list-ref all 
> you want.
> 
> That "syntax-rules" is of course syntax-case.
> 
> The only thing is that guile lacks syntax->list, so sometimes you have 
> to manually turn it into a list. Say you are matching ((_ stuff ...) 
> Body) stuff is a syntax object. You could turn it into a list of syntax 
> objects by doing  #'(stuff ...). Then you can treat it as a regular 
> list, and use quasisyntax to put it back into your output syntax. 
…
> Try writing it first with unhygienic macros and get that working
> before porting to syntax-case if you don't know the ins-and-outs of
> syntax-case.

I have not yet written an unhygienic macro in Guile.

Do I use the internal macros for that?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


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

2021-04-05 Thread Dr. Arne Babenhauserheide
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
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: rfc: next guile 1.8.x release

2021-03-08 Thread Dr. Arne Babenhauserheide

Andy Wingo  writes:

> power to them; perhaps there is room for an unofficial Guile development
> branch.  Just that again -- and I really hate to be negative here -- I

How about taking this at literal value and creating an ugg8-repository:
Unofficial GNU Guile 1.8? That carries with it the connotations of
keeping to plain, strong values without fundamental changes, and picking
up from the 8, so it isn’t limited to the minor number behind 1.8.x
(with x > 8).

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Guile Potluck 2021

2021-03-01 Thread Dr. Arne Babenhauserheide
.10  0.07  0.07  length
  0.03  0.02  0.02  %after-gc-thunk
  0.03  0.02  0.02  wispwot/wispwot.scm:236:10:discard
  0.00 62.77  0.00  wispwot/wispwot.scm:375:0:import-trust-value
  0.00  7.82  0.00  remove
  0.00  0.02  0.00  anon #x7a24b0
---
Sample count: 3820
Total time: 62.773351245 seconds (2.013414284 seconds in GC)


(I see here that the GC time during actual trust calculation is much
lower than I had expected)


I hope they help! (you’ll have to pull again — with `hg pull -u` — to
get import-trust-csv exported)

Best wishes,
Arne


Dr. Arne Babenhauserheide  writes:

> PS: Still it is important to get this code fast, because it is the
> fallback for all situations where I cannot cheat and only calculate
> a subset of the trust, and it is required at startup.
>
> Dr. Arne Babenhauserheide  writes:
>
>> Hi Linus,
>>
>> Linus Björnstam  writes:
>>> I had a look and there is quite a lot you can do. Just out of
>>> curiosity: how much is GC time? You are generating a lot of
>>> intermediate data. Instead of vector-append! maybe use something like
>>> the new vectorlist srfi? If you show me a flame graph and give me some
>>> test data I can have a go!
>>
>> Thank you!
>>
>> I expect GC time to be roughly half during the trust calculation (much
>> more during import), because this fills up two cores.
>>
>> I can’t easily give you a flame graph (except if you can tell me how to
>> generate it), but I now pushed a version in pure Scheme (instead of
>> wisp) that runs a huge test:
>>
>> hg clone https://hg.sr.ht/~arnebab/wispwot
>> cd wispwot
>> ./run-wispwot.scm --test
>>
>> This imports 200k trust edges (which takes a lot of time) and then does
>> three full trust calculations (which each take around 70s).
>>
>> The most important limitation for optimization is that the memory use
>> must stay reasonable with 64k IDs which each have 1000 trust edges. This
>> memory use is what the current code is optimized for (that’s why there
>> are all those u8vectors and u16vectors).
>>
>> For the math: at 64 million trust edges, this should currently require
>> (in theory) less than 200MiB of memory for the actual trust structure (2
>> byte for the id, 1 byte for the trust).
>>
>> Going up to 300MiB for time-optimization would still be viable, but it
>> shouldn’t go beyond that (there are algorithmic options to reduce the
>> amount of work done per update, so the runtime of the current code is
>> important but it is not a life-and-death situation).
>>
>> Best wishes,
>> Arne


-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Guile Potluck 2021

2021-03-01 Thread Dr. Arne Babenhauserheide
Hi Guilers,

There’s one more thing for the Potluck:

I started doing some code-catas in Guile wisp:
https://www.draketo.de/software/wisp-code-katas

Liebe Grüße,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Guile Potluck 2021

2021-02-27 Thread Dr. Arne Babenhauserheide
PS: Still it is important to get this code fast, because it is the
fallback for all situations where I cannot cheat and only calculate
a subset of the trust, and it is required at startup.

Dr. Arne Babenhauserheide  writes:

> Hi Linus,
>
> Linus Björnstam  writes:
>> I had a look and there is quite a lot you can do. Just out of
>> curiosity: how much is GC time? You are generating a lot of
>> intermediate data. Instead of vector-append! maybe use something like
>> the new vectorlist srfi? If you show me a flame graph and give me some
>> test data I can have a go!
>
> Thank you!
>
> I expect GC time to be roughly half during the trust calculation (much
> more during import), because this fills up two cores.
>
> I can’t easily give you a flame graph (except if you can tell me how to
> generate it), but I now pushed a version in pure Scheme (instead of
> wisp) that runs a huge test:
>
> hg clone https://hg.sr.ht/~arnebab/wispwot
> cd wispwot
> ./run-wispwot.scm --test
>
> This imports 200k trust edges (which takes a lot of time) and then does
> three full trust calculations (which each take around 70s).
>
> The most important limitation for optimization is that the memory use
> must stay reasonable with 64k IDs which each have 1000 trust edges. This
> memory use is what the current code is optimized for (that’s why there
> are all those u8vectors and u16vectors).
>
> For the math: at 64 million trust edges, this should currently require
> (in theory) less than 200MiB of memory for the actual trust structure (2
> byte for the id, 1 byte for the trust).
>
> Going up to 300MiB for time-optimization would still be viable, but it
> shouldn’t go beyond that (there are algorithmic options to reduce the
> amount of work done per update, so the runtime of the current code is
> important but it is not a life-and-death situation).
>
> Best wishes,
> Arne


-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Guile Potluck 2021

2021-02-27 Thread Dr. Arne Babenhauserheide
Hi Linus,

Linus Björnstam  writes:
> I had a look and there is quite a lot you can do. Just out of
> curiosity: how much is GC time? You are generating a lot of
> intermediate data. Instead of vector-append! maybe use something like
> the new vectorlist srfi? If you show me a flame graph and give me some
> test data I can have a go!

Thank you!

I expect GC time to be roughly half during the trust calculation (much
more during import), because this fills up two cores.

I can’t easily give you a flame graph (except if you can tell me how to
generate it), but I now pushed a version in pure Scheme (instead of
wisp) that runs a huge test:

hg clone https://hg.sr.ht/~arnebab/wispwot
cd wispwot
./run-wispwot.scm --test

This imports 200k trust edges (which takes a lot of time) and then does
three full trust calculations (which each take around 70s).

The most important limitation for optimization is that the memory use
must stay reasonable with 64k IDs which each have 1000 trust edges. This
memory use is what the current code is optimized for (that’s why there
are all those u8vectors and u16vectors).

For the math: at 64 million trust edges, this should currently require
(in theory) less than 200MiB of memory for the actual trust structure (2
byte for the id, 1 byte for the trust).

Going up to 300MiB for time-optimization would still be viable, but it
shouldn’t go beyond that (there are algorithmic options to reduce the
amount of work done per update, so the runtime of the current code is
important but it is not a life-and-death situation).

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Guile Potluck 2021

2021-02-27 Thread Dr. Arne Babenhauserheide
I’d like to contribute a basic implementation of the Web of Trust in
Freenet that provides spam-detection without centralized control:

https://hg.sr.ht/~arnebab/wispwot/browse/wispwot/wispwot.scm

Currently this takes 70s to calculate aggregated trust scores on 300k
trust edges.

I hope to get this faster and would love if someone would want to try
to golf its runtime down :-)

Best wishes,
Arne

Mike Gran  writes:

> On Fri, 2021-02-26 at 15:19 -0800, Aleix Conchillo Flaqué wrote:
>> In case it was not clear:
>> 
>> guile-oauth 1.0.0 with OAuth2 support: 
>> https://github.com/aconchillo/guile-oauth
>> guile-redis 2.1.0 with Redis 6.2.0 commands:
>> https://github.com/aconchillo/guile-redis
>> 
>> Aleix
>> 
>
> Awesome. Thanks! Look forward to checking it out.
>
>> On Sun, Feb 21, 2021 at 9:59 PM Aleix Conchillo Flaqué
>>  wrote:
>> > 
>> > Thank you Mike!
>> > 
>> > I should have waited to release guile-oauth with the OAuth2 support
>> > :-). But if that counts...
>> > 
>> > Also planning to release guile-redis with redis 6.2 support when
>> > they make a release (they are in RC3), but I might do it sooner.
>> > 
>> > Best,
>> > 
>> > Aleix
>> > 
>> > On Thu, Feb 18, 2021, 9:43 AM Mike Gran  wrote:
>> > > 
>> > > Hello All-
>> > > 
>> > > In celebration of the (slightly belated) 10-year anniversary of
>> > > Guile
>> > > v2.0, we're having another Guile Potluck!  The Guile Potluck is a
>> > > randomly annual event to give people a chance to show off their
>> > > Guile
>> > > projects and skills.  Think of it as a game jam, but, not
>> > > constrained
>> > > to games.
>> > > 
>> > > To participate, on or before Mar 6, send an email to 
>> > > guile-user@gnu.org
>> > > with instructions on how to find your entry, which could be
>> > > anything
>> > > you like.  For example,
>> > > 
>> > >- a script showing off some feature of Guile or your favorite
>> > > Guile
>> > >library
>> > >- a blog post describing something interesting about Guile
>> > >- an updated release of a neglected library
>> > >- a mini-game
>> > >- a graphical or audio demoscene-type demo
>> > > 
>> > > There probably won't be any prizes.  But there will definitely be
>> > > an e-
>> > > mail and blog post about the entries.
>> > > 
>> > > If you think you might attempt to participate, please reply to
>> > > this e-
>> > > mail so I can gauge the feasibility of some sort of participation
>> > > swag.
>> > > 
>> > > Regards,
>> > > Mike Gran, on behalf of the Guile team
>> > > 
>> > > 
>> > > 


-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Guile Potluck 2021

2021-02-21 Thread Dr. Arne Babenhauserheide

Alex Sassmannshausen  writes:

> I would love to participate by cheating a little and submitting a new
> release of Guile Hall, which is overdue and should happen between 1 and
> 6 March.

\o/

thank you!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Guile Hacker Handbook - Character sets

2021-02-19 Thread Dr. Arne Babenhauserheide

Jérémy Korwin-Zmijowski  writes:

> Le jeudi 18 février 2021 à 22:56 +0100, Zelphir Kaltstahl a écrit :
>> I am looking forward to seeing a new chapter of your handbook,
>> especially, if there is more stuff that explains macros and how to
>> get
>> something useful done with macros. : )
>
> Thank you for your support. 
> Macros are a wide topic, I will start with a syntax-rule to make use of
> srfi-64 more attractive to me ! ;)

You could look into my doctest module:

https://hg.sr.ht/~arnebab/wisp/browse/examples/doctests.scm?rev=tip

this currently does not use a macro but eval, because it uses procedure
properties to store the tests, but it could definitely benefit from
limiting the impact of eval with a macro:
https://hg.sr.ht/~arnebab/wisp/browse/examples/doctests.scm?rev=7ccdb6b2fd94#L123

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Guile Hacker Handbook - Character sets

2021-02-18 Thread Dr. Arne Babenhauserheide
Hi Jérémy,

Thank you for your book!

How you’re describing char-sets using a clear use-case looks really
good!

A few comments:

# Try and run the test

here you write “the test fails”, which is slightly unprecise. The
precise wording would be “the test will fail to run”.

# Write the minimal …

I wonder why the test-suite returns "passes 1" in the second try (with
undefined password-valid?).

Jérémy Korwin-Zmijowski  writes:

> The next chapter will probably introduce macros (syntax-rules) !

If you want to see the extend to which you can play with macros, you can
have a look at my natural-script-writing entry-point (from enter-three-witches):
https://hg.sr.ht/~arnebab/dryads-wake/browse/enter.w?rev=tip#L349

Thank you for your book!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Guix records

2021-02-10 Thread Dr. Arne Babenhauserheide

Taylan Kammer  writes:

>>>(import (rnrs records syntactic (6)))
>>>(define-record-type (cat make-cat cat?) (fields name age color))
>> I did not know about that shorthand — thank you!
>> I always did this:
>> (import (srfi srfi-9))
>> (define-record-type 
>>(make-cat name age color)
>>cat?
>>(name cat-name) (age cat-age) (color cat-color))
>> Compared to that the syntactic form you showed is much nicer.
>
> I actually prefer the conceptual simplicity and explicit nature of
> SRFI-9 to be honest, but yeah, it can be very verbose.

I’ve used records a bit, and the additional overhead is annoying.
On the other hand I like it that there is an explicit entry in the file,
so I don’t get magic variables that my text editor cannot find without
executing the code.

> According to the 3.0 release notes, R6RS and SRFI-9 now both use a
> unified core record system under the hood and should therefore have 
> equivalent performance characteristics I suppose.

Thank you!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Guix records

2021-02-09 Thread Dr. Arne Babenhauserheide

Taylan Kammer  writes:
> The most feature-rich record system supported by Guile is probably the
> R6RS record system, which is available through the modules:
>
>   (rnrs records syntactic (6))
>   (rnrs records procedural (6))
>   (rnrs records inspection (6))
> Here's a super brief example usage of R6RS records, demonstrating that
> field accessors are defined implicitly, but constructors still use an 
> unnamed sequence of arguments to assign fields:
>
>   (import (rnrs records syntactic (6)))  ; must use 'import' for R6RS
>
>   (define-record-type (cat make-cat cat?) (fields name age color))
>
>   (define garfield (make-cat "Garfield" 42 'orange))
>
>   (cat-color garfield)  ;=>  orange

I did not know about that shorthand — thank you!

I always did this:

(import (srfi srfi-9)) ; define-record-type
(define-record-type 
  (make-cat name age color)
  cat?
  (name cat-name) (age cat-age) (color cat-color))

Compared to that the syntactic form you showed is much nicer.

Is there a difference in efficiency or such?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: build system for pure Guile library (was Re: Help making a GNU Guix package for pure GNU Guile library)

2021-01-31 Thread Dr. Arne Babenhauserheide

Zelphir Kaltstahl  writes:
> This may be short sighted or uninformed, but generally I don't know, why
> I would build anything, except for running it. If I am not confused

Here are three reasons for building of a pure-guile ication:

- avoid the initial start time due to auto-compilation
- set specific optimization parameters (i.e. O3)
- bake-in system-specific data-paths (i.e. images to load)

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


  1   2   3   4   >