Threading / Pipe Macro

2019-07-07 Thread Zelphir Kaltstahl
Hi Guile Users!

I recently looked at some online course about Elixir and saw an elegant
use of pipes (the operator `|>` in Elixir). Then I remembered, that in
Racket there are so called threading macros, which seem to accomplish
the same:

https://github.com/lexi-lambda/threading/blob/master/threading-lib/threading/main.rkt

I also searched around for tutorials or explanations on how to write
these macros. Sometimes I found excellent documenation in the Chicken
Scheme wiki, so I checked there:

https://wiki.call-cc.org/eggref/5/pipes

However, I would like to use a threading macro or pipes in Guile. I am
seeing these options:

(1) I could start trying to translate the Racket version to Guile, maybe
it would work easily, maybe it uses Racket specific macro stuff, I don't
know. However, I am not sure I would learn how the macros actually work.
Maybe I would.

(2) I could start from zero and try to implement the pipes I saw in the
online course about Elixir.

(3) Maybe something already exists in Guile, that I am unaware of and
could not find through searching. Maybe there are even more names for pipes.

So my questions are:

(1) Does something already exist?

(2) Would translating the Racket version be an easy thing to do, or is
there something in there, that cannot so easily be achieved with
syntax-parse, syntax-case and the likes? (For someone who rarely touches
macros and does not have a lot experience writing them.)

Regards,

Zelphir




Re: Threading / Pipe Macro (Chris Vine, Mark H Weaver)

2019-07-08 Thread Zelphir Kaltstahl
Hello Chris and hello Mark,

Thank you both for posting your macros! This is really useful and I am
looking forward to using this in the next situation where there would be
deep nesting or where it seems appropriate in other ways.

To understand what is going on in the macro, I wrote a lot of explaining
comments and uploaded it in a new repository, where I intend to keep
macros I come across and explain them, if I can:

https://gitlab.com/ZelphirKaltstahl/guile-scheme-macros/blob/master/threading-pipe-macro/macro.scm

If there are mistakes in my explanations, it would be great if you could
point out the mistakes : ) I also think it should be easily doable for
me to change for example where the piped argument is inserted in the
list of arguments. Instead of `append` I could probably put the list
built by recurring in between the `func` and `args` to insert in the
first position.

Not sure what kind of license I should put on it (?) Usually I put
everything under GPL, but I am not sure how it is when the code is
actually from someone else.

Thanks!

Zelphir


On 7/8/19 12:26 AM, guile-user-requ...@gnu.org wrote:
> Message: 4
> Date: Sun, 7 Jul 2019 21:16:13 +0100
> From: Chris Vine 
> To: Mark H Weaver 
> Cc: guile-user@gnu.org
> Subject: Re: Threading / Pipe Macro
> Message-ID: <20190707211613.4a8a637da93e592b4f737...@gmail.com>
> Content-Type: text/plain; charset=US-ASCII
>
> On Sun, 07 Jul 2019 15:30:36 -0400
> Mark H Weaver  wrote:
>> Hi Chris,
>>
>> Chris Vine  writes:
>>
>>> I have a pipeline macro which sort-of mimics ML's |> pipeline operator
>>> which I use a lot:
>>>
>>> (define-syntax ->
>>>   (lambda (x)
>>> (syntax-case x ()
>>>   [(k exp0 . exps)
>>>(let* ([reversed (reverse (cons (syntax->datum #'exp0)
>>>(syntax->datum #'exps)))]
>>>   [out (let loop ([first (car reversed)]
>>>   [rest (cdr reversed)])
>>>  (if (null? rest)
>>>  first
>>>  (let ([func (car first)]
>>>[args (cdr first)])
>>>(append `(,func ,@args)
>>>(list (loop (car rest) (cdrrest)))])
>>>  (datum->syntax #'k out))])))
>>>
>>> Because all the macro does is to rearrange input forms, this is hygienic
>>> without the need to manipulate syntax objects - you can convert to a datum,
>>> rearrange and then convert back to a syntax object again, as above.
>> This macro is *not* hygienic.  The calls to 'syntax->datum' strip all of
>> the context information from the syntax objects, and then build a new
>> expression using raw S-expressions.  The result is essentially the same
>> as if you used 'define-macro'.  This results various problems.
>>
>> For example:
>>
>> --8<---cut here---start->8---
>> scheme@(guile-user)> (define-syntax ->
>>   (lambda (x)
>> (syntax-case x ()
>>   [(k exp0 . exps)
>>(let* ([reversed (reverse (cons (syntax->datum #'exp0)
>>(syntax->datum #'exps)))]
>>   [out (let loop ([first (car reversed)]
>>   [rest (cdr reversed)])
>>  (if (null? rest)
>>  first
>>  (let ([func (car first)]
>>[args (cdr first)])
>>(append `(,func ,@args)
>>(list (loop (car rest) (cdr rest)))])
>>  (datum->syntax #'k out))])))
>> scheme@(guile-user)> (define t 'global-t)
>> scheme@(guile-user)> (define-syntax-rule (foo x)
>>(-> x (format #t "[t=~A] ~A\n" t)))
>> scheme@(guile-user)> (let ((t 'inner-t)) (foo t))
>> [t=global-t] global-t
>> $1 = #t
>> scheme@(guile-user)> 
>> --8<---cut here---end--->8---
>>
>> I recommend reformulating the -> macro using 'syntax-rules' as follows:
>>
>> --8<---cut here---start->8---
>> scheme@(guile-user)> (define-syntax ->
>>(syntax-rules ()
>>  ((-> exp)
>>   exp)
>>  ((-> exp ... (op args ...))
>>   (op args ... (-> exp ...)
>> scheme@(guile-user)> (let ((t 'inner-t)) (foo t))
>> [t=global-t] inner-t
>> $8 = #t
>> scheme@(guile-user)> 
>> --8<---cut here---end--->8---
>>
>> This macro is hygienic, and also easier to comprehend (IMO).  Of course,
>> it could also be implemented using syntax-case.  The key is to always
>> work with the syntax objects.
>>
>> Whenever you use 'syntax->datum' on expressions that are not purely
>> literals, you will be sacrificing hygiene.
> How strange.  Both your and my macro gives 'global-t' when I test them,
> which is the result I would expect.  (M

Re: Threading / Pipe Macro

2019-07-08 Thread Zelphir Kaltstahl
Ah thanks! I did not find that before. Good to know where to look for more!

I should link to other places, where one can find macros in my repo.

On 7/8/19 2:49 AM, Erik Edrosa wrote:
> On 7/7/19 6:42 AM, Zelphir Kaltstahl wrote:
>> (1) Does something already exist?
>>
> This project was posted not too long ago on this mailing list.
>
> https://bitbucket.org/bjoli/guile-threading-macros/src/default/
>
> - Erik



Re: Re: Threading / Pipe Macro (Chris Vine, Mark H Weaver)

2019-07-09 Thread Zelphir Kaltstahl
Ah, I must have mixed it up when copying it out of the e-mail. It was
good to understand that macro nevertheless. I'll use the hygienic one
then or the one from Linus repository, because it does something, that I
thought would be very useful to have: A configurable place where to put
the value from the previous step of computation. In fact, I did not
understand at first what `<>` and `<...>` do, and thought maybe I could
try and write one which uses `_` to achieve this effect, but then I read
the examples in the follow-up e-mails and saw, that that macro already
does it. This is great!

On 7/9/19 11:26 AM, guile-user-requ...@gnu.org wrote:
> Date: Tue, 9 Jul 2019 00:00:51 +0100
> From: Chris Vine 
> To: guile-user@gnu.org
> Subject: Re: Threading / Pipe Macro (Chris Vine, Mark H Weaver)
> Message-ID: <2019070951.dfaac3839126b7ec58efd...@gmail.com>
> Content-Type: text/plain; charset=US-ASCII
>
> On Mon, 8 Jul 2019 23:10:28 +0200t
> Zelphir Kaltstahl  wrote:
>> Hello Chris and hello Mark,
>>
>> Thank you both for posting your macros! This is really useful and I am
>> looking forward to using this in the next situation where there would be
>> deep nesting or where it seems appropriate in other ways.
>>
>> To understand what is going on in the macro, I wrote a lot of explaining
>> comments and uploaded it in a new repository, where I intend to keep
>> macros I come across and explain them, if I can:
>>
>> https://gitlab.com/ZelphirKaltstahl/guile-scheme-macros/blob/master/threading-pipe-macro/macro.scm
> You are using the wrong macro, because the one you have chosen has been
> revealed to be unhygienic.  Either use the syntax-rules one (which is
> the simplest) or the revised syntax-case macro.


Re: Write a macro which defines a procedure

2019-07-20 Thread Zelphir Kaltstahl

Hey Ricardo,

Thanks for the advice! I did not remember, that I could use ,expand in 
the Guile REPL.
This was I found out about an issue, but not sure how to solve it. It 
seems like `module-define!` wants to have a symbol as input. But I could 
not figure out how to create a symbol from an identifier.


Here is my updated version of the macro:

88
(use-modules (web uri)
 (web client)
 (json)
 (ice-9 iconv))

(define-syntax variable-name->string
  (lambda (stx)
(syntax-case stx ()
  ((_ id)
   (identifier? #'id)
   (datum->syntax #'id (symbol->string (syntax->datum #'id)))

(define-syntax define-api-route
  (syntax-rules ()
[(define-api-route route http-method my-content-type)
 (module-define! (current-module)
 ;; `route` should be `/container/json` for example.
 #{route}#
 (lambda* (docker-socket #:key (data #f))
   (call-with-values
   (lambda ()
 ;; Here the route needs to be given as a 
string to `http-get`.

 (http-get (variable-name->string route)
   #:port docker-socket
   #:version '(1 . 1)
   #:keep-alive? #f
   ;; Why is my quasiquote not 
working as expected?
   #:headers `((host . ("localhost" 
. #f))
   (content-type . 
(my-content-type (charset . "utf-8"

   #; (list (cons "localhost" #f)
   (cons 'content-type (cons 
my-content-type (cons charset "utf-8"

   #:body (scm->json-string data)
   #:decode-body? #t
   #:streaming? #f))
 (lambda (response response-text)
   (let ([resp-text-as-string 
(bytevector->string response-text "utf-8")])

 (cons response resp-text-as-string))]))
88

And expanding it:

88
,expand(define-api-route
  /container/json
  'GET
  application/x-www-form-urlencoded)
$3 = (module-define!
  (current-module)
  /container/json
  (lambda* (docker-socket #:key (data #f #:data))
(call-with-values
  (lambda ()
(http-get
  "/container/json"
  #:port
  docker-socket
  #:version
  '(1 . 1)
  #:keep-alive?
  #f
  #:headers
  '((host "localhost" . #f)
(content-type
  application/x-www-form-urlencoded
  (charset . "utf-8")))
  #:body
  (scm->json-string data)
  #:decode-body?
  #t
  #:streaming?
  #f))
  (lambda (response response-text)
(let ((resp-text-as-string
(bytevector->string response-text "utf-8")))
  (cons response resp-text-as-string))
88

So using the Guile specific #{}# 
(https://www.gnu.org/software/guile/manual/html_node/Symbol-Read-Syntax.html#Symbol-Read-Syntax) 
did not work as I thought it might.

How can I make a symbol from an identifier? In this case:

/container/json/ -> '/container/json

Are there other things I should improve in this macro?

Regards,
Zelphir


On 2019-07-20 10:46, Ricardo Wurmus wrote:

Hi,


However, when I call this macro as follows:


88
(define-api-route /container/json 'POST
application/x-www-form-urlencoded)
88

I get the following error:

88
;;; :33:0: warning: possibly unbound variable `/container/json'
;;; :33:0: warning: possibly unbound variable
`application/x-www-form-urlencoded'
:33:0: In procedure module-lookup: Unbound variable:
/container/json
88


Here it might help you to see the expansion of the macro.  In the REPL
you can use

,expand (define-api-route /container/json 'POST
application/x-www-form-urlencoded)

to see what Scheme code the thing expands to.


--
Ricardo




Re: Write a macro which defines a procedure

2019-07-20 Thread Zelphir Kaltstahl
Hi,

At first I had the macro use `define`, but then I thought: "What if I
want to conditionally define a route procedure?". My guess is, that then
the define form would be inside some `cond` or `if` form and then it
would not work (I did not check this assumption though, because my macro
did not work yet.). That is why I looked for something that does what
`module-define!` does.

On 7/21/19 3:26 AM, Mark H Weaver wrote:
> Matt Wette  writes:
>
>> On 7/19/19 3:51 PM, zelphirkaltstahl wrote:
>>> (module-define! (current-module)
>>>  ;; `route` should be `/container/json` for example.
>>>  route
>> (quote route)
> Yes, or equivalently:  'route
>
> As an aside, is there a reason to not define it more simply as follows?
>
>  Mark
>
> --8<---cut here---start->8---
> (define-syntax define-api-route
>   (syntax-rules ()
> [(define-api-route route http-method my-content-type)
>  ;; `route` should be `/container/json` for example.
>  (define* (route docker-socket #:key (data #f))
>(call-with-values
>(lambda ()
>  ;; Here the route needs to be given as a string to `http-get`.
>  (http-get (variable-name->string route)
>#:port docker-socket
>#:version '(1 . 1)
>#:keep-alive? #f
>;; Why is my quasiquote not working as expected?
>#:headers `((host . ("localhost" . #f))
>(content-type . (,my-content-type (charset 
> . "utf-8"
>#:body (scm->json-string data)
>#:decode-body? #t
>#:streaming? #f))
>  (lambda (response response-text)
>(let ([resp-text-as-string (bytevector->string response-text 
> "utf-8")])
>  (cons response resp-text-as-string)]))
> --8<---cut here---end--->8---



Re: Write a macro which defines a procedure

2019-07-20 Thread Zelphir Kaltstahl
Ah thanks! Sometimes one does not see the simple solution. I was 
thinking that it would have to be something complicated.


On 2019-07-20 22:37, Ricardo Wurmus wrote:

Hi Zelphir,


This was I found out about an issue, but not sure how to solve it. It
seems like `module-define!` wants to have a symbol as input. But I
could not figure out how to create a symbol from an identifier.

Here is my updated version of the macro:

[…]

(define-syntax define-api-route
  (syntax-rules ()
[(define-api-route route http-method my-content-type)
 (module-define! (current-module)
 ;; `route` should be `/container/json` for 
example.

 #{route}#


Use (quote route) instead.




Re: Write a macro which defines a procedure

2019-07-21 Thread Zelphir Kaltstahl
Hi Mark!

On 7/21/19 4:56 AM, Mark H Weaver wrote:
> Hi Zelphir,
>
> Zelphir Kaltstahl  writes:
>
>> At first I had the macro use `define`, but then I thought: "What if I
>> want to conditionally define a route procedure?". My guess is, that then
>> the define form would be inside some `cond` or `if` form and then it
>> would not work
> You're right, it would not work.  Nonetheless, I would strongly
> discourage you from doing this kind of thing unless there's a very
> compelling reason for it.

To be honest there are not really any compelling reasons and I did think
about such consequences that you mention below, only the thought of not
being able to use the macro conditionally and wanting it to be usable
everywhere and fear of possibly making a mistake later on in my code,
trying to use it somewhere, where it cannot be used. However, now that I
think about it, there might not be a real need inside that project after
all, as the API route are predefined in the docker docs.

> Note that we have 'cond-expand' from SRFI-0 for conditional inclusion of
> definitions, if you need it.  'cond-expand' is roughly analogous to #if
> in C.  It's less general than plain 'if', but there's an important
> reason for that, and it has to do with the distinction between compile
> time and run time.

Aha! I did not know that : )

I will read about the `cond-expand` in the SRFI 0. Thanks for mentioning
SRFI 0. I guess I am still a little uneducated with regard to SRFIs and
what they contain. Zero seems like an important number.

> If you use 'cond-expand', the condition is checked at compile time, and
> consequently it is known at compile time which branch was taken and
> therefore which definitions were chosen.
>
> If you use 'cond', then the condition will be checked at run time, which
> will normally rule out the possibility of optimization opportunities
> such as inlining and partial evaluation.  At present, Guile is not able
> to perform these optimizations for toplevel level definitions in any
> case, but it might be possible in the future, at least for modules that
> are not explicitly mutated using low-level operations like this.
>
> Also, it's possible that a future version of Guile may be more
> disciplined in its handling of phases, i.e. expand-time
> (i.e. compile-time) vs run-time phases.  See section 7.2 (Import and
> export levels) of the R6RS for details on one approach, which would
> bring many advantages.  It's been a while since I looked at this
> closely, and at this point I would need some time to refresh my memory
> of the details, but it seems to me that the code you've written would
> likely cause problems with such an approach.
>
> Both the R6RS and R7RS have more declarative module systems, which bring
> many benefits.  Added freedom in one area often implies a loss of
> freedom somewhere else.  In this case, the freedom to treat modules as
> arbitrarily mutable objects implies a loss of freedom in the compiler to
> make any assumptions about what's in the module or even its set of
> bindings.  That freedom carries a very significant cost.
>
>Mark

Thank you for your explanations. That's great feedback! It seems asking
on the Guile user list saved me again from doing something not so good
in my code. I will improve my code accordingly then, either by making
use of SRFI 0 or reverting to simple `define`, knowing that I can only
use it at the top level of a module or top level of the scope where I
want things to be available, as with normal `define` forms.

… *goes and reads SRFI 0* …

OK, so the limitations are, that `cond-expand` is restricted to the top
level, unless Guile implements it differently. Not sure what kind of
useful condition I can come up with inside the `cond-expand` and simply
putting a `#t` seems silly. I guess it is really for checking things you
can know at expand time. I do not have any such conditions in mind to
check. Perhaps I will stick with normal `define` forms for now and just
need to remember, that it will be expanded to a `define` form and thus
needs to be used like one. Actually, that would still make it possible
to return the created procedures and then I could still conditionally
return another procedure instead, so it is still somewhat flexible.

Regards,

Zelphir




Re: Write a macro which defines a procedure

2019-07-21 Thread Zelphir Kaltstahl
Hello Arne!

Thanks for posting those links!

I think your "already defined macro check" is part of what I was looking
for. I say part, because I was looking for something, that probably does
not exist: Something that checks for existing macros and for existing
procedures or other after compile-time defined things. However, the
macro runs before those things are even evaluated, so I guess the only
option would be to inspect the code and then find out what is defined.
This is not really practical.

So now I think that your check is actually as far as one can reasonably go.

Regards,

Zelphir

On 7/20/19 6:00 PM, guile-user-requ...@gnu.org wrote:
> Message: 2
> Date: Sat, 20 Jul 2019 09:04:56 +0200
> From: Arne Babenhauserheide 
> To: guile-user@gnu.org
> Subject: Re: Write a macro which defines a procedure
> Message-ID: <87sgr1nq5d@web.de>
> Content-Type: text/plain; charset="utf-8"
>
>
> zelphirkaltstahl  writes:
>
>> Hi Guile Users,
>>
>> I want to write a macro, which creates a procedure of given name,
>> where the given name is a not yet defined identifier.
>> Here is what I have so far:
> … 
>
>> Anyway, can you help me out writing the macro, fixing at least the 2
>> issues or direct me to a tutorial, which covers how to write a macro
>> which gives basically a new define form?
> I can’t debug your form right now, but I can give you an example where I
> created macros to write macros:
>
> https://bitbucket.org/ArneBab/wisp/src/5e860c746ee02c764bf378aeb8f436a1a341bd5c/examples/enter-three-witches.scm#lines-209
>
> The Enter-Macro defines a macro which outputs its arguments as text.
>
> It took me some time to get it right, but it works pretty well.
>
> Bits and pieces:
> - check for the presence of a macro-binding:
> (syntax-case x ()
>((_ (name more ...) b ...)
>  ; new binding: only create it if the binding is not already a macro
>  (not (eq? 'macro (syntax-local-binding (syntax name
>  
> - stay on the same level:
>   #'(begin …
>
> (this is originally written in wisp and then transformed to scheme for
> easier sharing with other schemers:
> https://bitbucket.org/ArneBab/wisp/src/5e860c746ee02c764bf378aeb8f436a1a341bd5c/examples/enter-three-witches.w#lines-209
>  )
>
> Best wishes,
> Arne


syntax-case identifier name predicate in guard expression

2019-07-22 Thread Zelphir Kaltstahl
Hi Guile Users!

In previous e-mails I inquired about macros defining procedures.

Afterwards I noticed, that I need my macro to check whether some regular
expression is inside the name of an identifier.

For example I have an two identifiers (not strings and no values bound
to them yet):

8<8<8<
/containers/json
/containers//json
>8>8>8

I seem unable to find a way using syntax-rules to distinguish between
these two, when they are only given as identifiers. So I looked into
syntax-case, which has guards and thought, that I might be able to use
guard clauses to check for substrings in the name of the identifier
there. However, so far my attempts have failed to get it right and I am
having difficulties finding any example for such a thing. I believe in
principle it should be possible, however. It is just that I do not know how.

Here is my current code, simplified:

8<8<8<
(define-syntax identifier-name->string
  (lambda (stx)
    (syntax-case stx ()
  ((_ id)
   (identifier? #'id)
   (datum->syntax #'id (symbol->string (syntax->datum #'id)))

(define-syntax define-api-route
  (lambda (stx)
    (syntax-case stx (GET HEAD POST PUT DELETE CONNECT OPTIONS TRACE PATH)
  [(_ route GET my-content-type)
   (string-match "<[^>]+>" (identifier-name->string (syntax route)))
   (syntax (quote aaa))])))
>8>8>8

When calling that I get an error:

8<8<8<
(define-api-route /containers//json GET
application/x-www-form-urlencoded)

While compiling expression:
In procedure symbol->string: Wrong type argument in position 1
(expecting symbol): #/json>
>8>8>8

I have to wrap `route` into (syntax …) though, because otherwise it
complains about a reference to a pattern variable outside of a syntax
form. I do not really understand this, but in all examples I have seen
for guard clauses, pattern variables are wrapped in a call to syntax.

However, identifier-name->string does not work with syntax objects. I am
not sure how I can get the name of the identifier inside the guard
clause as string, so that I can check for occurences of anything in
angle braces <>.

I've also tried multiple other approaches over the last 2 days, but
always there was some error that made it seem like it was the wrong
approach and fixing the errors led to other errors. For example the
following also does not work (whole transcript):

8<8<8<
GNU Guile 2.2.4
Copyright (C) 1995-2017 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (use-modules (web uri)
 (web client)
 (json)
 (ice-9 iconv)
 (ice-9 regex))
scheme@(guile-user)> (define-syntax identifier-name->string
  (lambda (stx)
    (syntax-case stx ()
  ((_ id)
   (identifier? #'id)
   (datum->syntax #'id (symbol->string (syntax->datum #'id)))
scheme@(guile-user)> (define-syntax define-api-route-with-template-variables
  (syntax-rules (GET HEAD POST PUT DELETE CONNECT OPTIONS TRACE PATH)
    [(_ route GET my-content-type)
 (syntax
  (define* (route url-temp-vars docker-socket #:key (data #f))
    (let* ([route-as-string (identifier-name->string route)]
   [match-count
    (fold-matches "<[^>]+>" route-as-string 0 (λ (curr-match
count) (+ count 1)))])
  (cond
   [(= match-count (length url-template-vars))
    ;; build the final request url
    ;; loop over available url template variables
    (let ([request-url
   (let loop ([constructed-route-string route-as-string]
  [remaining-url-template-vars url-temp-vars])
 (cond
  ;; return the whole constructed request url
  [(null? remaining-url-template-vars)
constructed-route-string]
  [else
   ;; replace another url template var and recur
   (loop (regexp-substitute #f
    (string-match "<[^>]+>"
constructed-route-string)
    'pre (car
remaining-url-template-vars) 'post)
 (cdr remaining-url-template-vars))]))])
  ;; do the call with the built request url
  (send-request-to-docker-socket request-url
 docker-socket
 my-content-type
 #:data data))]
   [else
    (error "wrong number of URL template variables"
   

Re: syntax-case identifier name predicate in guard expression

2019-08-04 Thread Zelphir Kaltstahl
Hi Guile Users!

I made some progress in writing a procedure defining macro for creating
procedures which talk to an API.

I now have working code, which checks the name of an identifier in a
guard expression:

8<8<8<
(use-modules (web uri)
 (web client)
 (json)
 (ice-9 iconv)
 (ice-9 regex))


(define* (send-request-to-docker-socket request-url docker-socket
my-content-type #:key (data #f))
  (call-with-values
  (lambda ()
    (http-get request-url
  #:port docker-socket
  #:version '(1 . 1)
  #:keep-alive? #f
  #:headers `((host . ("localhost" . #f))
  (content-type . (my-content-type (charset
. "utf-8"
  #:body (scm->json-string data)
  #:decode-body? #t
  #:streaming? #f))
    (lambda (response response-text)
  (let ([resp-text-as-string (bytevector->string response-text
"utf-8")])
    (cons response resp-text-as-string)


(define-syntax define-api-route
  (lambda (stx)
    (define (identifier-name->string id)
  (symbol->string (syntax->datum id)))

    ;; Not needed yet.
    ;; (define (identifier->symbol id)
    ;;   (syntax->datum id))

    (define (contains-url-template-variable? route-as-string)
  (string-match "<[^>]+>" route-as-string))

    ;; We do not need a macro to produce syntax. Instead we need to use
a procedure to produce the
    ;; syntax, because we want to use it while evaluating another macro.
    (define make-simple-api-route-definition-syntax
  (lambda (route http-method my-content-type route-as-string)
    (syntax
 (quote simple-route

    (syntax-case stx (GET HEAD POST PUT DELETE CONNECT OPTIONS TRACE PATH)
  [(_ route GET my-content-type)
   (contains-url-template-variable? (identifier-name->string (syntax
route)))
   (syntax (quote aaa))]
  ;; an else branch basically
  [(_ route GET my-content-type) #t
   (syntax
    (define* (route docker-socket #:key (data #f))
  (call-with-values
  (lambda ()
    ;; GET request because syntax GET was specified
    (http-get request-url
  #:port docker-socket
  #:version '(1 . 1)
  #:keep-alive? #f
  #:headers `((host . ("localhost" . #f))
  (content-type . (my-content-type
(charset . "utf-8"
  #:body (scm->json-string data)
  #:decode-body? #t
  #:streaming? #f))
    (lambda (response response-text)
  (let ([resp-text-as-string (bytevector->string
response-text "utf-8")])
    (cons response resp-text-as-string))])))


(define* (connect-to-docker-socket #:key (socket-path
"/var/run/docker.sock"))
  (let ([docker-sock-addr (make-socket-address AF_UNIX socket-path)]
    [docker-sock (socket PF_UNIX SOCK_STREAM 0)])
    (setsockopt docker-sock SOL_SOCKET SO_REUSEADDR 1)
    (connect docker-sock docker-sock-addr)
    docker-sock))


(display
 (define-api-route /containers/json GET
"application/x-www-form-urlencoded"))


;; (let ([dock-sock (connect-to-docker-socket)])
;;   (let ([resp-and-resp-text
;;  (/containers/json dock-sock
;;    #:data '(("all" . "true")
;; ("filters" . (("name" . #("db"))
;;   ("status" .
#("running" "exited"))])
;; (display resp-and-resp-text)
;; (newline)))


(display
 (define-api-route /container/json GET "application/x-www-form-urlencoded"))
8<8<8<

However, it seems, that now I have a new problem. It seems I cannot use
a define form inside a syntax-case case!

Running the above code I get the following error:

8<8<8<
ice-9/boot-9.scm:222:17: In procedure map1:
Syntax error:
/home/user/development/Guile/macros/procedure-defining/runnable-example.scm:78:1:
definition in expression context, where definitions are not allowed, in
form (define /containers/json (lambda* (docker-socket #:key (data #f))
(call-with-values (lambda () (http-get request-url #:port docker-socket
#:version (quote (1 . 1)) #:keep-alive? #f #:headers (quasiquote ((host
"localhost" . #f) (content-type "application/x-www-form-urlencoded"
(charset . "utf-8" #:body (scm->json-string data) #:decode-body? #t
#:streaming? #f)) (lambda (response response-text) (let
((resp-text-as-string (bytevector->string response-text "utf-8"))) (cons
response resp-text-as-string))
8<8<8<

While it was possible to have a define form inside a syntax-rules,
suddenly it seems impossible inside a syntax-case?

Removing the (syntax ...) around the define form does not help either
and gives the following error:

8<8<8<

Re: syntax-case identifier name predicate in guard expression

2019-08-05 Thread Zelphir Kaltstahl
Hi Mark!

Thank you for your help!

I must have been blind from moving code back and forth and the (display
...) was still from when the output of the macro was simply a symbol,
for checking whether the guard expression in the (syntax-case ...) cases
works. Also I was confused because the error message mentioned the whole
define expression, which is why I looked in the wrong place : )

I got it working now, including the more complex case of having
variables in request URLs.
(https://gitlab.com/ZelphirKaltstahl/guile-scheme-macros/blob/fccb603a92f2c2d2709e169bbdd516fcf05a6816/procedure-defining/runnable-example.scm)

Fortunately I re-read the Guile docs and read about with-syntax.
Suddenly with-syntax made a lof of sense :D

I think I am finally getting it more or less. There were quite a few
snares to overcome for me, but I think that with some trial and error I
can now get things done.

The complex case should also be moved out of the syntax-case directly
and then I can use it in the library and can finally define API routes
without much trouble (hopefully! unless I overlooked some possibility
for sending requests to the docker API), yay!

Regards,

Zelphir


On 8/5/19 8:51 PM, Mark H Weaver wrote:
> Hi Zelphir,
>
> Zelphir Kaltstahl  writes:
>
>> Hi Guile Users!
>>
>> I made some progress in writing a procedure defining macro for creating
>> procedures which talk to an API.
>>
>> I now have working code, which checks the name of an identifier in a
>> guard expression:
>>
>> 8<8<8<
>> (use-modules (web uri)
>>  (web client)
>>  (json)
>>  (ice-9 iconv)
>>  (ice-9 regex))
>>
>>
>> (define* (send-request-to-docker-socket request-url docker-socket
>> my-content-type #:key (data #f))
>>   (call-with-values
>>   (lambda ()
>>     (http-get request-url
>>   #:port docker-socket
>>   #:version '(1 . 1)
>>   #:keep-alive? #f
>>   #:headers `((host . ("localhost" . #f))
>>   (content-type . (my-content-type (charset
>> . "utf-8"
>>   #:body (scm->json-string data)
>>   #:decode-body? #t
>>   #:streaming? #f))
>>     (lambda (response response-text)
>>   (let ([resp-text-as-string (bytevector->string response-text
>> "utf-8")])
>>     (cons response resp-text-as-string)
>>
>>
>> (define-syntax define-api-route
>>   (lambda (stx)
>>     (define (identifier-name->string id)
>>   (symbol->string (syntax->datum id)))
>>
>>     ;; Not needed yet.
>>     ;; (define (identifier->symbol id)
>>     ;;   (syntax->datum id))
>>
>>     (define (contains-url-template-variable? route-as-string)
>>   (string-match "<[^>]+>" route-as-string))
>>
>>     ;; We do not need a macro to produce syntax. Instead we need to use
>> a procedure to produce the
>>     ;; syntax, because we want to use it while evaluating another macro.
> Right.  Before, you were trying to perform the check within a procedural
> macro, whose code was run when the 'define-api-route' macro was being
> _defined_, which is too early.  Here you have the right idea.
>
>>     (define make-simple-api-route-definition-syntax
>>   (lambda (route http-method my-content-type route-as-string)
>>     (syntax
>>  (quote simple-route
>>
>>     (syntax-case stx (GET HEAD POST PUT DELETE CONNECT OPTIONS TRACE PATH)
>>   [(_ route GET my-content-type)
>>    (contains-url-template-variable? (identifier-name->string (syntax
>> route)))
>>    (syntax (quote aaa))]
>>   ;; an else branch basically
>>   [(_ route GET my-content-type) #t
>>    (syntax
>>     (define* (route docker-socket #:key (data #f))
>>   (call-with-values
>>   (lambda ()
>>     ;; GET request because syntax GET was specified
>>     (http-get request-url
>>   #:port docker-socket
>>   #:version '(1 . 1)
>>   #:keep-alive? #f
>>   #:headers `((host . ("localhost" . #f))
>>   (content-type . (my-content-type
>> (charset . "utf-8"
>>   #:body (scm->json-string data)
>>   #:decode-body? #t
>>    

Re: guile-user Digest, Vol 201, Issue 5

2019-08-09 Thread Zelphir Kaltstahl
Hi Thomas!

I don't have a solution for you, but maybe an idea. Can you check that 
your PATH does not "shadow" the installed Guile?

Regards,

Zelphir

On 8/9/19 6:00 PM, guile-user-requ...@gnu.org wrote:
> Message: 1
> Date: Thu, 8 Aug 2019 22:19:50 +0200
> From: Thomas Morley 
> To: guile-user@gnu.org
> Subject: Problem installing the intended version
> Message-ID:
>   
> Content-Type: text/plain; charset="UTF-8"
>
> Hi,
>
> recently I tested building LilyPond against guile-2.2.6 without
> success[*] and tried to investigate whether the problem is on the
> guile-side or at LilyPond (there are some patches which may or may not
> cause the problem).
>
> Though I stumbled across a problem which may be caused by guile or my
> naivity ...
>
> I had built guile-2.2.6 from the git repository and installed it via
> `sudo make install´
> Then I did (in/for a fresh repo):
>
>   git clone git://git.sv.gnu.org/guile.git ~/guile-2.2.4
>   cd guile-2.2.4/
>   git checkout v2.2.4
>   git checkout -b guile-2.2.4
>   sh autogen.sh
>   ./configure
>   make
>
> All successfull, then some tests:
>
>   ./meta/guile --version
>   -->  guile (GNU Guile) 2.2.4 [...]
>   ./meta/guile-config --version
>   --> guile-config - Guile version 2.2.4
>
> Then installed it systemwide
>
>   sudo make install
>
> And made some testings:
>
>   which guile
>   --> /usr/local/bin/guile
>   /usr/local/bin/guile --version
>   --> guile (GNU Guile) 2.2.6.1-a69b5
>
> Obviously 2.2.4 was _not_ installed but 2.2.6 from another repo.
>
> What am I missing?
>
>
> Thanks,
>   Harm
>
> [*] To be more exact: `make´ succeeded for LilyPond, but `make
> test-baseline´ failed.
>
>
>
> --
>
> Message: 2
> Date: Thu, 8 Aug 2019 22:23:00 +0200
> From: Thomas Morley 
> To: guile-user@gnu.org
> Subject: Re: Problem installing the intended version
> Message-ID:
>   
> Content-Type: text/plain; charset="UTF-8"
>
> Am Do., 8. Aug. 2019 um 22:19 Uhr schrieb Thomas Morley
> :
>> Hi,
>>
>> recently I tested building LilyPond against guile-2.2.6 without
>> success[*] and tried to investigate whether the problem is on the
>> guile-side or at LilyPond (there are some patches which may or may not
>> cause the problem).
>>
>> Though I stumbled across a problem which may be caused by guile or my
>> naivity ...
>>
>> I had built guile-2.2.6 from the git repository and installed it via
>> `sudo make install´
>> Then I did (in/for a fresh repo):
>>
>>   git clone git://git.sv.gnu.org/guile.git ~/guile-2.2.4
>>   cd guile-2.2.4/
>>   git checkout v2.2.4
>>   git checkout -b guile-2.2.4
>>   sh autogen.sh
>>   ./configure
>>   make
>>
>> All successfull, then some tests:
>>
>>   ./meta/guile --version
>>   -->  guile (GNU Guile) 2.2.4 [...]
>>   ./meta/guile-config --version
>>   --> guile-config - Guile version 2.2.4
>>
>> Then installed it systemwide
>>
>>   sudo make install
>>
>> And made some testings:
>>
>>   which guile
>>   --> /usr/local/bin/guile
>>   /usr/local/bin/guile --version
>>   --> guile (GNU Guile) 2.2.6.1-a69b5
> Forgot to add:
>   which guile-config
>   --> /usr/local/bin/guile-config
>   /usr/local/bin/guile-config --version
>   --> guile-config - Guile version 2.2.4
>> Obviously 2.2.4 was _not_ installed but 2.2.6 from another repo.
>>
>> What am I missing?
>>
>>
>> Thanks,
>>   Harm
>>
>> [*] To be more exact: `make´ succeeded for LilyPond, but `make
>> test-baseline´ failed.



Re: Diversification [ branched from Re: conflicts in the gnu project now affect guile]

2019-10-22 Thread Zelphir Kaltstahl
Hi!

I just want to share my experience with Riot.

I have used it before. In fact, I used it to communicate with only one
person so far for reasons I will mention below. Today there was a
strange thing, when Riot showed an error and warned, that it could be a
replay attack. This is not the first time something happened. If you
remember, that some time ago everyone had to upgrade their Riot.IM
client, because someone had intruded in the server system (Iirc it was
someone, who worked there before and still had access somehow. It was
linked on Hackernews. Let's see if I can find it … Probably one of the
search results of: https://hn.algolia.com/?q=riot.im).

We would have to ask ourselves, whether Riot is sufficiently independent
too. I believe it depends on the master server being up and running. If
we could have our own, that would of course be better.

The reason however, why I have only ever used Riot with one person is,
surprise surprise, that most people are not willing to sacrifice the
tiniest bit of comfort, for enhanced security. This one person I used it
with tried to get 2 more people on board, who were even less tech-savy
and whom I did not have the chance of helping directly, to get things
set up and so we remained 1-on-1 on Riot.IM.

Let me explain further:

To verify another person's device, one has to exchange information via a
second trusted channel. That information is a sequence of icons being
shown. If they are the same, that the other person sends you via the
second trusted channel, you can reasonably assume, that the device you
are communicating with is under their control.

When it comes to the step of exchanging information about what icons are
displayed, most people will close the app and say "it's too
complicated", because they do not understand it ("Huh? How strange! Why
I have to do that? Are icons secure?") or do not want to do anything in
order to have security. They are not willing to invest as much as 5min
of effort, to have encrypted chat. What makes matters worse is, that
when you use Riot.IM in the browser, it might happen, that every time
you log in, the other person has to re-verify your device. Guess what
people will do when facing that workflow …

As much as I like Riot.IM, it did have its share of problems and does
bring in some required effort for setting up communication. I would
personally still like to use it, however, I very much doubt, that
someone, who is not willing to use a mailing list, is willing to get
Riot.IM set up and keep it running, while being aware of the security
implications of trusting devices of other people, adhering to a good
security aware workflow. And we are not even using GPG on the mailing
list a lot, so people don't even have to deal with Enigmail yet, to post
and read on the mailing list.

Maybe offering Riot.IM as an alternative would still make sense, just to
see how it goes, but don't bet on many people joining Riot.IM. I am
willing to try!

Best regards,

Zelphir


On 10/22/19 8:47 PM, Mark H Weaver wrote:
> Hi Todor,
>
> Todor Kondić  writes:
>
>> [...]  I've set up my workflows around Guix, git(lab)
>> and a customised Emacs installation (instead of R Studio). My small
>> team of science students (majority female, various cultural
>> backgrounds), never previously exposed to a GNU system to such an
>> extent, managed to get a handle on it quite impressively.
>>
>> But, I doubt any of them would find it natural to take a step further
>> and participate in GNU itself (ugh, now I sound like a preacher of a
>> new age religion). To my knowledge, interaction within GNU communities
>> is still mostly mailing lists and IRC. This _not_ my students' natural
>> digital habitat. I am probably not saying anything new, though ...
> You raise an important issue.  If we can improve the situation without
> causing other problems, I think we should.  I don't know of any modern
> replacement for mailing lists that has the properties we need, but I
> *do* think there's a very promising alternative for live chat: Matrix.
> Amirouche mentioned it elsewhere in this thread.
>
>   https://matrix.org/
>
> Matrix is supported by a very large and diverse set of free clients,
> from modern Web-based interfaces to simple text programs, multiple
> Emacs-based clients, and several gateways to other protocols such as
> IRC, so that old-timers can use their preferred IRC client if they
> prefer.
>
>   https://matrix.org/clients/
>
> Incidentally, there was recently an internal GNU project discussion
> about how to better communicate with one another, and Matrix was
> identified as an option that would meet our requirements.
>
> The client that would likely be most attractive for the younger
> generation is Riot.im:
>
>   https://about.riot.im/
>
> What do you think?
>
> Thanks,
>   Mark
>



Re: Diversification [ branched from Re: conflicts in the gnu project now affect guile]

2019-10-22 Thread Zelphir Kaltstahl


On 10/23/19 1:24 AM, Chris Vine wrote:
> On Tue, 22 Oct 2019 21:23:32 +0200
> Zelphir Kaltstahl  wrote:
> [snip]
>> The reason however, why I have only ever used Riot with one person is,
>> surprise surprise, that most people are not willing to sacrifice the
>> tiniest bit of comfort, for enhanced security. This one person I used it
>> with tried to get 2 more people on board, who were even less tech-savy
>> and whom I did not have the chance of helping directly, to get things
>> set up and so we remained 1-on-1 on Riot.IM.
>>
>> Let me explain further:
>>
>> To verify another person's device, one has to exchange information via a
>> second trusted channel. That information is a sequence of icons being
>> shown. If they are the same, that the other person sends you via the
>> second trusted channel, you can reasonably assume, that the device you
>> are communicating with is under their control.
>>
>> When it comes to the step of exchanging information about what icons are
>> displayed, most people will close the app and say "it's too
>> complicated", because they do not understand it ("Huh? How strange! Why
>> I have to do that? Are icons secure?") or do not want to do anything in
>> order to have security. They are not willing to invest as much as 5min
>> of effort, to have encrypted chat. What makes matters worse is, that
>> when you use Riot.IM in the browser, it might happen, that every time
>> you log in, the other person has to re-verify your device. Guess what
>> people will do when facing that workflow …
> This is a public mailing list, and any replacement of it is going to be
> a mailing-list-alike.  Why do they (or chats) need to be encrypted or
> have the sender verified?  No one should be posting sensitive personal
> information here so I don't understand the point of it.  Lack of
> understanding of (or disagreement with) the purpose may be what is
> holding your idea back. If you want to set up private mailing lists or
> chat servers, fair enough, but that's not what this is.
>
> Discord seems a reasonably popular chat medium with a bridge to IRC and
> discourse seems reasonably popular as a web based mailing-list-ish
> medium with a somewhat more vibey feel than traditional mailing lists.
>
Hi!

My example was about private conversation and a friend. So you are
right, that the example does not quite match the mailing list example.
Maybe we should clear up the question what kind of communication would
happen over such a new channel first, before making any decisions.

In Riot you will notice, that you see warning, when the devices are not
verified. That confuses users. Not sure what you can do about it in
terms of making settings default, as I have not used Riot in a public
communication scenario.

You did not address the other point I raised though: Dependency on a
third party server (and all the implications, when/if it gets hacked
again). Same goes for Discord. It would not be under our control whether
the server is running. In case of Discord: While we only need a mail
client for posting on a mailing list, using Discord requires to use a
bloated Electron app. When you start Discord and log in, the first thing
that happens is, that your CPU fan starts rotating, because of Discord
showing ads with videos. Do we really want to let people go through this
to interact with the rest of us?

There is also the problem of non-searchable content. You cannot, as far
as I know, search in a search engine through Discord or Riot messages.
If content by tendency of "quickly solving the problem in chat" moves to
non-searchable medium, it will mean, that searching in search engines
does not benefit from those solutions.

Another problem are the company policies of Discord. Not exactly a place
where you'd expect free software to happen.

However, like I said, I personally would be willing to try it, for sure!
Some communities already actively use Discord (Pharo community for example).

Best regards,

Zelphir




Re: Diversification [ branched from Re: conflicts in the gnu project now affect guile]

2019-10-23 Thread Zelphir Kaltstahl


On 10/23/19 2:33 PM, pelzflorian (Florian Pelz) wrote:
> On Wed, Oct 23, 2019 at 01:25:44PM +0200, pelzflorian (Florian Pelz) wrote:
>> On Wed, 23 Oct 2019 08:48:13 +0200
>> "pelzflorian (Florian Pelz)"  wrote:
>>> On Wed, Oct 23, 2019 at 08:16:34AM +0200, Amirouche Boubekki wrote:
>>> I only know that subscribing to GNOME Discourse required Javascript
>>> and its mail headers are less pretty compared to mailman.
>>>
>> These are the reasons why I do not like Discourse.
>>
>>> I am not sure what it is that caused gnome to move from mailman to
>>> discourse, but I suspect it was to get the more up-to-date feel of a web
>>> interface.
>> I quote Emmanuele Bassi, 
>> <https://mail.gnome.org/archives/gtk-devel-list/2019-February/msg1.html>:
>>> Having a better archive search, a better moderation system, and a
>>> decent web UI are the major selling points for switching to
>>> Discourse.
> If there isn’t one already, then I would like to start working on a
> written in Guile, free software, old-school bulletin board-like
> interface, perhaps with a more modern UI design, next week.  I do not
> like Discourse and will need something like this anyway for other
> projects.  I see there already is guile-email and Mumi.  So far I had
> no time looking at either.  I would start next week.
>
> Regards,
> Florian

It would be an interesting project, for an example of how to do a Guile
server side. What kind of library/framework/tool would you use for the
server side? I think the standard library webserver is still very bare
bones. So far I've not tried GNU Artanis. Would it be a good idea to use
that?

I've created some example code for the standard library web server:

https://gitlab.com/zelphir-kaltstahl-projects/guile-scheme-tutorials-and-examples/tree/dev/web-development/using-guile-webserver

But it has not progressed very far.

Regards,
Zelphir




Use core or SRFIs?

2019-10-24 Thread Zelphir Kaltstahl
Hello Guile Users!

I have a question regarding usage of SRFIs in Guile code.

Sometimes there are core functions, which are also available from an
SRFI implementation. One example I am currently dealing with are bitwise
operations for integer numbers. There is SRFI 60 and there are the core
functions like logand, logior and so on.

Usually I tend to think, that using the SRFI implementation in such
situation is better, as it is an implementation of a common interface,
which other Schemes might also have implemented. Using that makes code
more portable to other Schemes. However, I want to be sure, that this is
a good way of thinking about it. Are there ever arguments against using
an SRFI implementation, when an SRFI implementation provides what I need?

Another example are structs. I usually use SRFI 9 to make some structs,
instead of the core record or struct type.

What do you think?

Best regards,

Zelphir




Re: Use core or SRFIs?

2019-10-24 Thread Zelphir Kaltstahl
Hi!

I see. Thanks, that is what I did so far as well : )

Best regards,

Zelphir

On 10/24/19 6:01 PM, Nala Ginrut wrote:
> Personally, I prefer srfi. But sometimes I mix with RnRS.
> I think it's better to avoid Guile specific things, however, Guile
> provides many good things that the standard doesn't have.
>
> On Thu, Oct 24, 2019 at 11:56 PM Zelphir Kaltstahl
> mailto:zelphirkaltst...@posteo.de>> wrote:
>
> Hello Guile Users!
>
> I have a question regarding usage of SRFIs in Guile code.
>
> Sometimes there are core functions, which are also available from an
> SRFI implementation. One example I am currently dealing with are
> bitwise
> operations for integer numbers. There is SRFI 60 and there are the
> core
> functions like logand, logior and so on.
>
> Usually I tend to think, that using the SRFI implementation in such
> situation is better, as it is an implementation of a common interface,
> which other Schemes might also have implemented. Using that makes code
> more portable to other Schemes. However, I want to be sure, that
> this is
> a good way of thinking about it. Are there ever arguments against
> using
> an SRFI implementation, when an SRFI implementation provides what
> I need?
>
> Another example are structs. I usually use SRFI 9 to make some
> structs,
> instead of the core record or struct type.
>
> What do you think?
>
> Best regards,
>
> Zelphir
>
>


Re: mailmam, web bridge, forum, p2p (was: Diversification)

2019-10-24 Thread Zelphir Kaltstahl
Hi Tomas!

Do you still remember some of the issues you came across when making
such a shop?

If I am not mistaken, Racket's continuation based webserver does
something like this. It also stores state in the URL, which then looks a
bit strange. I think that state even encodes the continuation.

Regards,

Zelphir


On 10/24/19 5:12 PM, to...@tuxteam.de wrote:
> On Thu, Oct 24, 2019 at 11:03:07PM +0800, Nala Ginrut wrote:
>> I've ever tried to write a site for our local community without any JS
>> code, all auxiliary features include simple animation are implemented with
>> CSS.
>> However, I have to say it's painful to write a more complex site. I don't
>> know if there's any framework for that. I'm too lazy to write all things
>> manually. But I recommend you try it if you never did. It's interesting.
> I once did. Long time ago. A simple shop -- no javascript.
>
> All state was coded in the URL. You wouldn't do that these days (at least
> not without thinking hard) -- but it worked acceptably. People ordered
> things :-)
>
> Cheers
> -- t



Re: mailmam, web bridge, forum, p2p (was: Diversification)

2019-10-24 Thread Zelphir Kaltstahl
Hi Nala!

I have a question regarding this IP check.

Does this mean that both, the IP address and (logical and) the cookie
need to be correct, or is it an inclusive logical or?

I sometimes find myself switching location of the server of the VPN I am
using. In such a case, would I still be logged in, based on the correct
cookie, or would I be logged out, because my IP address does not match
my previous address?

Regards,

Zelphir

On 10/24/19 4:15 PM, Nala Ginrut wrote:
> On Thu, Oct 24, 2019 at 8:30 PM pelzflorian (Florian Pelz) <
> pelzflor...@pelzflorian.de> wrote:
>
>> Because of login CSRF the Referer header should also be verified for
>> all links internal to the website (external links should strip the
>> Referer header via redirect pages similar to what the code attached to
>> this mail does).
>>
>> I do not know what Artanis does currently.  I will check next week.
>>
>>
> The current Artanis will check both session token (from cookies) and the
> client IP.
> This method was blamed to be overkilled because some users may be in the
> same LAN with a unique external IP.
> But I think IPv6 will cover this world finally, so I think this would be
> the best way to go.
> Of course, there's no conflict to add extra verification token. Patches or
> proposals are welcome. ;-)
>
> Best regards.



Re: Use core or SRFIs?

2019-10-24 Thread Zelphir Kaltstahl
Ah, but SRFI 151 is not implemented in my version of Guile:

~
scheme@(guile-user)> (use-modules (srfi srfi-151))
While compiling expression:
no code for module (srfi srfi-151)
scheme@(guile-user)>
~

Guile version: 2.2.6 from Guix:

~
guile (GNU Guile) 2.2.6
Copyright (C) 2019 Free Software Foundation, Inc.

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

Are you suggesting, that I copy the code for SRFI 151 from somewhere and
put it into my project?

Regards,

Zelphir

On 10/24/19 7:02 PM, John Cowan wrote:
> For bitwise integers, I recommend SRFI 151.  If you use your
> implementation to provide the seven core functions bitwise-not,
> bitwise-and, bitwise-ior, bitwise-xor, arithmetic-shift,
> integer-length, and bit-count, all of which have definitions in
> bitwise-core.scm that are very slow, then you'll have a package that
> can do pretty much what all the bitwise SRFIs provide and more with
> acceptable performance.
>
> There is a conversion table at the end of the SRFI between the names
> used by other SRFIs and the names used by SRFI 151; they are as close
> to SRFI 33 and SRFI 60 as practical.  It is part of the Tangerine
> Edition of R7RS-large.
>
> On Thu, Oct 24, 2019 at 12:43 PM Nala Ginrut  <mailto:nalagin...@gmail.com>> wrote:
>
> Personally, I prefer srfi. But sometimes I mix with RnRS.
> I think it's better to avoid Guile specific things, however, Guile
> provides
> many good things that the standard doesn't have.
>
> On Thu, Oct 24, 2019 at 11:56 PM Zelphir Kaltstahl <
> zelphirkaltst...@posteo.de <mailto:zelphirkaltst...@posteo.de>> wrote:
>
> > Hello Guile Users!
> >
> > I have a question regarding usage of SRFIs in Guile code.
> >
> > Sometimes there are core functions, which are also available from an
> > SRFI implementation. One example I am currently dealing with are
> bitwise
> > operations for integer numbers. There is SRFI 60 and there are
> the core
> > functions like logand, logior and so on.
> >
> > Usually I tend to think, that using the SRFI implementation in such
> > situation is better, as it is an implementation of a common
> interface,
> > which other Schemes might also have implemented. Using that
> makes code
> > more portable to other Schemes. However, I want to be sure, that
> this is
> > a good way of thinking about it. Are there ever arguments
> against using
> > an SRFI implementation, when an SRFI implementation provides
> what I need?
> >
> > Another example are structs. I usually use SRFI 9 to make some
> structs,
> > instead of the core record or struct type.
> >
> > What do you think?
> >
> > Best regards,
> >
> > Zelphir
> >
> >
> >
>


Re: Use core or SRFIs?

2019-10-24 Thread Zelphir Kaltstahl
Sorry, I am a bit clueless right now. I have the following questions:

Where would I find srfi-151.sld?

What is a *.sld file? (If I had to come up with a guess: "Scheme
language definition"?)

If it is already standard Scheme code, why would I need to adapt it for
Guile? Does it need to be modified?


I think modifying an external library, which does not exist for Guile
yet, is a bit out of scope for my project. I also found logand, logior
and similar to be super fast. I expect that the SRFI 60 functions are
mapped to the Guile core logand and similar internally. I ran a million
times logand in approximately 1.3 seconds. Is that slow?

Background: I am working on a bit board implementation and my current
(working) implementation uses bit vectors, because I did initially not
get it, that I could use integers with those bit-wise operations instead
of bit vectors. I had the initial impression, that the code ran fast,
but using logand and logior and similar, I already have an approximate
300x speedup. Not sure whether that should still be considered slow.
Here is some timing code I used to measure a very simple case:

~
(use-modules (srfi srfi-19))

(define-syntax time
  (syntax-rules ()
    [(time expr expr* ...)
 (begin
   (define start-time (current-time time-monotonic))
   expr
   expr* ...
   (define end-time (current-time time-monotonic))
   (let* ([diff (time-difference end-time start-time)]
  [elapsed-ns (+ (/ (time-nanosecond diff) 1e9)
 (time-second diff))])
 (display (format #t "~fs~%" elapsed-ns]))


(time
 (let ([int1 #b10101010]
   [int2 #b01010101])
   (do ([i 1 (+ i 1)])
   ([> i 100])
 (logand int1 int2
~

And here is the one for my old / current code:

~
(use-modules (srfi srfi-19))

(define-syntax time
  (syntax-rules ()
    [(time expr expr* ...)
 (begin
   (define start-time (current-time time-monotonic))
   expr
   expr* ...
   (define end-time (current-time time-monotonic))
   (let* ([diff (time-difference end-time start-time)]
  [elapsed-ns (+ (/ (time-nanosecond diff) 1e9)
 (time-second diff))])
 (display (format #t "~fs~%" elapsed-ns]))


(define (binary-bit-vector-operation bv1 bv2 proc)
  (define (iter bit-list1 bit-list2)
    (cond [(or (null? bit-list1) (null? bit-list2)) '()]
  [else (cons (proc (car bit-list1)
    (car bit-list2))
  (iter (cdr bit-list1)
    (cdr bit-list2)))]))
  (list->bitvector
   (iter (bitvector->list bv1)
 (bitvector->list bv2


(time
 (let ([bv1 #*10101010]
   [bv2 #*01010101])
   (do ([i 1 (+ i 1)])
   ([> i 100])
 (binary-bit-vector-operation
  bv1
  bv2
  (lambda (b1 b2)
    (and b1 b2))
~

It is also in my todo file on:

https://notabug.org/ZelphirKaltstahl/bitboard/src/dev/todo.org

(Btw.: I really like that notabug renders Emacs Org-mode files!)

Regards,

Zelphir

On 10/24/19 8:50 PM, John Cowan wrote:
> Compile it yourself!  Just look at the logic in srfi-151.sld and see
> how it needs to be modified for Guile.  Easy-peasy.
>
> It's a lot less work to port a SRFI implementation than to do things
> from scratch.
>
> On Thu, Oct 24, 2019 at 2:26 PM Zelphir Kaltstahl
> mailto:zelphirkaltst...@posteo.de>> wrote:
>
> Ah, but SRFI 151 is not implemented in my version of Guile:
>
> ~
> scheme@(guile-user)> (use-modules (srfi srfi-151))
> While compiling expression:
> no code for module (srfi srfi-151)
> scheme@(guile-user)>
> ~
>
> Guile version: 2.2.6 from Guix:
>
> ~
> guile (GNU Guile) 2.2.6
> Copyright (C) 2019 Free Software Foundation, Inc.
>
> License LGPLv3+: GNU LGPL 3 or later
> <http://gnu.org/licenses/lgpl.html>
> <http://gnu.org/licenses/lgpl.html>.
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> ~
>
> Are you suggesting, that I copy the code for SRFI 151 from
> somewhere and put it into my project?
>
> Regards,
>
> Zelphir
>
> On 10/24/19 7:02 PM, John Cowan wrote:
>> For bitwise integers, I recommend SRFI 151.  If you use your
>> implementation to provide the seven core functions bitwise-not,
>> bitwise-and, bitwise-ior, bitwise-xor, arithmetic-shift,
>> integer-length, and bit-count, all of which have definitions in
>> bitwise-core.scm that are very slow, then you'll have a package
>> that can do pretty much what all the bitwise SRFIs provide and
>> more with acceptable performance.
>

Re: Use core or SRFIs?

2019-10-24 Thread Zelphir Kaltstahl
Thanks for your input!

This also reads reasonable.

On 10/24/19 7:01 PM, Taylan Kammer wrote:
> On 24.10.2019 17:55, Zelphir Kaltstahl wrote:
>> Hello Guile Users!
>>
>> I have a question regarding usage of SRFIs in Guile code.
>>
>> Sometimes there are core functions, which are also available from an
>> SRFI implementation. One example I am currently dealing with are bitwise
>> operations for integer numbers. There is SRFI 60 and there are the core
>> functions like logand, logior and so on.
>>
>> Usually I tend to think, that using the SRFI implementation in such
>> situation is better, as it is an implementation of a common interface,
>> which other Schemes might also have implemented. Using that makes code
>> more portable to other Schemes. However, I want to be sure, that this is
>> a good way of thinking about it. Are there ever arguments against using
>> an SRFI implementation, when an SRFI implementation provides what I need?
>>
>> Another example are structs. I usually use SRFI 9 to make some structs,
>> instead of the core record or struct type.
>>
>> What do you think?
> My decision-tree on this question would go like this:
>
> Do I *really* care about my code being portable?
> |
> -> Yes -> Use the SRFI
> |
> -> No
>|
>Is the Guile API an old and crusty one that may be deprecated?
>|
>-> Yes -> Use the SRFI
>|
>-> No
>   |
>   Is the Guile API noticeably better than the SRFI?
>   |
>   -> Yes -> Use the Guile API
>   |
>   -> No -> Use the SRFI
>
> The criteria for the API/implementation being "better" might include,
> depending on the situation and your subjective tastes:
>
> - simplicity
> - feature-richness
> - performance
>
> I would default to using the SRFI if the Guile-specific API isn't
> noticeably better, because maybe one day you or someone else will try to
> make your code portable.  I don't know of an argument for using a
> Guile-specific API when there's an SRFI that does the same, is as good,
> and is supported by Guile.
>
>> Best regards,
>>
>> Zelphir
>>
> Kind regards,
>
> - Taylan
>
>
> P.S. for SRFI enthusiasts: I've written a ton of them in R7RS Scheme,
> many of which Guile might support:
>
> https://github.com/TaylanUB/scheme-srfis/
>



Re: Use core or SRFIs?

2019-10-24 Thread Zelphir Kaltstahl
I see, thank you.

I am still not sure using SRFI 151 will have any advantage for my program:

- Is there any plan to phase out SRFI 60, so that in the future my code
using SRFI 60 would not work any longer?
- Is SRFI 60 considered to be slow running code?
- Is there something bad about how SRFI 60 is implemented for Guile?
- Why would I use SRFI 151 instead of SRFI 60? What is the advantage of
that, considering, that it would bring more code into my project, which
I would have to manage and even get to run first?

So far SRFI 60 has worked in my refactored (from using bit vectors to
using integers) procedures. As long as I cannot see an advantage of
using SRFI 151, I will probably stick with SRFI 60 usage. I might not
have some knowledge context here.

Thanks for hinting to SRFI 151 though. I did not know that there were
several "treat integers as bits" libraries out there.

Regards,

Zelphir


On 10/24/19 9:56 PM, John Cowan wrote:
> See <https://github.com/scheme-requests-for-implementation/srfi-151>. 
> Clone it and do a little adapting.  The .sld extension is a common,
> but not required, convention for R7RS libraries, but the guts of it
> are in the other files.
>
> On Thu, Oct 24, 2019 at 3:47 PM Zelphir Kaltstahl
> mailto:zelphirkaltst...@posteo.de>> wrote:
>
> Sorry, I am a bit clueless right now. I have the following questions:
>
> Where would I find srfi-151.sld?
>
> What is a *.sld file? (If I had to come up with a guess: "Scheme
> language definition"?)
>
> If it is already standard Scheme code, why would I need to adapt
> it for Guile? Does it need to be modified?
>
>
> I think modifying an external library, which does not exist for
> Guile yet, is a bit out of scope for my project. I also found
> logand, logior and similar to be super fast. I expect that the
> SRFI 60 functions are mapped to the Guile core logand and similar
> internally. I ran a million times logand in approximately 1.3
> seconds. Is that slow?
>
> Background: I am working on a bit board implementation and my
> current (working) implementation uses bit vectors, because I did
> initially not get it, that I could use integers with those
> bit-wise operations instead of bit vectors. I had the initial
> impression, that the code ran fast, but using logand and logior
> and similar, I already have an approximate 300x speedup. Not sure
> whether that should still be considered slow. Here is some timing
> code I used to measure a very simple case:
>
> ~
> (use-modules (srfi srfi-19))
>
> (define-syntax time
>   (syntax-rules ()
>     [(time expr expr* ...)
>  (begin
>    (define start-time (current-time time-monotonic))
>    expr
>    expr* ...
>    (define end-time (current-time time-monotonic))
>    (let* ([diff (time-difference end-time start-time)]
>   [elapsed-ns (+ (/ (time-nanosecond diff) 1e9)
>  (time-second diff))])
>  (display (format #t "~fs~%" elapsed-ns]))
>
>
> (time
>  (let ([int1 #b10101010]
>    [int2 #b01010101])
>    (do ([i 1 (+ i 1)])
>    ([> i 100])
>  (logand int1 int2
> ~
>
> And here is the one for my old / current code:
>
> ~
> (use-modules (srfi srfi-19))
>
> (define-syntax time
>   (syntax-rules ()
>     [(time expr expr* ...)
>  (begin
>    (define start-time (current-time time-monotonic))
>    expr
>    expr* ...
>    (define end-time (current-time time-monotonic))
>    (let* ([diff (time-difference end-time start-time)]
>   [elapsed-ns (+ (/ (time-nanosecond diff) 1e9)
>  (time-second diff))])
>  (display (format #t "~fs~%" elapsed-ns]))
>
>
> (define (binary-bit-vector-operation bv1 bv2 proc)
>   (define (iter bit-list1 bit-list2)
>     (cond [(or (null? bit-list1) (null? bit-list2)) '()]
>   [else (cons (proc (car bit-list1)
>     (car bit-list2))
>   (iter (cdr bit-list1)
>     (cdr bit-list2)))]))
>   (list->bitvector
>    (iter (bitvector->list bv1)
>  (bitvector->list bv2
>
>
> (time
>  (let ([bv1 #*10101010]
>    [bv2 #*01010101])
>    (do ([i 1 (+ i 1)])
>    ([> i 100])
>  (binary-bit-vector-operation
>   bv1
>   bv2
>   (lambda (b1 b

Re: Diversification [ branched from Re: conflicts in the gnu project now affect guile]

2019-10-26 Thread Zelphir Kaltstahl
On 10/26/19 1:26 PM, to...@tuxteam.de wrote:
> On Sat, Oct 26, 2019 at 11:03:12AM +0200, pelzflorian (Florian Pelz) wrote:
>> On Sat, Oct 26, 2019 at 10:14:22AM +0200, to...@tuxteam.de wrote:
> [...]
>
>>> only become aware of that when you try to live at the rift.
>> Yes, this is something we should keep in mind.  IMHO the medium should
>> remain a mailing list and this should be clear.  Top posting is
>> useless and undesirable with both e-mail and forums though, I believe.
>>
>> Since I use mutt too, I think plain text compatibility is important.
> See? There lies the problem. I'm firmly in your "camp", and still I
> learnt to realise that the other "cultures" do have as difficult a
> time to adapt to "our" camp as the other way around.
>
> That's why I believe that we need serious thinking (beyond the "easy"
> technical things) and lots of tolerance.
>
> To me, Wikipedia is a wonderful inspirational example for a web site
> which succeds in bridging an astonishly broad swath of those "cultures"
> (and still doesn't cover all of them, it has a distinct academic and
> "liberal", in the broadest sense, "smell" to it).
>
>> As for the formatting, I think for plain text e-mail compatibility,
>> when there are stars around a word, it should *not* be highlighted as
>> italic.
> Uh -- isn't the star reserved for *strong*? ;-)
>
> Cheers
> -- tomás

Hi!

Well, I hope that such tolerance does not lead us to accept usage of
mini-uglyfied proprietary JavaScript or other bad things, just to please
people, who in the majority most likely …

(1) … would never consider switching away from _their_ medium of choice,
because most people use it, so it must be right
(2) … have never even thought about the consequences of their choice of
technology (examples here are the web engine monoculture threat and
human interaction via Whatsapp and FB messenger, Skype)

I just want to point that out. While I find it to be a good idea to be
open to alternatives, I do not find it acceptable to not stay true to
our principles as a community of free software developers.

I also often see a very heavy imbalance between the amount of thought
some people in the free software world have put into their choice of
technology and the amount of thought the mainstream user has put into
their choice (usually zero, besides an "Oh it works!" or "It does not
cost me money!"). So we should not give up our principles, in order to
win some people over, because then we are actually the ones "won over"
(or lost) to the proprietary non-free world. It would not be a
diversification, but a disintegration of our community.

That said, I am open to trying out any community communication
technology, that follows the principles of free software and is run in
an ethically acceptable way.

I am highly skeptical of discourse, because:

* https://www.discourse.org/ tries to load Google Analytics and
fontawesome, 2 tools to spy on users. They already do not seem to care
about privacy.
* It is very JavaScript heavy.
* In my experience slow and sluggish.
* WYSIWYG-Editor – These tend to not produce plain text well readable
documents. Just give me some simple editor, Markdown maybe, not mandatory.

That is, why I like the idea of having a good old (newly written in
Guile) forum software. I would like and welcome such a forum software,
because some of my best memories of community interaction happened in
such a good old forum with a great community. It is also a great
structured long term memory. Whether the "other cultures" would use it
is on a different sheet of paper.

One more thing we should very much look out for, when choosing some
technology or when making our own software is:

* Can we actually get all our content out of that software if needed?
Can we export it to some JSON or other useful format?

Otherwise we will lock ourselves in.

Best regards,

Zelphir




Re: mailmam, web bridge, forum, p2p

2019-10-27 Thread Zelphir Kaltstahl
On 10/27/19 3:26 PM, Keith Wright wrote:
> Mike Gerwitz  writes:
>
>> To make sure I see replies, please include me in the recipient list (not
>> just the mailing list).  I missed this at first.
>>
>> On Sat, Oct 26, 2019 at 09:48:37 +0200, to...@tuxteam.de wrote:
 Passing session tokens via GET requests is a bad idea, because that
 leaks the token.
> Actually, if you are going to have an extended conversation
> between two people that has little to do with Guile,
> consider taking it off the mailing list entirely.
>
>-- Keith 
>
Hi Keith,

I understand your point (everyone gets emails …), but at the same time I
find this quite educational. It would be great, if at the end there was
some documentation why one approach was chosen, with all the up- and
downsides of the approaches discussed, if this is not available on the
mailing list : )

Regards,

Zelphir




Re: guile-user Digest, Vol 204, Issue 2

2019-11-05 Thread Zelphir Kaltstahl
This is great! A solid JSON parsing and outputting library is important
for a programming language these days! Thanks for your work!

On 11/5/19 6:00 PM, guile-user-requ...@gnu.org wrote:
> Message: 1
> Date: Mon, 4 Nov 2019 22:28:12 -0800
> From: Aleix Conchillo Flaqué 
> To: guile-user 
> Subject: [ANN] guile-json 3.3.0 released
> Message-ID:
>   
> Content-Type: text/plain; charset="UTF-8"
>
> Hi,
>
> I'm pleased to announce guile-json 3.3.0. This new version comes with a few
> improvements: guile-json will now throw an exception if the native scheme
> value used to build a JSON document is invalid (this is done before
> printing any JSON). Also, an additional key argument #:validate can be
> given to ignore the validation in the case performance is important and the
> data is known to be valid. Empty JSON array slots are also considered
> invalid, before they were generating an invalid scheme representation. A
> few more details can be found on the NEWS file.
>
> https://github.com/aconchillo/guile-json
>
> Best,
>
> Aleix



guile-json, SRIFs and licenses

2019-11-06 Thread Zelphir Kaltstahl
Hi!

What is the requirement in terms of licenses for SRFI implementations?

I personally think that MIT is a terrible license (one of the I don't
care licenses) as it does not make sure, that modifications flow back to
the community. Do SRFIs require MIT license? And if so, why?

~ Zelphir

On 11/6/19 1:28 AM, John Cowan wrote:
> +1.  If only it weren't GPL3, which makes it ineligible to be a SRFI
> implementation
>
> Is there any chance of dual-licensing it under MIT?
>
> On Tue, Nov 5, 2019 at 7:03 PM Zelphir Kaltstahl 
> wrote:
>
>> This is great! A solid JSON parsing and outputting library is important
>> for a programming language these days! Thanks for your work!
>>
>> On 11/5/19 6:00 PM, guile-user-requ...@gnu.org wrote:
>>> Message: 1
>>> Date: Mon, 4 Nov 2019 22:28:12 -0800
>>> From: Aleix Conchillo Flaqué 
>>> To: guile-user 
>>> Subject: [ANN] guile-json 3.3.0 released
>>> Message-ID:
>>>   <
>> ca+xasouhwaqapqvpqqg5suermoe9pkydfm57ng679pgsy5e...@mail.gmail.com>
>>> Content-Type: text/plain; charset="UTF-8"
>>>
>>> Hi,
>>>
>>> I'm pleased to announce guile-json 3.3.0. This new version comes with a
>> few
>>> improvements: guile-json will now throw an exception if the native scheme
>>> value used to build a JSON document is invalid (this is done before
>>> printing any JSON). Also, an additional key argument #:validate can be
>>> given to ignore the validation in the case performance is important and
>> the
>>> data is known to be valid. Empty JSON array slots are also considered
>>> invalid, before they were generating an invalid scheme representation. A
>>> few more details can be found on the NEWS file.
>>>
>>> https://github.com/aconchillo/guile-json
>>>
>>> Best,
>>>
>>> Aleix
>>



Re: guile-user Digest, Vol 204, Issue 2

2019-11-06 Thread Zelphir Kaltstahl
I also cannot download that tarball and on:
https://bigsearcher.com/mirrors/nongnu/guile-json/ it does not exist.

(http://download.savannah.gnu.org/releases/guile-json redirects to
https://bigsearcher.com/mirrors/nongnu/guile-json/)

On Github one can download it.

On 11/6/19 7:12 AM, Greg Coladonato wrote:
> Aleix, I tried to follow the link at
> https://github.com/aconchillo/guile-json to download your tar file at
> http://download.savannah.gnu.org/releases/guile-json/guile-json-3.3.0.tar.gz,
> but that URL redirects to "bigsearcher.com". Are others able to download
> the tar file from that savannah URL?
>
> Greg
>
> On Tue, Nov 5, 2019 at 9:04 AM  wrote:
>
>> Send guile-user mailing list submissions to
>> guile-user@gnu.org
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>> https://lists.gnu.org/mailman/listinfo/guile-user
>> or, via email, send a message with subject or body 'help' to
>> guile-user-requ...@gnu.org
>>
>> You can reach the person managing the list at
>> guile-user-ow...@gnu.org
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of guile-user digest..."
>>
>>
>> Today's Topics:
>>
>>1. [ANN] guile-json 3.3.0 released (Aleix Conchillo Flaqué)
>>2. Re: [ANN] guile-json 3.3.0 released (John Cowan)
>>
>>
>> --
>>
>> Message: 1
>> Date: Mon, 4 Nov 2019 22:28:12 -0800
>> From: Aleix Conchillo Flaqué 
>> To: guile-user 
>> Subject: [ANN] guile-json 3.3.0 released
>> Message-ID:
>> <
>> ca+xasouhwaqapqvpqqg5suermoe9pkydfm57ng679pgsy5e...@mail.gmail.com>
>> Content-Type: text/plain; charset="UTF-8"
>>
>> Hi,
>>
>> I'm pleased to announce guile-json 3.3.0. This new version comes with a few
>> improvements: guile-json will now throw an exception if the native scheme
>> value used to build a JSON document is invalid (this is done before
>> printing any JSON). Also, an additional key argument #:validate can be
>> given to ignore the validation in the case performance is important and the
>> data is known to be valid. Empty JSON array slots are also considered
>> invalid, before they were generating an invalid scheme representation. A
>> few more details can be found on the NEWS file.
>>
>> https://github.com/aconchillo/guile-json
>>
>> Best,
>>
>> Aleix
>>
>>
>> --
>>
>> Message: 2
>> Date: Tue, 5 Nov 2019 09:32:27 -0500
>> From: John Cowan 
>> To: Aleix Conchillo Flaqué 
>> Cc: guile-user 
>> Subject: Re: [ANN] guile-json 3.3.0 released
>> Message-ID:
>> <
>> cad2gp_qbbq8yfbf_csxlr2ihyztkdcbhqtpafoj+w0_nqkg...@mail.gmail.com>
>> Content-Type: text/plain; charset="UTF-8"
>>
>> Thanks, this is great!  I'm curious though why you didn't take up my
>> suggestion of using 'null rather than #nil, given the points I raised at <
>> https://github.com/aconchillo/guile-json/issues/31>.
>>
>> On Tue, Nov 5, 2019 at 1:28 AM Aleix Conchillo Flaqué <
>> aconchi...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I'm pleased to announce guile-json 3.3.0. This new version comes with a
>> few
>>> improvements: guile-json will now throw an exception if the native scheme
>>> value used to build a JSON document is invalid (this is done before
>>> printing any JSON). Also, an additional key argument #:validate can be
>>> given to ignore the validation in the case performance is important and
>> the
>>> data is known to be valid. Empty JSON array slots are also considered
>>> invalid, before they were generating an invalid scheme representation. A
>>> few more details can be found on the NEWS file.
>>>
>>> https://github.com/aconchillo/guile-json
>>>
>>> Best,
>>>
>>> Aleix
>>>
>>
>> --
>>
>> Subject: Digest Footer
>>
>> ___
>> guile-user mailing list
>> guile-user@gnu.org
>> https://lists.gnu.org/mailman/listinfo/guile-user
>>
>>
>> --
>>
>> End of guile-user Digest, Vol 204, Issue 2
>> **
>>
>



Re: guile-json, SRIFs and licenses

2019-11-06 Thread Zelphir Kaltstahl
Hi John!

I am just putting my thoughts he, as I do not decide these matters of
course:

I think in this case, it might be a good idea to make sure, that
guile-json runs on all Schemes implementing a standard level and keep it
free software, to avoid the problem of people grabbing it and making it
proprietary software. If it is that standard conform, it would hopefully
require no effort to use the library in other Schemes. Then the only
obstacle would be finding the repository and downloading the code.

Not sure how standard Guile's module system is, but maybe one could use
a module system from the SRFIs to get more compatibility with other
Scheme dialects.

What would be the effects of guile-json being dual-licensed?

If the implementation for an SRFI is under MIT, cannot people take that
instead of the original guile-json repository and make it proprietary?

How could the dual license work, so that we still make sure, that
guile-json can only be used as free software?

Regards,

Zelphir

On 11/6/19 3:36 PM, John Cowan wrote:
> The MIT license is required for all SRFIs, both texts and
> implementations: the exact wording appears at the end of every SRFI,
> and is adjusted over time as the MIT license changes (very slightly). 
> I wasn't there at the time, but it was probably adopted because MIT,
> like BSD, is a universal donor: it can be incorporated into software
> that is preponderantly under any other license.  Chicken, for
> instance, is under the BSD license, but you can compile and distribute
> a Chicken program under any license — unless it incorporates one of
> the 31 GPLed eggs.
>
> What looks like a commons from inside the GNUverse looks more like a
> walled garden to the rest of FLOSS.
>
>
>
> On Wed, Nov 6, 2019 at 3:19 AM Zelphir Kaltstahl
> mailto:zelphirkaltst...@posteo.de>> wrote:
>
> Hi!
>
> What is the requirement in terms of licenses for SRFI implementations?
>
> I personally think that MIT is a terrible license (one of the I don't
> care licenses) as it does not make sure, that modifications flow
> back to
> the community. Do SRFIs require MIT license? And if so, why?
>
> ~ Zelphir
>
> On 11/6/19 1:28 AM, John Cowan wrote:
> > +1.  If only it weren't GPL3, which makes it ineligible to be a SRFI
> > implementation
> >
> > Is there any chance of dual-licensing it under MIT?
> >
> > On Tue, Nov 5, 2019 at 7:03 PM Zelphir Kaltstahl
> mailto:zelphirkaltst...@posteo.de>>
> > wrote:
> >
> >> This is great! A solid JSON parsing and outputting library is
> important
> >> for a programming language these days! Thanks for your work!
> >>
> >> On 11/5/19 6:00 PM, guile-user-requ...@gnu.org
> <mailto:guile-user-requ...@gnu.org> wrote:
> >>> Message: 1
> >>> Date: Mon, 4 Nov 2019 22:28:12 -0800
> >>> From: Aleix Conchillo Flaqué  <mailto:aconchi...@gmail.com>>
> >>> To: guile-user mailto:guile-user@gnu.org>>
> >>> Subject: [ANN] guile-json 3.3.0 released
> >>> Message-ID:
> >>>       <
> >>
> ca+xasouhwaqapqvpqqg5suermoe9pkydfm57ng679pgsy5e...@mail.gmail.com
> 
> <mailto:ca%2bxasouhwaqapqvpqqg5suermoe9pkydfm57ng679pgsy5e...@mail.gmail.com>>
> >>> Content-Type: text/plain; charset="UTF-8"
> >>>
> >>> Hi,
> >>>
> >>> I'm pleased to announce guile-json 3.3.0. This new version
> comes with a
> >> few
> >>> improvements: guile-json will now throw an exception if the
> native scheme
> >>> value used to build a JSON document is invalid (this is done
> before
> >>> printing any JSON). Also, an additional key argument
> #:validate can be
> >>> given to ignore the validation in the case performance is
> important and
> >> the
> >>> data is known to be valid. Empty JSON array slots are also
> considered
> >>> invalid, before they were generating an invalid scheme
> representation. A
> >>> few more details can be found on the NEWS file.
> >>>
> >>> https://github.com/aconchillo/guile-json
> >>>
> >>> Best,
> >>>
> >>> Aleix
> >>
>


Weird behavior of hash-table

2019-11-23 Thread Zelphir Kaltstahl
Hi Guile Users!

I've noticed a strange behavior of hash tables. I put in symbols as keys
and integers as values, but when I try to get the integers out again by
using the same symbol, I get back a #f instead. Here is the code I am using:


(use-modules
 ;; SRFI 60: procedures for treating integers as bits
 (srfi srfi-60)
 (ice-9 hash-table))


(define SQUARES
  ;; vector, constant time access
  #('A1 'B1 'C1 'D1 'E1 'F1 'G1 'H1
'A2 'B2 'C2 'D2 'E2 'F2 'G2 'H2
'A3 'B3 'C3 'D3 'E3 'F3 'G3 'H3
'A4 'B4 'C4 'D4 'E4 'F4 'G4 'H4
'A5 'B5 'C5 'D5 'E5 'F5 'G5 'H5
'A6 'B6 'C6 'D6 'E6 'F6 'G6 'H6
'A7 'B7 'C7 'D7 'E7 'F7 'G7 'H7
'A8 'B8 'C8 'D8 'E8 'F8 'G8 'H8))


(define square-pos->bit-integer
  (lambda (pos)
(expt 2 pos)))


(define make-squares-to-integer-mapping
  (lambda (squares)
(let* ([num-squares (vector-length squares)]
   [lookup-table (make-hash-table num-squares)])
  (let loop ([square-pos 0])
(cond
 [(< square-pos num-squares)
  #;(display
   (simple-format
#f "setting at key: ~a\n" (vector-ref squares square-pos)))
  (hash-set! lookup-table
 (vector-ref squares square-pos)
 (square-pos->bit-integer square-pos))
  (loop (+ square-pos 1))]
 [else lookup-table])


(define SQUARES-TO-INTEGERS
  (make-squares-to-integer-mapping SQUARES))


(hash-ref SQUARES-TO-INTEGERS 'A1)


Surprisingly, I cannot get out any value of the ones stored in the hash
table. But when I use:

(hash-map->list cons SQUARES-TO-INTEGERS)

I can clearly see, that under the keys I have in SQUARES, are the
numbers stored in the hash table.

Also I use hash-ref, which is supposed to compare using equal?, which
for symbols like 'A1 and 'A1 returns #t, so I think my lookup should work.

Why can I not get the integers out of the hash table?

Regards,

Zelphir




Re: Weird behavior of hash-table

2019-11-24 Thread Zelphir Kaltstahl
Hi Mark!

Thank you, that is the solution and the explanation!

I read my procedures multiple times, wondering whether I am returning
another hash table or anything. It would have taken me a long time
before trying to create the vector without the additional quotes.

Regards,
Zelphir

On 11/24/19 9:04 AM, Mark H Weaver wrote:
> Hi Zelphir,
>
> Zelphir Kaltstahl  writes:
>
>> I've noticed a strange behavior of hash tables. I put in symbols as keys
>> and integers as values, but when I try to get the integers out again by
>> using the same symbol, I get back a #f instead. Here is the code I am using:
>>
>> 
>> (use-modules
>>  ;; SRFI 60: procedures for treating integers as bits
>>  (srfi srfi-60)
>>  (ice-9 hash-table))
>>
>>
>> (define SQUARES
>>   ;; vector, constant time access
>>   #('A1 'B1 'C1 'D1 'E1 'F1 'G1 'H1
>> 'A2 'B2 'C2 'D2 'E2 'F2 'G2 'H2
>> 'A3 'B3 'C3 'D3 'E3 'F3 'G3 'H3
>> 'A4 'B4 'C4 'D4 'E4 'F4 'G4 'H4
>> 'A5 'B5 'C5 'D5 'E5 'F5 'G5 'H5
>> 'A6 'B6 'C6 'D6 'E6 'F6 'G6 'H6
>> 'A7 'B7 'C7 'D7 'E7 'F7 'G7 'H7
>> 'A8 'B8 'C8 'D8 'E8 'F8 'G8 'H8))
> I guess that you meant for this to be a vector of symbols.  In fact, it
> is a vector of lists of the form (quote ), for which '
> is a shorthand.
>
>   scheme@(guile-user)> (vector-ref SQUARES 0)
>   $10 = (quote A1)
>
> To fix the problem, remove all of the apostrophes (') from the elements
> of the vector literal above.  Like list literals, vector literals take
> raw values, not expressions.
>
>> (hash-ref SQUARES-TO-INTEGERS 'A1)
>   scheme@(guile-user)> (hash-ref SQUARES-TO-INTEGERS 'A1)
>   $11 = #f
>   scheme@(guile-user)> (hash-ref SQUARES-TO-INTEGERS ''A1)
>   $12 = 1
>
>Mark



Re: Weird behavior of hash-table

2019-11-24 Thread Zelphir Kaltstahl
Hi Tomas!

On 11/24/19 9:57 AM, to...@tuxteam.de wrote:
> Yikes. I'd fall into this trap, too. Thanks you both for illustrating
> it so well -- and thanks, Mark, for your unfailing sharp vision :-)
>
> So the best thing for one's brain is to train it to read #(...)
> as some weird relative of '(...)?

I guess so, because it is a reader syntax. So it is free to not evaluate
the things in the parentheses.

> Is there a corresponding weird relative of `(...)?
>
> Cheers
> -- tomás

Do you mean a way to write a vector and evaluate only some of the
elements in the vector?

Regards,

Zelphir




Guile fibers return values

2020-01-04 Thread Zelphir Kaltstahl
Hello Guile users!

I have questions regarding the usage of the fibers library. It seems,
that I cannot find any way to get a computation result back from a
fiber. I also cannot find anything about how to get a value back from a
fiber, except for channels. The examples include one example using the
procedure `make-channel`, to create one channel for a client to send to
a server and one channel to use for the server to send messages to the
client.

Are channels the only way to get a computation result back from a fiber?

Should I be creating channels, which the spawned fiber then can use on
its own, to asynchronously give me a result?

This is an aside of my actual project currently. I want to parallelize
some algorithm and want to make use of fibers for that, but in order to
do that, I must understand how to run multiple fibers and get their
results back.

Can you give me an example, where fibers are used to split up a
computation heavy task so that it is sped up, because of running on
multiple cores?

Regards,

Zelphir




Re: Guile fibers return values

2020-01-04 Thread Zelphir Kaltstahl
Hello Guile Users,

so I figured out an example for using channels, but I am not sure, if
that is the only way to get results from a fiber:

8<8<
(use-modules
 (fibers)
 (fibers channels)
 (ice-9 match))

;; Define a procedure to run in a fiber.
(define fiber1-proc
  (lambda (in-chan out-chan)
;; Look for mesages.
(let loop ([received-proc (lambda (data) 'no-proc-received)])
  (match
  ;; Write arguments to the current output port, and return the last
  ;; argument. This will get the message received and write to current
  ;; output port an information, that the get-message procedure was
  ;; called.
  (pk 'fiber1-proc-called-get-message
  (get-message in-chan))
;; Match anything tagged as procedure and store it in the argument for
;; the named let.
[('proc . proc)
 (loop proc)]
;; Match anything labeled as data and apply the stored procedure to
;; it. If no procedure has been received yet, use the default one.
[('data . data)
 (put-message out-chan (received-proc data))
 ;; Loop again with the default procedure, awaiting a new procedure and
 ;; data for it.
 (loop (lambda (data) 'no-proc-received))]
;; Have a default reaction to anything, but the correctly tagged
;; messages.
[any-other-message
 (put-message out-chan 'unrecognized-message)
 ;; Allow for unrecognized messages in between correct communication.
 (loop received-proc)])
  ;; Continue looking for messages.
  (loop received-proc

(run-fibers
 (lambda ()
   (let ((fiber1-in-chan (make-channel))
 (fiber1-out-chan (make-channel)))
 ;; Spawn a fiber to run fiber1-proc, which internally looks for messages on
 ;; its in-channel.
 (spawn-fiber
  (lambda ()
(fiber1-proc fiber1-in-chan fiber1-out-chan)))
 ;; Send a mssage to the fiber.
 (put-message fiber1-in-chan
  ;; Send some tagged data, in this case the procedure to use.
  (cons 'proc
;; A procedure, which checks all things in data for
;; whether they are even numbers and builds a list of
;; the answers.
(lambda (data)
  (let loop ([remaining-data data])
(cond
 [(null? remaining-data) '()]
 [else
  (cons (even? (car remaining-data))
(loop (cdr remaining-data)))])
 ;; Then put the data on the channel.
 (put-message fiber1-in-chan
  (cons 'data '(0 1 2 3 4 5 6 7 8 9)))
 ;; Look for the answer on the out-channel of the fiber.
 (display
  (simple-format
   #f "~a\n" (pk 'main-thread-called-peek
 (get-message fiber1-out-chan

 ;; And then do it again.

 ;; Send a mssage to the fiber.
 (put-message fiber1-in-chan
  ;; Send some tagged data, in this case the procedure to use.
  (cons 'proc
;; A procedure, which checks all things in data for
;; whether they are even numbers and builds a list of
;; the answers.
(lambda (data)
  (let loop ([remaining-data data])
(cond
 [(null? remaining-data) '()]
 [else
  (cons (even? (car remaining-data))
(loop (cdr remaining-data)))])
 ;; Then put the data on the channel.
 (put-message fiber1-in-chan
  (cons 'data '(0 1 2 3 4 5 6 7 8 9)))
 ;; Look for the answer on the out-channel of the fiber.
 (display
  (simple-format
   #f "~a\n" (pk 'main-thread-called-peek
 (get-message fiber1-out-chan)))
>8>8

Is there another way or anything quite wrong in this example?

This way of communication between the fiber and the main process seems
in the style of Racket's places. Except that I can send normal
procedures / lambdas to the fiber, which is great on a single machine,
while I need to send serializable lambdas to Racket places (and I have
not gotten to do that yet).

Is there a restriction on the kind of lambdas I can send on a channel as
I did in the example above?

Regards,
Zelphir

Regards,
Zelphir



Re: Guile fibers return values

2020-01-05 Thread Zelphir Kaltstahl
Thank you for your answer!

I think the example with channels, which I sent later goes in the
direction your are describing : )

Yes, I am not planning on modifying shared state and doing the whole
mutex stuff.

Regards,

Zelphir

On 1/5/20 3:42 AM, John Cowan wrote:
>
>
> On Sat, Jan 4, 2020 at 5:50 PM Zelphir Kaltstahl
> mailto:zelphirkaltst...@posteo.de>> wrote:
>
> I have questions regarding the usage of the fibers library. It seems,
> that I cannot find any way to get a computation result back from a
> fiber. I also cannot find anything about how to get a value back
> from a
> fiber, except for channels.
>
>
> FIbers are much more like coroutines than subroutines: they don't
> return data, they pass it on.  You *can* communicate by mutating
> shared data, but it's asking for trouble because of synchronization
> issues.  Stick to communicating using channels, that's what they are
> for.  Of course if your fiber both sends and receives on channels to
> the same fiber, you risk deadlock if you are not careful to stay
> exactly in sync and avoid output buffering.  Exactly these rules
> apply to shell pipelines, probably the most widespread form of
> concurrency in programming as well as the simplest and most reliable.
>
>
>
> John Cowan          http://vrici.lojban.org/~cowan      
>  co...@ccil.org <mailto:co...@ccil.org>
> Deshil Holles eamus.  Deshil Holles eamus.  Deshil Holles eamus.
> Send us, bright one, light one, Horhorn, quickening, and wombfruit. (3x)
> Hoopsa, boyaboy, hoopsa!  Hoopsa, boyaboy, hoopsa!  Hoopsa, boyaboy,
> hoopsa!
>   --Joyce, Ulysses, "Oxen of the Sun"
>


Re: Guile fibers return values

2020-01-05 Thread Zelphir Kaltstahl
Thank you for the detailed explanation!

By "process" I meant only "sequence of steps performed", the main thunk
in run-fibers, separate from the steps that are run in the spawned
fiber, not really OS process or thread.

I will take a look again at the parallel forms and think about whether I
want to use them or fibers.

Originally I had my algorithm in Racket and could not get it to work in
parallel, unless I explore places and serializable lambdas more.

I think fibers are more flexible than the parallel forms though, as one
could also build a pipeline using fibers or any kind of network of
connected computation tasks, while the parallel forms split a task
immediately and then join again. Not sure any of the additional
flexibility of fibers helps me. Perhaps I can use both and abstract from
it with an additional abstraction layer. Then my code could also be used
more easily in other Schemes.

This is my project:
https://notabug.org/ZelphirKaltstahl/guile-ml/src/wip-port-to-guile

I still am not sure though, if I can simply use any lambda I want and
send that to a fiber, or I need to look out for things like "What is in
the environment of the lambda?". It would be good to know that. I guess
it depends on how data sent on channels is handled in the fibers library.

Regards,

Zelphir

On 1/5/20 1:33 PM, Chris Vine wrote:
> On Sun, 5 Jan 2020 02:30:06 +0100
> Zelphir Kaltstahl  wrote:
> [snip]
>> This way of communication between the fiber and the main process seems
>> in the style of Racket's places. Except that I can send normal
>> procedures / lambdas to the fiber, which is great on a single machine,
>> while I need to send serializable lambdas to Racket places (and I have
>> not gotten to do that yet).
>>
>> Is there a restriction on the kind of lambdas I can send on a channel as
>> I did in the example above?
> I may well be missing your point, mainly because I don't know what you
> mean by "the main process" - all the fibers are part of the same
> process, and can be run in the same native thread if you want.
>
> run-fibers runs what amounts to a scheduler and does not return until
> the thunk passed to it returns.  So if by "the main proccess" you mean
> the thunk which is running on a fiber scheduler, then you know it has
> finished when run-fibers returns, after which you can execute what
> other non-fiber code you want to execute.  run-fibers will return the
> value (if any) returned by the thunk which it runs.
>
> Within the thunk run by run-fibers, you normally synchronize using
> channels. At it's absolute simplest it can be this:
>
>   (display (run-fibers
> (lambda ()
>   (let ((channel (make-channel)))
> (spawn-fiber
>  (lambda ()
>(sleep 1) ;; do some work
>(put-message channel "hello world")))
> (simple-format #t "~a~%" (get-message channel))
> "finished\n"
>
> Here the "main" thunk (the one passed to run-fibers which returns
> "finished\n") will not finish until the fiber thunk has finished,
> because of the wait on the channel.  If you spawn multiple fibers and
> the "main" thunk does not wait for the fibers like this, and you
> therefore need to ensure additionally that run-fibers does not return
> until all the fiber thunks have finished, you can set the drain
> argument of run-fibers to #t.  Probably in that case your "main" thunk
> will not return a meaningful value.
>
> You say you want "to parallelize some algorithm".  If that is your main
> aim, consider guile's parallel forms of parallel, let-par and friends.
>
> Chris
>



Re: Guile fibers return values

2020-01-05 Thread Zelphir Kaltstahl
Hi Chris!

On 1/5/20 3:23 PM, Chris Vine wrote:
> On Sun, 5 Jan 2020 13:58:24 +0100
> Zelphir Kaltstahl  wrote:
>> Thank you for the detailed explanation!
>>
>> By "process" I meant only "sequence of steps performed", the main thunk
>> in run-fibers, separate from the steps that are run in the spawned
>> fiber, not really OS process or thread.
>>
>> I will take a look again at the parallel forms and think about whether I
>> want to use them or fibers.
>>
>> Originally I had my algorithm in Racket and could not get it to work in
>> parallel, unless I explore places and serializable lambdas more.
>>
>> I think fibers are more flexible than the parallel forms though, as one
>> could also build a pipeline using fibers or any kind of network of
>> connected computation tasks, while the parallel forms split a task
>> immediately and then join again. Not sure any of the additional
>> flexibility of fibers helps me. Perhaps I can use both and abstract from
>> it with an additional abstraction layer. Then my code could also be used
>> more easily in other Schemes.
> Fibers are more flexible than guile's parallel forms as you say (of
> course, if you have your own thread pool available that can also be
> more flexible than the parallel forms), but fibers' main other feature
> is that they will multi-plex i/o operations on the same native thread
> using guile's suspendable ports and coroutines.  Any one native OS
> thread run by the fibers' scheduler may therefore have more than one
> coroutine running on it.  So, beware having blocking operations when
> using fibers, because between fibers running on the same native OS
> thread, concurrency is co-operative - coroutine task switching occurs on
> a port suspending or the fiber yielding, although there is some work
> stealing implemented between OS threads which will help you out.  (From
> the blocking point of view, do not use the simple-format procedure as in
> my toy example because it is not suspendable-port-safe.)
>
> If your work is i/o-bound rather than cpu-bound, fibers are likely to be
> especially useful.


I think the decision tree calculations, which I want to parallelize, are
not I/O related. However, I am not quite sure I understand the whole
suspendable port thing, but here is what I think it is:

When some I/O happens in a fiber, the fiber is still able to pause
(suspend, yield, …) at that point, because the suspendable ports work in
such a way, that no harm is done in doing so. Later the I/O work can be
resumed (woken up from suspension). This quality had to be built into
Guile first, before fibers were able to take advantage of it.

Is this correct?

But I do not understand, why this is not the case with normal OS
threads. Maybe it can be done but is not convenient or difficult to get
right, to work with suspendable ports, when not using the fibers library?

And why is simple-format not "suspendable-port-safe"? (What does a
procedure need to do, in order to be "suspendable-port-safe"?)


>> This is my project:
>> https://notabug.org/ZelphirKaltstahl/guile-ml/src/wip-port-to-guile
>>
>> I still am not sure though, if I can simply use any lambda I want and
>> send that to a fiber, or I need to look out for things like "What is in
>> the environment of the lambda?". It would be good to know that. I guess
>> it depends on how data sent on channels is handled in the fibers library.
> The lambda closures passed to run-fibers and spawn-fiber are like any
> other lambda closure.  In particular, beware of closures with shared
> mutable state.  Apart from that you should be fine as regards closures
> but I am not convinced that I sufficiently understand your use case to
> comment further.  On data sent through channels, I haven't looked at it
> but I have always assumed that objects such as lists, vectors, records
> and so forth which are passed through channels are passed by reference
> in the ordinary way, so don't mutate them after putting them in a
> channel if more than one fiber may subsequently have them in use
> concurrently.  The purpose of channels is to provide safe
> synchronization.


Good advice, thanks. I was not planning to do mutation on the things
received from channels in a fiber, but it is good to remember, that it
might be problematic to do so, even with vectors or structs. So I better
create new structs or vectors, when creating a return message.

With the parallel forms, isn't it the case, that at each call of such a
form, new OS threads are created? In this case it might be a good idea
to create a fibers scheduler and reuse it, if that is possible, so that
I do not need to create my own process pool kind of thingy.

Regards,

Zelphir




Re: Guile fibers return values

2020-01-06 Thread Zelphir Kaltstahl
Hey Chris!

Thanks for your informative reply! I did not remember, that the parallel
forms are already that clever. It might be the case, that I only need to
use futures or parallel forms then. I have a question regarding futures
though.

In Racket the futures have some limitations, where one needs to use a
different number type to enable them in some cases to run in parallel –
wait, I am looking for the link … here:
https://docs.racket-lang.org/guide/parallelism.html – Is there any
similar restriction for futures in Guile?

Regards,

Zelphir

On 1/5/20 10:45 PM, Chris Vine wrote:
> On Sun, 5 Jan 2020 19:22:14 +0100
> Zelphir Kaltstahl  wrote:
>> I think the decision tree calculations, which I want to parallelize, are
>> not I/O related. However, I am not quite sure I understand the whole
>> suspendable port thing, but here is what I think it is:
>>
>> When some I/O happens in a fiber, the fiber is still able to pause
>> (suspend, yield, …) at that point, because the suspendable ports work in
>> such a way, that no harm is done in doing so. Later the I/O work can be
>> resumed (woken up from suspension). This quality had to be built into
>> Guile first, before fibers were able to take advantage of it.
>>
>> Is this correct?
> Yes, suspendable ports were first implemented in guile-2.2.  They are
> used by 8-sync (https://www.gnu.org/software/8sync/), guile-a-sync2
> (https://github.com/ChrisVine/guile-a-sync2/wiki) and fibers, and
> possibly by other libraries.
>
> The basic arrangement is that if a port's file descriptor is not ready,
> then its continuation is saved, and is resumed by the scheduler when it
> becomes ready.  fibers use epoll rather than POSIX select or poll for
> this.
>
>> But I do not understand, why this is not the case with normal OS
>> threads. Maybe it can be done but is not convenient or difficult to get
>> right, to work with suspendable ports, when not using the fibers library?
>>
>> And why is simple-format not "suspendable-port-safe"? (What does a
>> procedure need to do, in order to be "suspendable-port-safe"?)
> simple-format does not suspend as it is implemented in C in libguile and
> its continuation is not available to scheme code.  There is a
> list of those of guile's i/o procedures which do (and which do not)
> suspend here, in the second and third paragraphs, although it does not
> mention format/simple-format:
> https://github.com/ChrisVine/guile-a-sync2/wiki/await-ports
> (That library has nothing to do with fibers, but as mentioned above it
> happens to use suspendable ports for similar purposes): 
>
> None of this is likely to be relevant to your use case.
>
> [snip]
>> With the parallel forms, isn't it the case, that at each call of such a
>> form, new OS threads are created? In this case it might be a good idea
>> to create a fibers scheduler and reuse it, if that is possible, so that
>> I do not need to create my own process pool kind of thingy.
> guile's parallel forms are implemented using futures, which use an
> internal thread pool according to this:
> https://www.gnu.org/software/guile/docs/master/guile.html/Futures.html#Futures
>
> "Internally, a fixed-size pool of threads is used to evaluate futures,
> such that offloading the evaluation of an expression to another thread
> doesn’t incur thread creation costs. By default, the pool contains one
> thread per available CPU core, minus one, to account for the main
> thread."
>
> Chris



Re: Guile fibers return values

2020-01-06 Thread Zelphir Kaltstahl
Hello John!

Thanks for your reply!

On 06.01.2020 22:47, John Cowan wrote:
> Conceptually, parallelism and concurrency are two different and partly
> independent things.  Parallelism refers to physically simultaneous
> execution, as when you throw a ball into the air in each hand and
> catch it in the same hand.  Each throw-catch cycle is a parallel
> process (using "process" in the broad sense of the term). 
> Concurrency, on the other hand, is *logically* simultaneous execution,
> as when you juggle three balls in one or two hands.  Now the
> throw-catch cycle of each ball from one hand to the other is a
> concurrent process, and it is also a parallel process if you use two
> hands.  If you are using one hand, however, there is no parallelism in
> juggling.

Yes, that is pretty clear. Parallelism and concurrency are not the same,
I know that. One could also say, that one can have concurrent execution
on a single core, even multiple processes, but cannot have parallel
execution on that single core. With concurrency, even on one core, one
needs to look out for many things like concurrent updates or mutating
state, as one, in the general case, does not know when one process will
be running and when the other.

> To make matters more confusing, "futures" in Racket are for
> parallelism, whereas in Guile they are for concurrency.  Guile
> "parallel" and friends are executed on futures (which are executed on
> OS threads), but use at most as many futures as there are CPUs, so
> physically simultaneous execution is at least encouraged if not
> actually guaranteed.

I think that is a typo maybe? The futures guide says:

"The (ice-9 futures) module provides futures, a construct for fine-grain
parallelism."

Otherwise that would indeed be very confusing. Or do you say this,
because on a single core machine, there would be no parallelism and thus
one cannot say, that Guile's futures will enable parallelism in general,
but can say, that they in general enable concurrency?

> Racket parallelism only operates until one of the parallel processes
> blocks or needs to synchronize (which includes things like allocating
> memory): they are not implemented on top of Racket threads, which are
> for concurrency (and have nothing to do with OS threads). 

Yes, as far as I understand, Racket threads are so called "green
threads" (like in Python). To use multiple cores in the general case,
one needs to make use of Racket's "places" instead, which are additional
Racket VMs running.

> A Scheme promise can be viewed as a type of parallel process that
> doesn't actually provide parallelism (and in fact my parallel pre-SRFI
> is called "parallel promises" and treats ordinary promises as a
> degenerate case) or as a future that doesn't start to execute until
> you wait for it to finish (and my futures pre-SRFI also treats
> promises as a degenerate case).

I think of "promises" as something that enables asynchronous execution.
Don't beat me for this: "Just like in JavaScript" basically :D I don't
know, if that notion is wrong in the Scheme context though. So far I
found the following approaches to do things in parallel in GNU Guile:

1. futures
2. parallel forms (built on futures, probably "just" convenience)
3. fibers library

I have not considered to look for "promises" yet, as I did not think
them to be a parallelism construct or concept. However, you are
mentioning them. Does that mean, that I should look into them as well or
is it rather a general explanation to get the concepts cleanly
separated? It seems not like they could parallelize any algorithm. At
least not, if they share the character of JavaScript promises.

And hello Chris!

I have just checked, whether futures run in parallel for the example of
the Racket docs and they seem to run in parallel, although the CPU is
not 100% busy, probably because of other factors, like allocations:

8<8<
(use-modules
 (ice-9 futures)
 ;; SRFI 19 for time related procedures
 (srfi srfi-19))


;; Just defining a timing macro here to conveniently measure elapsed time of
;; evaluating expressions.
(define-syntax time
  (syntax-rules ()
[(time expr expr* ...)
 (begin
   (define start-time (current-time time-monotonic))
   expr
   expr* ...
   (define end-time (current-time time-monotonic))
   (let* ([diff (time-difference end-time start-time)]
  [elapsed-ns (+ (/ (time-nanosecond diff) 1e9)
 (time-second diff))])
 (display (format #t "~fs~%" elapsed-ns]))


(define (mandelbrot iterations x y n)
  (let ([ci (- (/ (* 2.0 y) n) 1.0)]
[cr (- (/ (* 2.0 x) n) 1.5)])
(let loop ([i 0] [zr 0.0] [zi 0.0])
  (if (> i iterations)
  i
  (let ([zrq (* zr zr)]
[ziq (* zi zi)])
(cond
  [(> (+ zrq ziq) 4.0) i]
  [else (loop (+ i 1)
  (+ (- zrq ziq) cr)
  (+ (* 2.0 zr zi) ci)

Limiting parallelism using futures, parallel forms and fibers

2020-01-07 Thread Zelphir Kaltstahl
Hello Guile users!

I thought about what I need for parallelizing an algorithm I am working
on. Background: I am working on my decision tree implementation
(https://notabug.org/ZelphirKaltstahl/guile-ml/src/wip-port-to-guile),
which is currently only using a single core. Training the model splits
the tree into subtrees, which is an opportunity for running things in
parallel. Subtrees can subsequently split again and that could again
result in a parallel evaluation of the subtrees.

Since it might not always be desired to use potentially all available
cores (blocking the whole CPU), I would like to add the possibility for
the user of the algorithm to limit the number of cores used by the
algorithm, most likely using a keyword argument, which defaults to the
number of cores. Looking at futures, parallel forms and the fibers
library, I've had the following thoughts:

1. fibers support a ~#:parallelism~ keyword and thus the number of
fibers running in parallel can be set for ~run-fibers~, which creates a
scheduler, which might be used later, possibly avoiding to keep track of
how many threads are being used. It would probably be important when
using fibers, to always make use of the same scheduler, as a new
scheduler might not know anything about other schedulers and the limit
for parallelism might be overstepped. Schedulers, which are controlled
by the initial scheduler are probably OK. I will need to re-read the
fibers manual on that.

2. With parallel forms, there are ~n-par-map~ and ~n-par-for-each~,
where one can specify the maximum number of threads running in parallel.
However, when recursively calling these procedures (in my case
processing subtrees of a decision tree, which might split into subtrees
again), one does not have the knowledge of whether the processing of the
other recursive calls has finished and cannot know, how many other
threads are being used currently. Calling one of these procedures again
might run more threads than specified on a upper level call.

3. With futures, one cannot specify the number of futures to run at
maximum directly. In order to control how many threads are evaluating
code at the same time, one would have to build some kind of construct
around them, which keeps track of how many futures are running or could
be running and make that work for recursive creation of further futures
as well.

4. One could also do something ugly and create a globally defined active
thread counter, which requires locking, to keep track of the number of
in parallel running threads or futures.

5. I could just assume the maximum number of currently used cores, by
giving the tree depth as argument for recursive calls and calculating
from that, how many splits and thus evaluations might be running in
parallel at that point. However, this might be inaccurate, as some
subtree might already be finished and then I would not use the maximum
user specified number of parallel evaluations.

So my questions are:

- Is there a default / recommended way to limit parallelism for
recursive calls to parallel forms?

- Is there a better way than a global counter with locking, to limit the
number of futures created during recursive calls? I would dislike very
much to have to do something like global state + mutex.

- What do you recommend in general to solve this?

Regards,
Zelphir




Re: SRFI-151 (Bitwise Operations) Implementation

2020-01-08 Thread Zelphir Kaltstahl
Hello Frank,

I think I might find good use for this library in one of my projects!
Thanks for sharing!

Regards,
Zelphir

On 09.01.2020 05:28, Frank Terbeck wrote:
> Hey Guilers!
>
> Since I got  a project that uses (potentially large)  integers to encode
> bits in registers,  I was looking at  SRFIs that deal with  that type of
> domain. The most recent entry is SRFI-151, which is in final status.
>
> Since Guile currently doesn't have an implementation of this SRFI, I fi-
> gured I might as well add one.
>
> I tried to reuse as many facilities  that are already in Guile to get to
> a complete implementation. So it reuses  stuff from the R6RS bitwise li-
> brary, as well as SRFI-60 (which is titled “Integers as Bits”) and other
> functions from Guile's core.
>
> SRFI-151 has one  API that returns a SRFI-121 generator¹  to traverse an
> integer. Since Guile currently  doesn't have a SRFI-121 implementation²,
> this function³ is missing from this implementation.
>
> The implementation can be found here: https://gitlab.com/ft/srfi-151
>
> The test-suite  reproduces the examples  from the specification,  plus a
> couple of additional ones.  Maybe this is useful for someone.
>
>
> Regards, Frank
>
> ¹ http://srfi.schemers.org/srfi-121/srfi-121.html
> ² https://www.mail-archive.com/guile-devel@gnu.org/msg14950.html
> ³ make-bitwise-generator
>




Re: Limiting parallelism using futures, parallel forms and fibers

2020-01-09 Thread Zelphir Kaltstahl
Thanks for your suggestion, I will take it into account.

Regards,

Zelphir

On 1/8/20 9:11 AM, Linus Björnstam wrote:
> Hi! 
>
> I don't have much more input than to say that futures use a built in thread 
> pool that is limited to (current-processor-count) threads. That could maybe 
> be modified using setaffinity ?
>
> Hope this helps.
>



Re: Limiting parallelism using futures, parallel forms and fibers

2020-01-09 Thread Zelphir Kaltstahl
Hi Chris!

On 1/8/20 12:44 PM, Chris Vine wrote:
> On Wed, 8 Jan 2020 08:56:11 +0100
> Zelphir Kaltstahl  wrote:
> [snip]
>> So my questions are:
>>
>> - Is there a default / recommended way to limit parallelism for
>> recursive calls to parallel forms?
>>
>> - Is there a better way than a global counter with locking, to limit the
>> number of futures created during recursive calls? I would dislike very
>> much to have to do something like global state + mutex.
>>
>> - What do you recommend in general to solve this?
> I think you have it wrong, and that futures use a global queue and a
> global set of worker threads.  I don't see how futures could work
> without at least a global set of worker threads.  Have a look at the
> futures source code.

So far I did not write any parallel code in my project. I am only
exploring possibilities, finding out what I should be using. I also
could not think of a good way to limit the number of threads to anything
less than the (current-processor-count) value, but thought maybe someone
knows something I did not see or read about Guile's futures yet : )

> If you want more control over the thread pool than guile's futures
> provide, you could consider something like this:
> https://github.com/ChrisVine/guile-a-sync2/blob/master/a-sync/thread-pool.scm
> But then you would have to make your own futures if you want a graph
> of futures rather than a graph of coroutines (which is what you would
> get if you use the associated event loop).

This seems like a lot of code for the purpose of being able to limit the
maximum number of threads running at the same time. (Perhaps it is
necessary?)

I would not like to create some kind of futures alternative and whatever
else I would have to do. I am not even sure what "making my own futures"
would entail.

Perhaps I can create something like a thread pool using a reused fibers
scheduler, which I give the chosen limit in the #:parallelism keyword
argument. It spawns only as many fibers at the same time, as are
allowed, if that is possible (some kind of loop inside (run-fibers …)?)
Whenever one spawned fiber finishes, it checks, if there is more work
available (on some channel?) and put that work in a new spawned fiber.
If I squint at the fibers library, it almost looks like a thread pool
should be not too difficult to implement using the library, but maybe I
am wrong about this and there is some fundamental difficulty.

> The main thing is to get the parallel algorithm right, which can be
> tricky.

In my decision tree the fitting of the tree is purely functional code so
far (as far as I know). If I can only find a way to limit the
parallelism as I want to, I should be able to simply spawn some kind of
unit of evaluation for each subtree recursively. Usually decision trees
should not be too deep, as they tend to easily overfit, so I think the
overhead would not be too much for spawning a unit of parallel evaluation.

In the end, if it turns out to be too difficult to limit the maximum
number of threads running in parallel, I might choose to discard the
idea and instead use all available cores, depending on the tree depth
and number of cores.


Initially I had 2 reasons for porting the whole program to GNU Guile:

1. I had difficulties using places in Racket, as I could not send normal
lambdas to other places. This means I would have to predefine the
procedures, instead of sending them on channels or I would have to use
serializable-lambdas, which someone told me they did not manage to use
for channels and then later someone on the Racket user list told me they
can be used for sending over channels. I had already started creating a
thread pool, but this whole serializable-lambda thing stopped me from
finishing that project and it is a half-finished thing, waiting to be
completed some day by anyone. Guile in comparison seems to have easier
to use ways of achieving multicore usage.

2. I am using Guile more than Racket now and wanted my own code to be
available there. Possibly develop more machine learning algorithms in
Guile, getting the basics available.

Then, during porting the code, I found more reasons for going on with
porting:

* I used many Racketisms, which are not available in Scheme dialects. My
code would only ever work on Racket.
* I separated out many modules, which in the Racket code were all in one
big file.
* I added tests for some new procedures and some separated modules.
* I refactored some parts, made some display procedures testable with
optional output port arguments.

Regards,
Zelphir




Re: Re: Limiting parallelism using futures, parallel forms and, fibers (Chris Vine)

2020-01-11 Thread Zelphir Kaltstahl


On 1/10/20 6:00 PM, guile-user-requ...@gnu.org wrote:
> Message: 1
> Date: Fri, 10 Jan 2020 16:08:25 +
> From: Chris Vine 
> To: Zelphir Kaltstahl 
> Cc: Guile User 
> Subject: Re: Limiting parallelism using futures, parallel forms and
>   fibers
> Message-ID: <20200110160825.ed165619cb590b8755d94...@gmail.com>
> Content-Type: text/plain; charset=US-ASCII
>
> On Fri, 10 Jan 2020 01:43:18 +0100
> Zelphir Kaltstahl  wrote:
>> Hi Chris!
>>
>> On 1/8/20 12:44 PM, Chris Vine wrote:
>>> On Wed, 8 Jan 2020 08:56:11 +0100
>>> Zelphir Kaltstahl  wrote:
>>> [snip]
>>>> So my questions are:
>>>>
>>>> - Is there a default / recommended way to limit parallelism for
>>>> recursive calls to parallel forms?
>>>>
>>>> - Is there a better way than a global counter with locking, to limit the
>>>> number of futures created during recursive calls? I would dislike very
>>>> much to have to do something like global state + mutex.
>>>>
>>>> - What do you recommend in general to solve this?
>>> I think you have it wrong, and that futures use a global queue and a
>>> global set of worker threads.  I don't see how futures could work
>>> without at least a global set of worker threads.  Have a look at the
>>> futures source code.
>> So far I did not write any parallel code in my project. I am only
>> exploring possibilities, finding out what I should be using. I also
>> could not think of a good way to limit the number of threads to anything
>> less than the (current-processor-count) value, but thought maybe someone
>> knows something I did not see or read about Guile's futures yet : )
> I still don't understand why you think you want to do that, given the
> aims you set out in your earlier posts.  Why do you want to spawn less
> than (processor-count - 1) threads for your algorithm, which is what
> futures would use?
>
> But if you really want to do that, and you don't want to use a
> stand-alone thread pool, the parallelism keyword of fibers seems to do
> what you want.


Hi Chris!

Yes, it might not be so clear a reason. At the beginning of implementing
the algorithm I looked at the Scikit-learn interface for decision trees
and implemented the functionality for the keyword arguments, which that
interface provides. They also offer a keyword for many models, which
allows you to set the number of threads. I think they call it "jobs",
"tasks", "n_jobs" or "n_tasks" or something like that. The reason why I
think this is useful is the following:

If you are running a training phase for a model of a lot of data, this
can take a while. You might want to still be able to use your machine
for other purposes, while the model is being trained / fitted to the
data. However, if I go for maximum parallelism in my algorithm, then it
could easily happen, that all cores are busy. That would impact the
ability to do other things, while the algorithm is running. I would like
the user to be able to make a decision about how many cores they want to
use for the algorithm. This is wishful thinking, but maybe it can be
done and I don't want to abandon the idea too early. Perhaps I will
abandon it later, if it becomes too difficult to do for me.

With the fibers keyword argument #:parallelism, the only thing I am not
sure about is the following: Whether the number of threads is guaranteed
to be at maximum the specified number, if in your fibers, you create a
new schedule using (run-fibers …) and spawn new fibers in there. This
would be the case with my recursive algorithm for the decision tree.
With parallel forms or simple futures it seems to be the case, that more
threads would be used, when recursively creating more expressions to
evaluate in parallel.

Thanks for linking to your async thread pool implementation. It is not
out of the question, that it is actually the solution for the problem.

Currently I am trying to build a simple thread pool using the
#:parallelism keyword argument of (run-fibers …). What I imagine there
is the following:

There is one call to (run-fibers …), which specifies the #:parallelism
keyword and then inside the lambda given to run-fibers, I need to spawn
all fibers, which shall perform the actual work, so that they are
limited by the parallelism of that scheduler. To do that, I imagine,
that I can have an input and output channel for the scheduler to receive
work on and give back results, which it got from fibers, which it
spawned. For any work received, a new fiber is spawned, which shall
perform the work. The fibers library, as far as I know, handles work
stealing between the fibers of one scheduler and the parallelism keyword
would make sure only so many c

Re: Pure (side-effect-free) calls into c/c++?

2020-01-11 Thread Zelphir Kaltstahl
Hello Linas,

On 1/10/20 11:36 PM, Linas Vepstas wrote:
> So, I've got lots of C code wrapped up in guile, and I'd like to declare
> many of these functions to be pure functions, side-effect-free, thus
> hopefully garnering some optimizations.  Is this possible? How would I do
> it? A cursory google-search reveals no clues.
>
> To recap, I've got functions f and g that call into c++, but are pure (i.e.
> always return the same value for the same arguments).   I've got
> user-written code that looks like this:
>
> (define (foo x)
> (g  (f 42) (f x) (f 43))
>
> and from what I can tell, `f` is getting called three times whenever the
> user calls `foo`. I could tell the user to re-write their code to cache,
> manually: viz:
>
> (define c42 (f 42))
> (define c43 (f 43))
> (define (foo x) (g c42 (f x) c43))
>
> but asking the users to do this is .. cumbersome.  And barely worth it: `f`
> takes under maybe 10 microseconds to run; so most simple-minded caching
> stunts don't pay off. But since `foo` is called millions/billions of times,
> I'm motivated to find something spiffy.
>
> Ideas? suggestions?
>
> -- Linas

I don't know exactly how to do it, but in theory, you could provide the
user a macro, which looks for calls of `f` and makes it so, that these
calls are only done once. My macro skills are not so great yet, so I
don't know how to do that. I am just thinking, that in theory this
should be possible, perhaps with a simplified case, that assumes, that
the user does not redefine `f` inside the expression given to the macro.

Just outputting the idea, not sure it is a good idea.

Regards,

Zelphir




Re: GNU Guile 2.9.9 Released [beta]

2020-01-13 Thread Zelphir Kaltstahl
I am already super excited about Guile 3.0.0 and JIT.

I've not had to complain about Guile's speed so far and there are
low-level things like using integers as bits to enable high performance
things, but hey, if simply by upgrading to a new version most Guile
programs run faster, that's great!

I've also steadily discovered new corners of the language as in: "Oh
there already is a library for that!" (for example fibers library or
futures and parallel forms) or "Oh wow, I can go so low-level with that
and still have high level language features and abstractions!" (for
example with using integers as bits, for my attempt of writing a chess
engine) or "Ah, that's how I should use it!" (for example with R6RS
exception handling (conditions)). So I am looking forward to learning
more about Guile and see it being used in more scenarios in the future.

Thanks for keeping up the good work and thanks for everyone contributing
to the Guile ecosystem,
Zelphir

On 1/13/20 9:39 AM, Andy Wingo wrote:
> We are pleased to announce GNU Guile release 2.9.9.  This is the ninfth
> and probably final pre-release of what will eventually become the 3.0
> release series.
>
> Compared to the current stable series (2.2.x), the future Guile 3.0 adds
> support for just-in-time native code generation, speeding up all Guile
> programs.  See the NEWS extract at the end of the mail for full details.
>
> Compared to the previous prerelease (2.9.7), Guile 2.9.8 fixes a number
> of bugs.
>
> The current plan is to make a 3.0.0 final release on 17 January 2020.
> If there's nothing wrong with this prerelease, 3.0.0 will be essentially
> identical to 2.9.9.  With that in mind, please test and make sure the
> release works on your platform!  Please send any build reports (success
> or failure) to guile-de...@gnu.org, along with platform details.  You
> can file a bug by sending mail to bug-gu...@gnu.org.
>
> The Guile web page is located at http://gnu.org/software/guile/, and
> among other things, it contains a copy of the Guile manual and pointers
> to more resources.
>
> Guile is an implementation of the Scheme programming language, packaged
> for use in a wide variety of environments.  In addition to implementing
> the R5RS, R6RS, and R7RS Scheme standards, Guile includes a module
> system, full access to POSIX system calls, networking support, multiple
> threads, dynamic linking, a foreign function call interface, powerful
> string processing, and HTTP client and server implementations.
>
> Guile can run interactively, as a script interpreter, and as a Scheme
> compiler to VM bytecode.  It is also packaged as a library so that
> applications can easily incorporate a complete Scheme interpreter/VM.
> An application can use Guile as an extension language, a clean and
> powerful configuration language, or as multi-purpose "glue" to connect
> primitives provided by the application.  It is easy to call Scheme code
> From C code and vice versa.  Applications can add new functions, data
> types, control structures, and even syntax to Guile, to create a
> domain-specific language tailored to the task at hand.
>
> Guile 2.9.9 can be installed in parallel with Guile 2.2.x; see
> http://www.gnu.org/software/guile/manual/html_node/Parallel-Installations.html.
>
> A more detailed NEWS summary follows these details on how to get the
> Guile sources.
>
> Here are the compressed sources:
>   http://alpha.gnu.org/gnu/guile/guile-2.9.9.tar.lz   (10MB)
>   http://alpha.gnu.org/gnu/guile/guile-2.9.9.tar.xz   (12MB)
>   http://alpha.gnu.org/gnu/guile/guile-2.9.9.tar.gz   (21MB)
>
> Here are the GPG detached signatures[*]:
>   http://alpha.gnu.org/gnu/guile/guile-2.9.9.tar.lz.sig
>   http://alpha.gnu.org/gnu/guile/guile-2.9.9.tar.xz.sig
>   http://alpha.gnu.org/gnu/guile/guile-2.9.9.tar.gz.sig
>
> Use a mirror for higher download bandwidth:
>   http://www.gnu.org/order/ftp.html
>
> Here are the SHA256 checksums:
>
>   59f136e5db36eba070cc5e68784e632dc2beae4b21fd6c7c8ed2c598cc992efc  
> guile-2.9.9.tar.lz
>   bf71920cfa23e59fc6257bee84ef4dfeccf4f03e96bb8205592e09f9dbff2969  
> guile-2.9.9.tar.xz
>   eafe394cf99d9dd1ab837e6d1b9b2b8d9f0cd13bc34e64ca92456ce1bc2b1925  
> guile-2.9.9.tar.gz
>
> [*] Use a .sig file to verify that the corresponding file (without the
> .sig suffix) is intact.  First, be sure to download both the .sig file
> and the corresponding tarball.  Then, run a command like this:
>
>   gpg --verify guile-2.9.9.tar.gz.sig
>
> If that command fails because you don't have the required public key,
> then run this command to import it:
>
>   gpg --keyserver keys.gnupg.net --recv-keys 
> 4FD4D288D445934E0A14F9A5A8803732E4436885
>
> and rerun the 'gpg --verify' command.
>
> This release was bootstrapped with the following tools:
>   Autoconf 2.69
>   Automake 1.16.1
>   Libtool 2.4.6
>   Gnulib v0.1-1157-gb03f418
>   Makeinfo 6.7
>
> An extract from NEWS follows.
>
>
> Changes since alpha 2.9.8 (since 2.9.7):
>
> * Notable changes
>
> ** `define-module' #

Logging in Guile

2020-01-13 Thread Zelphir Kaltstahl
Hi Guile Users!

Is there any library for logging in Guile?

What I imagine is something, where I can log messages of various levels,
like debug, info, error and such. Currently I am using display and
simple-format for all the things, but it would be nice to be able to run
a program and give it some log level, so that only the log messages of
that level or above in importance are shown. Then I could leave all my
logging in my code and set it to debug level or, if intended to be seen
for the user, set it to info level, or if there really is an error, I
could set it to error level.

On a quick search I could not find anything.

Regards,
Zelphir




Bug in Guile 2.2.6 parallel forms implementation?

2020-01-14 Thread Zelphir Kaltstahl
Hi Guile Users!

For my project of implementing a decision tree algorithm, which I ported
to Guile, I am trying ways of parallelizing the algorithm. Since I did
not make use of mutation or global state in the algorithm, it should be
fairly simple to parallelize: "Simply split execution into 2 parts at
every split of the tree and let those run on different cores." – That's
at least the theory. I am using Guile 2.2.6, installed via Guix package
manager.

However, I think there might be a bug in Guile's implementation of the
parallel forms. There is still a small chance, that somehow the bug is
in my code and I overlooked something, that would only matter in a
concurrent or parallel scenario.

The commit id is:
https://notabug.org/ZelphirKaltstahl/guile-ml/src/d61a9535508264dd065760b20caa25a820ed00be

I wrote a more detailed bug report in my todo file:
https://notabug.org/ZelphirKaltstahl/guile-ml/src/d61a9535508264dd065760b20caa25a820ed00be/todo.org
(view the non-rendered version, notabug does not render org files correctly)

Here is why I am saying that there might be a bug in the parallel forms
somewhere:

* When I run the algorithm without concurrency or parallelism, no error
happens. Especially all procedures receive correct types of arguments
and run without problem.
* As stated, I took care to not use mutation anywhere. I am not aware of
any mutation in my code. I think almost, if not all, participating
procedures have referential transparency.
* The bug only happens sometimes and only when using parallel forms. (I
have yet to try fibers and futures.)
* The project has passing tests, which include fitting the decision
tree. Although they do not use the same data set, the structure of the
data is the same. No "wrong type" errors happen. The tests do not yet
cover every single procedure, but the most important once, I think.
* Once the parallel forms are involved, I get the following errors
seemingly at random, perhaps approximately every 10th run of the very
same script, which makes use of the algorithm. I seemingly get them more
often when running on my core 2 duo machine than on my Lenovo Thinkpad
X200, which has 2 cores. I can sometimes run the algorithm 5-10 times
without error and then the next time I run it, an error will happen:

8<8<
scheme@(guile-user)> (define tree
  (fit #:train-data (shuffle-dataset banking-dataset #:seed 12345)
   #:feature-column-indices (list 0 1 2 3)
   #:label-column-index 4
   #:max-depth 5
   #:min-data-points 12
   #:min-data-points-ratio 0.02
   #:min-impurity-split (expt 10 -7)
   #:stop-at-no-impurity-improvement #t))
recursive split on depth: 1
will check for stop conditions now
checking for stop condition: max-depth-reached?
checking for stop condition: insufficient-data-points-for-split?
checking for stop condition: insufficient-data-points-ratio-for-split?
checking for stop condition: all-same-label?
INFO: CONTINUING SPLITT: still got 1372 data points
ice-9/threads.scm:289:22: In procedure loop:
In procedure <: Wrong type argument in position 1: 0.39142673091293256

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
>8>8

This never happens when not running concurrently and also does not
happen on every run. Also I think floats are OK for `<` to handle. I am
using my own procedures with correct arguments. Somehow Guile gets confused.

Here is another one:

8<8<
scheme@(guile-user)> (define tree
  (fit #:train-data (shuffle-dataset banking-dataset #:seed 12345)
   #:feature-column-indices (list 0 1 2 3)
   #:label-column-index 4
   #:max-depth 5
   #:min-data-points 12
   #:min-data-points-ratio 0.02
   #:min-impurity-split (expt 10 -7)
   #:stop-at-no-impurity-improvement #t))
recursive split on depth: 1
will check for stop conditions now
checking for stop condition: max-depth-reached?
checking for stop condition: insufficient-data-points-for-split?
checking for stop condition: insufficient-data-points-ratio-for-split?
checking for stop condition: all-same-label?
INFO: CONTINUING SPLITT: still got 1372 data points
ice-9/threads.scm:289:22: In procedure loop:
In procedure <: Wrong type argument in position 1: 0.39142673091293256

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt
In current input:
161:2  3 (_)
In decision-tree.scm:
   218:18  2 (recursive-split (#(-2.7028 1.6327 0.83598 -0.091393 1) #(-1.3931 
1.5664 7.5382 0.78403 0) #(-5.4414 7.2363 0.10938 -7.5642 1) #(-2.7908 -5.7133 
5.953 0.45946 1) #(-3.518 2.8763 0.1548 # 1) # …) …)
   110:13  1 (get-best-split _ _ _ #:split-quality-proc _)
In ice-9/threads.scm:
   289:22  0 (loop _)
scheme@(guile-user) [1]>
>8>8

It even claims that I cannot use `<` with a floating point number, which
is weird, I think:

In procedure <: Wrong type argument in position 1: 0.39142673091293256

And 

Re: Logging in Guile

2020-01-14 Thread Zelphir Kaltstahl
Hi Alex!

Thanks for the hint, I forgot about checking whether there is something
in guile-lib.

I will have a look.

Regards,
Zelphir

On 1/13/20 7:17 PM, Alex Sassmannshausen wrote:
> Hi Zelphir,
>
> Zelphir Kaltstahl  writes:
>
>> Is there any library for logging in Guile?
> Guile-Lib contains a set of logging modules.
>
> Have a search for guile-lib in guix, and then check the manual.
>
> HTH,
>
> Alex
>
>
>



Re: Logging in Guile

2020-01-14 Thread Zelphir Kaltstahl
Thanks, I will also take a look at that!

On 1/13/20 7:47 PM, John Cowan wrote:
> I have a rough proposal now at
> <https://bitbucket.org/cowan/r7rs-wg1-infra/src/default/SyslogCowan.md>. 
> It depends on either being able to send TCP or UDP packets or
> preferably to call the Posix API through the FFI.  It is very basic
> and leaves log rotation etc. to the syslog infrastructure.
>
> On Mon, Jan 13, 2020 at 1:10 PM Zelphir Kaltstahl
> mailto:zelphirkaltst...@posteo.de>> wrote:
>
> Hi Guile Users!
>
> Is there any library for logging in Guile?
>
> What I imagine is something, where I can log messages of various
> levels,
> like debug, info, error and such. Currently I am using display and
> simple-format for all the things, but it would be nice to be able
> to run
> a program and give it some log level, so that only the log messages of
> that level or above in importance are shown. Then I could leave all my
> logging in my code and set it to debug level or, if intended to be
> seen
> for the user, set it to info level, or if there really is an error, I
> could set it to error level.
>
> On a quick search I could not find anything.
>
> Regards,
> Zelphir
>
>


Re: Logging in Guile

2020-01-14 Thread Zelphir Kaltstahl
Hi Roel,

A simple short code is always tempting, thanks. I will check it out!

Regards,
Zelphir

On 1/13/20 10:42 PM, Roel Janssen wrote:
> On Mon, 2020-01-13 at 19:06 +0100, Zelphir Kaltstahl wrote:
>> Hi Guile Users!
>>
>> Is there any library for logging in Guile?
>>
>> What I imagine is something, where I can log messages of various levels,
>> like debug, info, error and such. Currently I am using display and
>> simple-format for all the things, but it would be nice to be able to run
>> a program and give it some log level, so that only the log messages of
>> that level or above in importance are shown. Then I could leave all my
>> logging in my code and set it to debug level or, if intended to be seen
>> for the user, set it to info level, or if there really is an error, I
>> could set it to error level.
>>
>> On a quick search I could not find anything.
>>
>> Regards,
>> Zelphir
> I'm using a rather simple module that distinguishes errors from warnings and
> debug:
> https://github.com/UMCUGenetics/sparqling-genomics/blob/master/web/logger.scm
>
> You could implement your own log levels easily..
>
> So you can use it like this:
> (log-error "the-calling-function" "A ~a ~a ~a" "format" "like" "format")
> (log-debug "the-calling-function" "Similar to ~a" 'log-error)
> (log-warning "the-calling-function" "Similar to ~a" 'log-debug)
>
> Then there are three functions that return a port to write to:
> (default-error-port) (default-warning-port) (default-debug-port)
>
> When (null? port) => #t, no message is written.
>
> See:
> https://github.com/UMCUGenetics/sparqling-genomics/blob/dc5fea515c30aa26ff60b77911438689473d125b/web/ldap/authenticate.scm.in#L148
>
> Kind regards,
> Roel Janssen
>
>



Re: Guile fibers return values

2020-01-14 Thread Zelphir Kaltstahl
Hi Amirouche!

I am currently looking into using parallel forms, but am experiencing
some trouble with it (see other e-mail about possible bug in parallel
forms).

I would like to have more control over the maximum number of in parallel
running threads, when spawning tasks recursively. Parallel forms do not
offer to limit the maximum, except for the expensive parallel forms. And
those probably also do not offer it for recursive calls (in a task start
again multiple tasks to run in parallel, which is the case for building
the tree).

I need to look at your code in detail to understand, but from the
description or comments it looks promising for my use case.

Thanks,
Zelphir

On 1/14/20 11:59 AM, Amirouche Boubekki wrote:
> Hello Zelphir!
>
> Le sam. 4 janv. 2020 à 22:49, Zelphir Kaltstahl
>  a écrit :
>> Hello Guile users!
>>
>> I have questions regarding the usage of the fibers library. It seems,
>> that I cannot find any way to get a computation result back from a
>> fiber. I also cannot find anything about how to get a value back from a
>> fiber, except for channels. The examples include one example using the
>> procedure `make-channel`, to create one channel for a client to send to
>> a server and one channel to use for the server to send messages to the
>> client.
>>
>> Are channels the only way to get a computation result back from a fiber?
>>
>> Should I be creating channels, which the spawned fiber then can use on
>> its own, to asynchronously give me a result?
>>
>> This is an aside of my actual project currently. I want to parallelize
>> some algorithm and want to make use of fibers for that, but in order to
>> do that, I must understand how to run multiple fibers and get their
>> results back.
>>
>> Can you give me an example, where fibers are used to split up a
>> computation heavy task so that it is sped up, because of running on
>> multiple cores?
>>
> For that last bit, I have done the following in babelia:
>
>   
> https://github.com/amirouche/guile-babelia/blob/87ae25b56777ab6072759bbe80bb80851d0d9174/babelia/pool.scm#L89-L108
>
> I am wondering why the existing parallel for do not work for you:
>
>   https://www.gnu.org/software/guile/manual/html_node/Parallel-Forms.html
>
>> Regards,
>>
>> Zelphir
>>
>>
>



Re: Bug in Guile 2.2.6 parallel forms implementation?

2020-01-16 Thread Zelphir Kaltstahl
Hi Guile Users!

I have now checked every single procedure, which is used in the code,
which runs in parallel, for any kind of mutation and the following is
the result, a list of everything that is used down to standard functions
of Guile like + - * / and a short explanation of what each procedure is
and as sub list elements other procedures, which are used inside the
procedures (org mode format, copied from my notes file, so ignore the
tilde characters, if not viewing in org mode):

START
- ~select-min-cost-split~
  - can raise a condition in case of wrong arguments (empty list of splits)
- ~get-best-split-for-column~
  - ~make-split~
- is a constructor
- only ever creates new struct instances
  - ~dataset-get-col~
- ~dataset-map~
  - uses only ~map~ internally, is just part of an abstraction layer over 
lists
- ~data-point-get-col~
  - is just an alias for ~vector-ref~
- ~dataset-column-empty?~
  - is an alias for ~null?~, is part of an abstraction layer
- ~dataset-column-first~
  - is an alias for ~car~, is part of an abstraction layer
- ~split-data~
  - makes use of ~receive~, inside which the bug happened, that ~<~ got an 
argument of the wrong type
  - ~dataset-partition~
- is a wrapper for ~partition~ (or actually an alias)
- is part of the abstraction layer over lists
- ~partition~
  - is a library function from ~srfi-1~
- ~data-point-get-col~
  - alias for vector-ref
  - part of abstraction layer over vectors for data points
- ~<~
  - standard mathematical function
- ~list~
  - is the list constructor
  - standard function
- ~split-quality-proc~
  - is in this case actually ~gini-index~, given as an argument
  - ~gini-index~
- ~+~
  - standard math function
- ~apply~
  - standard higher-order function
- ~map~
  - standard higher-order function
- ~calc-proportion~
  - ~dataset-empty?~
- abstraction layer over lists
- alias for ~null?~
  - ~dataset-length~
- abstraction layer over lists
- alias for ~length~
  - ~count~
- SRFI-1 higher-order function
  - ~data-point-get-col~
- alias for ~vector-ref~
- part of abstraction layer over vectors for data points
  - ~/~
- standard math function
  - ~*~
- standard math function
  - ~-~
- standard math function
- ~iter-col-vals~
  - is a named let, defined in ~get-best-split-for-column~ itself
- ~dataset-column-rest~
  - is an alias for ~cdr~
  - is part of an abstraction layer over lists
~END~

I was not able to find a single procedure, which I wrote, or usage of
mutation, which could cause problems, when I run the code in multiple
threads using parallel forms. This makes me think the following:

  * Perhaps some function from SRFI 1 is not suitable for running in
parallel?
  * Perhaps the implementation of the parallel forms is not correct?
  * Perhaps the underlying threading code for parallel forms is not correct?
  * Perhaps recursively splitting into parallel executions for branches
of the tree is not a use case foreseen for parallel forms?
  * Perhaps a language primitive is not usable in parallel code? (unlikely?)
  * Maybe the ~receive~ form is buggy in parallel execution.

My algorithm in itself should be correct. It works just fine and never
has any "wrong type" errors in non-concurrent execution. It also has
many tests and they cover most procedures I wrote and none of those fails.

I will look into making use of fibers as well. If it turns out, that no
error happens when I am using fibers, then that would be even more an
indication of parallel forms implementation containing some kind of
error. If there is still an error like the ones I described in my
previous e-mail, then perhaps the whole thing is about recursively
spawning futures and fibers, or some primitive I used does not work in
parallel for some reason.

What else can I try?

Regards,
Zelphir

On 1/14/20 10:55 PM, Zelphir Kaltstahl wrote:
> Hi Guile Users!
>
> For my project of implementing a decision tree algorithm, which I ported
> to Guile, I am trying ways of parallelizing the algorithm. Since I did
> not make use of mutation or global state in the algorithm, it should be
> fairly simple to parallelize: "Simply split execution into 2 parts at
> every split of the tree and let those run on different cores." – That's
> at least the theory. I am using Guile 2.2.6, installed via Guix package
> manager.
>
> However, I think there might be a bug in Guile's implementation of the
> parallel forms. There is still a small chance, that somehow the bug is
> in my code and I overlooked someth

Re: Announcing the first actually stable release of guile-for-loops

2020-01-23 Thread Zelphir Kaltstahl
Hi Linus!

Although I just ported multiple usages of those kind of loops from a
previously Racket project to a Guile project, I think this is quite
cool! When I ported those usages in my code, it also resulted in some
named lets (I guess quite naturally, as an available looping construct),
so I can relate to that.

Thanks!

Regards,

Zelphir

On 1/23/20 6:00 PM, guile-user-requ...@gnu.org wrote:
> Message: 4
> Date: Thu, 23 Jan 2020 13:10:46 +0100
> From: Linus Björnstam 
> To: guile-user@gnu.org
> Subject: Announcing the first actually stable release of
>   guile-for-loops
> Message-ID: 
> Content-Type: text/plain;charset=utf-8
>
> Hiya everybody!
>
> I have spent some time implementing efficient for loops for guile, and they 
> are baked and ready to go. I have worked the last weeks at implementing 
> generalized support for non-tail-recursive loops and am happy to announce 
> for/foldr. It is a generic right fold, with support for delaying it's 
> arguments as either thunks or promises. 
>
> The syntax is more or less the same as racket's loops, and they are generally 
> compatible. The code generated is for almost all cases as fast as hand-rolled 
> code. They are all expressed as left or right folds, and are as such (apart 
> from for/list, but read about that in the documentation) free of mutation. 
> They are all converted to named lets. 
>
> Some examples:
>
> (for/list ((a (in-range 1 6)))
>   (* a a)) ;; => (1 4 9 16 25)
>
> (for*/list ((a (in-string "ab")) (b (in-range 1 3)))
>   (list a b)) 
> ;; => ((#\a 1) (#\a 2) (#\b 1) (#\b 2))
>
> There are many more looping constructs, among others: 
> for/sum, for/vector, for/or, for/and, for/first, for/last and a 
> side-effecting simple for.
>
> Here is a sieve of erathostenes:
>
> (define (erathostenes n)
>   (define vec (make-vector n #t))
>   (for/list ([i (in-range 2 n)] #:when (vector-ref vec i))
> (for ([j (in-range/incr (* 2 i) n i)])
>   (vector-set! vec j #f))
> i))
>
> The code and documentation is available here: 
> https://hg.sr.ht/~bjoli/guile-for-loops
>
> A web-friendly documentation can be found here: 
> https://man.sr.ht/%7Ebjoli/for-loops-docs/for-loops.md
>
> The thing I had been waiting for is right fold. That allows us to write loops 
> like guile's map: non-tail recursive:
> (for/foldr ((identity '())) ((a (in-list '(1 2 3
>   (cons (* a a) identity))
>
> becomes equivalent to:
>
> (let loop ((random-identifier '(1 2 3)))
>   (if (null? random-identifier)
>   '()
>   (let ((a (car random-identifier)))
> (cons (* a a) (loop (cdr random-identifier))
>
> Happy hacking
> Linus Björnstam



Not understanding spawn-fiber's parallel? keyword argument

2020-01-26 Thread Zelphir Kaltstahl
Hi Guile Users!

I am experimenting with guile-fibers and hit some behavior that seems weird.

Have a spawn-fiber call in a run-fibers call inside a
call-with-new-thread, to spawn and run fibers without blocking the whole
execution of the program. The code is probably very similar to
amirouche's babelia thread pool (I get a 404 currently, when trying to
visit it on Github and could not find it on Gitlab either, could it be
you are moving it elsewhere @amirouche?), except, that I am trying to
use fibers instead of threads:

8<8<
(define pool-initializer
  (lambda* (#:key (parallelism (current-processor-count)))
(let ([channel-receive (make-channel)]
  [scheduler (make-scheduler #:parallelism parallelism)])
  ;; Start as many workers as are desired.
  ;; TODO: PROBLEM: ~run-fibers~ blocks. So we need a new thread to run the
  ;; fibers in a non-blocking way. LOOKUP: How to start fibers without
  ;; waiting for them to finish?
  (call-with-new-thread
   (lambda ()
 (run-fibers
  (lambda ()
(let loop ([index parallelism])
  (unless (zero? index)
(display "[POOL INIT THREAD]: will spawn fiber ") (displayln 
index)
(spawn-fiber (lambda () (worker index channel-receive))
 )  ; add #:parallel? #t keyword argument here
;; We do not need to spawn new fibers in the same scheduler 
later. The
;; fibers should stay alive for the whole duration the program 
is
;; running.
(displayln "[POOL INIT THREAD]: fiber spawned")
(loop (- index 1)
  #:scheduler scheduler)
 (displayln "[POOL INIT]: pool init thread returning")
 ))
  (displayln "[POOL INIT]: will start work-distributor")
  (call-with-new-thread
   (lambda ()
 (work-distributor channel-receive)))
  ;; Return the channel for receiving work, so that the outside context can
  ;; make use of it when calling ~publish~ to publish work.
  channel-receive)))
>8>8

So there is that call to spawn-fiber. This call starts executing
whatever is defined in ~worker~. However, when I add the #:parallel? #t
keyword argument, the fiber never starts running. This is confusing. I
thought (after reading the manual of fibers regarding this keyword
argument multiple times) that it would only change what scheduler
(scheduler or peer scheduler) the fiber is run on, but not whether it is
run at all. It seems, that somehow when I add the keyword #:parallel?
#t, it never is run.

Can anyone explain, why this happens?

I will send the complete code as attachment.

There is also the question, why the fibers do not run in parallel, as
they should, because I created the scheduler with #:parallelism 2.
Instead they run sequentially. But maybe that makes for another e-mail
later.

Btw.: Thanks @amirouche! After a while of looking at your thread pool
code and drawing some diagrams to help me understanding it, it seems
quite clever and just in the direction I probably need for a fibers
"thread pool".

Regards,
Zelphir

(define-module (fibers-pool))


(use-modules
 ;; FIFO queue, not functional, using mutation
 ;; https://www.gnu.org/software/guile/manual/html_node/Queues.html
 (ice-9 q)
 (ice-9 match)
 (ice-9 threads)
 (rnrs exceptions)
 (rnrs conditions)
 ;; fibers internals are needed for creating schedulers without running anything
 ;; in them immediately
 (fibers)
 (fibers channels)
 (fibers internal))


(define displayln
  (lambda (msg)
(display msg)
(newline)))


(define work-distributor
  (lambda (channel-receive)
;; (displayln "[WORK-DISTRIBUTOR]: work-distributor started")
;; (displayln "[WORK-DISTRIBUTOR]: starting work-distributor message loop")
(let loop ([work-queue (make-q)]
   [worker-channels-queue (make-q)])
  (displayln "[WORK-DISTRIBUTOR]: work-distributor is listening for messages")

  (display "[WORK-DISTRIBUTOR]: number of ready workers in queue: ")
  (displayln (q-length worker-channels-queue))

  (display "[WORK-DISTRIBUTOR]: number of works in queue: ")
  (displayln (q-length work-queue))

  (match (pk 'work-distributor-received-msg (get-message channel-receive))
[('worker-ready . channel-worker)
 (displayln "[WORK-DISTRIBUTOR]: work-distributor received ready worker channel")
 ;; If there is no work for the ready worker, enqueue the worker,
 ;; otherwise give it work.
 (cond
  [(q-empty? work-queue)
   ;; (displayln "[WORK-DISTRIBUTOR]: work queue is empty")
   (enq! worker-channels-queue channel-worker)]
  [else
   ;; (displayln "[WORK-DISTRIBUTOR]: work queue has work")
   (let ([some-work (deq! work-queue)])
 ;; (displayln "[WORK-DISTRIBUTOR]: work-distributor will put work on channel")
 (pu

Re: Logo proposal

2020-01-27 Thread Zelphir Kaltstahl
On 1/27/20 2:03 PM, Marc Chantreux wrote:
> hello,
>
> On Mon, Jan 27, 2020 at 12:30:51AM +0100, Arne Babenhauserheide wrote:
>> Did you try it?
> i never seen λ used in the documentation or code so what i actually
> wrote a macro:
> (define-syntax λ
>   (syntax-rules ()
> ((λ sign ...)
>  (lambda sign ...
>
> i just removed it and the code is still working. thanks a lot.
>
> marc
>
The thing is, it does not work in Geiser in Emacs.

It does work in normal program code, but if you use the REPL all the
time, it becomes annoying. It looks very neat though.

Regards,
Zelphir




Re: Logo proposal

2020-01-28 Thread Zelphir Kaltstahl
Hmmm, I tried again and it worked in command line REPL and Geiser.
Weird, I was remembering something did not work. Perhaps it was only
when I needed lambda* or something. Great, I can use it more often again!

On 1/28/20 1:44 AM, Jose A. Ortega Ruiz wrote:
> On Tue, Jan 28 2020, Zelphir Kaltstahl wrote:
>
>> On 1/27/20 2:03 PM, Marc Chantreux wrote:
>>> hello,
>>>
>>> On Mon, Jan 27, 2020 at 12:30:51AM +0100, Arne Babenhauserheide wrote:
>>>> Did you try it?
>>> i never seen λ used in the documentation or code so what i actually
>>> wrote a macro:
>>> (define-syntax λ
>>>   (syntax-rules ()
>>> ((λ sign ...)
>>>  (lambda sign ...
>>>
>>> i just removed it and the code is still working. thanks a lot.
>>>
>>> marc
>>>
>> The thing is, it does not work in Geiser in Emacs.
> Hmm, it does work for me.  For instance, this simple example
>
>(define-module (foo))
>
>(define foo (λ () 3))
>
> in foo.scm does what i expect.  Also using λ directly in the REPL works
> for me.  What behaviour are you observing instead?  Could it be that
> you're not using UTF-8 as your encoding?
>
> Cheers,
> jao



Re: stis-data

2020-02-11 Thread Zelphir Kaltstahl
Hi Stefan!

Would this be a good option for a binary format for transmission of data
over network, or is there anything, that would make it less suitable for
such purpose?

Regards,
Zelphir

On 2/11/20 11:16 PM, Stefan Israelsson Tampe wrote:
> HI,
>
> I just want to announce my pure guile safe serialiser that serialises and
> deserialise guile datastructures to a byte format. It can either keep the
> data compressed more or less and by default the original datastructure is
> perfectly represented. It can represents all datastructures that are atoms,
> lists, vectors, variables, structs or objects.
>
> classes and objects need to have a target class or struct references in a
> module for it to work
>
> This repository should be a safer option that a simple read/write
> serialization.
>
> For a small part of the API and a little example see README
>
> REPO:
> https://gitlab.com/tampe/stis-data
>
> A similar repo is
> https://gitlab.com/tampe/guile-persist
>
> That is more feature complete (includes serialisation of lambdas and
> continuations and whatnot) but is unsafe.



Re: Happy birthday, Guile! - grid printing

2020-02-16 Thread Zelphir Kaltstahl
Hi Guile Users!

Guile is my go to programming language for my free time projects : )
While it's sometimes not as easy to find answers for problems as in some
other programming languages, usually it is worth the research, as I come
out more knowledgeable on the other side. The documentation is usually
great and people are creating great projects and software in Guile.
Happy to be part of the community!

Some time ago and this weekend I have been working on a thing that
prints grids:

https://notabug.org/ZelphirKaltstahl/guile-grid-printer/src/0.1.0

Basically prints lists as grids in on command line or to string and
allows for configuration of the printed grid, such as padding or which
characters shall be used for representing borders or intersections in
the grid. Personally I think this could be useful for example for
printing a chess board or similar things in pure text form. In the test
cases, there is also an example of printing a grid containing a grid.

It's only one of many projects I try to work on, but since it is not as
complex as the others, it at least is already usable, while most of my
other projects are in the unfinished non-usable state.

Thanks everyone for participating in the Guile community and for sharing
knowledge or providing learning resources!

Zelphir

On 16.02.20 15:56, Ludovic Courtès wrote:
> Hello Guilers!
>
> Today, it’s been 9 years since Guile 2.0 came out!
>
>   https://lists.gnu.org/archive/html/guile-devel/2011-02/msg00173.html
>
> It’s impressive how much has been accomplished since 2.0, and how what
> seemed like a pipe dream back then came into reality with 3.0.  I think
> Guile 2.0 started a renaissance of Guile, and it’s in bloom now.  :-)
>
> We used to have a “Guile potluck” for the anniversary, where people
> would bring their own hacks and virtually join for a party.  We missed
> it this year, but if there’s a nice hack that you’d like to share, now
> is a good time!
>
> Happy hacking with Guile!
>
> Ludo’.



Re: Happy birthday, Guile! - grid printing

2020-02-17 Thread Zelphir Kaltstahl
Hey Linus!

Huh, interesting! This does more than my little tool. I don't understand
all of it right now, but perhaps it can be used to make grids too.

Thanks for the hint. I did not know of its existence!

On 2/17/20 9:01 AM, Linus Björnstam wrote:
> Hi Zelphir!
>
> You should check out SRFI 166 or 159. It has columnar printing built in. I 
> ported it to guile and one implementation is available in guix (under a 
> non-standard module name iirc).
>
> https://srfi.schemers.org/srfi-166/srfi-166.html#Columnar-Formatting
>



Lenses in Guile?

2020-02-18 Thread Zelphir Kaltstahl
Hi!

This reminds me of something: Is there something like
https://docs.racket-lang.org/lens/index.html for Guile? Or perhaps an
easy to understand tutorial on implementing it?

Regards,
Zelphir

On 2/18/20 2:38 PM, Christopher Lam wrote:
> A bit late, and perhaps not as sophisticated as some bigger modules here.
>
> Two functions defined as follows: nested-alist-set! nested-alist-get at
> https://github.com/Gnucash/gnucash/blob/1f83cfaf64d1cd3c8862b427dd043154f780a772/gnucash/report/html-chart.scm#L37
>
> Consider a nested alist describing unix file system
> (define lst
>  (list
>   (cons 'usr (list
>   (cons 'bin "binary files")
>   (cons 'games "g4m3s")
>   (cons 'include (list
>   (cons 'guile (list
> (cons '2.2 "old")))
>   (cons 'linux "da best")))
>
> We can access a leaf node via (nested-alist-get lst '(usr include linux))
> --> "da best", and set a leaf node via (nested-alist-set! lst '(usr include
> python) "boo"). This is probably easy to seasoned schemers, but still a
> nice pair of functions to use in modifying nested alists before conversion
> into json.
>
> On Mon, 17 Feb 2020 at 09:16, Ludovic Courtès  wrote:
>
>> Hi!
>>
>> Ricardo Wurmus  skribis:
>>
>>> What do you think about adding these things to
>>> https://notabug.org/cwebber/guile-webutils/ ?  This was once intended to
>>> be a collection of useful tools that come in handy when writing web
>>> applications.
>> I didn’t know about guile-webutils but consolidating Web tools in this
>> package sounds like a great idea!
>>
>> Ludo’.
>>
>>



Re: Lenses in Guile?

2020-02-19 Thread Zelphir Kaltstahl
Hi Alex!

Thanks for that!

On 18.02.20 15:04, Alex Sassmannshausen wrote:
> Heya,
>
> Zelphir Kaltstahl  writes:
>
>> Hi!
>>
>> This reminds me of something: Is there something like
>> https://docs.racket-lang.org/lens/index.html for Guile? Or perhaps an
>> easy to understand tutorial on implementing it?
> Check out https://gitlab.com/a-sassmannshausen/guile-lens
>
> It's an implementation I did for fun a while ago.  Can't remember how
> faithfully it implements lenses as compared with racket's…
>
> Best wishes,
>
> Alex
>
>> Regards,
>> Zelphir
>>
>> On 2/18/20 2:38 PM, Christopher Lam wrote:
>>> A bit late, and perhaps not as sophisticated as some bigger modules here.
>>>
>>> Two functions defined as follows: nested-alist-set! nested-alist-get at
>>> https://github.com/Gnucash/gnucash/blob/1f83cfaf64d1cd3c8862b427dd043154f780a772/gnucash/report/html-chart.scm#L37
>>>
>>> Consider a nested alist describing unix file system
>>> (define lst
>>>  (list
>>>   (cons 'usr (list
>>>   (cons 'bin "binary files")
>>>   (cons 'games "g4m3s")
>>>   (cons 'include (list
>>>   (cons 'guile (list
>>> (cons '2.2 "old")))
>>>   (cons 'linux "da best")))
>>>
>>> We can access a leaf node via (nested-alist-get lst '(usr include linux))
>>> --> "da best", and set a leaf node via (nested-alist-set! lst '(usr include
>>> python) "boo"). This is probably easy to seasoned schemers, but still a
>>> nice pair of functions to use in modifying nested alists before conversion
>>> into json.
>>>
>>> On Mon, 17 Feb 2020 at 09:16, Ludovic Courtès  wrote:
>>>
>>>> Hi!
>>>>
>>>> Ricardo Wurmus  skribis:
>>>>
>>>>> What do you think about adding these things to
>>>>> https://notabug.org/cwebber/guile-webutils/ ?  This was once intended to
>>>>> be a collection of useful tools that come in handy when writing web
>>>>> applications.
>>>> I didn’t know about guile-webutils but consolidating Web tools in this
>>>> package sounds like a great idea!
>>>>
>>>> Ludo’.
>>>>
>>>>
>



Re: How to correctly load modules from runtime defineable locations?

2020-03-06 Thread Zelphir Kaltstahl
Hi!

I am not sure this will help you, but here is what I observed and what
works best for me:

  * For running Guile programs use: `guile -L 
`.
  * For using libraries:
  o If Guile is installed via GUIX, try to install the library
through GUIX as well, then it should be available for Guile.
  o If Guile is installed via GUIX, but the library is not on GUIX
or not in the version you would like, create a directory
somewhere and set the Guile load path for that directory.
  o If Guile is built and installed by yourself also use Guile load
path.
  * Modules need to be named the same as the directories they are in to
be found:
  o To use (use-modules (some mymodule)) the module should be in a
directory `some` and a file `mymodule.scm`.
  o To use (use-modules (some)), the module should be in a file
named `some.scm`.

Perhaps the Guile load path varies on different systems?

Regards,
Zelphir

On 06.03.20 06:22, Михаил Бахтерев wrote:
> Hello, Guile world.
>
> I have got the following issue, when trying to understand, how the
> Guiles modules system works.
>
> 1. I've wrote simple code
>
> ; check.scm
> (setlocale LC_ALL "")
>
> (let* ((fn (current-filename))   
>(dir (if (string? fn) (dirname fn) "."))  
>(lib (if (string? fn) (string-append (dirname dir) "/lib") "../lib")))
>   (add-to-load-path lib)
>   (add-to-load-path dir))
>
> (display %load-path)
> (newline)
>
> (use-modules (json))
>
> (scm->json #("hello" "world"))
> (newline)
>
> 2. I have the following tree structure
>
> $ find
> .
> ./bin
> ./bin/check.scm
> ./lib
> ./lib/json
> ./lib/json/parser.scm
> ./lib/json/builder.scm
> ./lib/json.scm
>
> These json files are taken from https://github.com/aconchillo/guile-json
> intact.
>
> 3. I have Guile 2.2.6
>
> 4. In that environment i run
>
> $ guile bin/check.scm 
> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
> ;;;   or pass the --no-auto-compile argument to disable.
> ;;; compiling /tmp/news/bin/check.scm
> ;;; WARNING: compilation of /tmp/news/bin/check.scm failed:
> ;;; no code for module (json)
> ;;; compiling /tmp/news/lib/json.scm
> ;;; compiling /tmp/news/lib/json/builder.scm
> ;;; compiled 
> /home/mob/.cache/guile/ccache/2.2-LE-8-3.A/tmp/news/lib/json/builder.scm.go
> ;;; compiling /tmp/news/lib/json/parser.scm
> ;;; compiled 
> /home/mob/.cache/guile/ccache/2.2-LE-8-3.A/tmp/news/lib/json/parser.scm.go
> ;;; compiled 
> /home/mob/.cache/guile/ccache/2.2-LE-8-3.A/tmp/news/lib/json.scm.go
> (/tmp/news/bin /tmp/news/lib /usr/share/guile/2.2 /usr/share/guile/site/2.2 
> /usr/share/guile/site /usr/share/guile)
> ["hello","world"]
>
> My questions:
>
> 1. What does the message "no code for module" mean? It seems, that Guile
> can find the code and compile it.
>
> 2. Why does the program work in some distributives (Arch, Debian) and
> does not work in others (Ubuntu)? What is the difference, given the
> Guile versions are the same?
>
> 3. What am i doing wrong? My intent is to have some freedom in library
> placement, i do not want to use autoconf and automake for fixed paths.
> Is it possible to solve this task with `add-to-load-path` or should i
> use another technique?
>
> -- MB, respectfully, with many thanks in advance.
>


Re: How to correctly load modules from runtime defineable locations?

2020-03-06 Thread Zelphir Kaltstahl
Hi!

I don't know about other ways, but using the -L argument, you can run
Guile programs from anywhere, because it will have the effect of making
it look to Guile as if it was started from that -L specified path.

Using `add-to-load-path` would be in your code, but usually I think one
should prefer to keep such things out of the code. I guess a shell
script would be better even, than using `add-to-load-path`.

However, this is only my opinion and I am myself not sure, whether that
is the best way.

I always use the -L argument when running tests, which are in a parallel
directory hierarchy to the source code. I specify a path that points to
a directory, which is (grand* …)parent of both, the tests directory and
the source code directory. Only then my tests have access to the modules
defined in the source code and can use `use-modules` as I described.

Regards,
Zelphir

On 3/6/20 5:29 PM, Михаил Бахтерев wrote:
> Thanks for the detailed answer.
>
> When i run
>
>   guile -L lib bin/check.scm
>
> everything works fine. No warnings.
>
> But my problem is that client wants just to unpack code archive to the
> random location and run it from there. Unfortunately, no GUIX, no custom
> builds. I don't understand what is the difference between -L option and
> add-to-load-path. It seems, that -L just adds lib directory to the
> %load-path, and that is it.
>
> May be it would be better to provide shell script, but i would like
> to solve this in pure Guile, if possible. May be, instead of
> adding-to-load-path, the better solution would be to reexecute Guile
> with appropriate -L options from simple trampoline .scm script?
>
> If i opt to this solution of reexecuting Guile, are there better and
> more robust choices than passing options through command line? Could the
> passing paths through environment variables be more reliable option?
>
> On Fri, Mar 06, 2020 at 12:53:37PM +0100, Zelphir Kaltstahl wrote:
>> Hi!
>>
>> I am not sure this will help you, but here is what I observed and what
>> works best for me:
>>
>>   * For running Guile programs use: `guile -L 
>> `.
>>   * For using libraries:
>>   o If Guile is installed via GUIX, try to install the library
>> through GUIX as well, then it should be available for Guile.
>>   o If Guile is installed via GUIX, but the library is not on GUIX
>> or not in the version you would like, create a directory
>> somewhere and set the Guile load path for that directory.
>>   o If Guile is built and installed by yourself also use Guile load
>> path.
>>   * Modules need to be named the same as the directories they are in to
>> be found:
>>   o To use (use-modules (some mymodule)) the module should be in a
>> directory `some` and a file `mymodule.scm`.
>>   o To use (use-modules (some)), the module should be in a file
>> named `some.scm`.
>>
>> Perhaps the Guile load path varies on different systems?
>>
>> Regards,
>> Zelphir
>>
>



Re: syntax taste: use of unquote in macros

2020-03-29 Thread Zelphir Kaltstahl


On 3/29/20 5:11 PM, Matt Wette wrote:
> Hi All,
>
> I'm not sure if you know about this, but there is a discrepancy in the
> way some folks define macros to use unquote (aka ,).   For example,
>
> > (use-modules (system base pmatch))
> > (pmatch '(foo "bar")  ((foo ,val)  (write val) (newline)))
> => "bar"
>
> > (use-modules (ice-9 match))
> > (match '(foo "bar")  (`(foo ,val)  (write val) (newline)))
> => "bar"
>
> Note the difference in the use of quasiquote (aka `) in the pattern
> for (foo ,val): match syntax uses it, pmatch does not.
> In Scheme, quasiquote and unquote always come together.
>
> Is pmatch syntax in bad taste?  I'm looking for opinions.
>
> Another example is sxml-match, which omits use of quasiquote.
> I have written a variation of sxml-match.  Should I keep the sxml-match
> usage, which keeps it compatible with sxml-match,  or adopt that
> used by (ice-9 match)?
>
> Matt

Hi Matt!

I'm not sure where I first read about pmatch doing the quasiquote
internally automatically and I of course had already forgotten about it,
until I read your e-mail. I remember though: When I read about it, I
thought something like: "Ehhh? That's confusing. Everywhere else you
have to quasiquote to unquote, but in pmatch it's different. Easy to
forget that and I need to remember more. I would not mind having to
write a simple quasiquote myself."

So, with my limited experience, I would definitely vote for the, in my
opinion more natural way, to have the user write the quasiquote, instead
of doing that internally. It's not saving that much time or writing
really. I understand the idea, that "if it is always done anyway, one
could save the user some typing of the same thing over and over again",
but in my opinion it is not worth it to deviate from, what one would
expect without knowing about this behavior.

Regards,
Zelphir




Re: SRFI-37 and short-name option with optional argument

2020-05-15 Thread Zelphir Kaltstahl
Hi Simon!

Perhaps this will help?

https://notabug.org/ZelphirKaltstahl/guile-examples/src/master/command-line-arguments

Regards,
Zelphir

On 5/15/20 5:21 PM, zimoun wrote:
> Dear Linus,
>
> On Tue, 12 May 2020 at 22:29, Linus Björnstam
>  wrote:
>> I Sony have an answer to your question, but using (ice-9 getopt-long)is 
>> usually the library guilers reach for unless they want to install third 
>> party libraries: 
>> https://www.gnu.org/software/guile/manual/html_node/getopt_002dlong.html#getopt_002dlong
> Thank you for your answer.  But I really would like to use SRFI-37. :-)
>
> All the best,
> simon
>




Re: guile-json 4.0.0 released

2020-05-17 Thread Zelphir Kaltstahl
Hi!

Congrats to the new version!

Your project has made quite some progress!

Best regards,
Zelphir

On 5/17/20 8:42 AM, Aleix Conchillo Flaqué wrote:
> Hi!
>
> I'm super excited to announce guile-json 4.0.0. This new version comes with
> a couple of small breaking changes and huge performance improvements (up to
> 6x faster).
>
> Huge thanks to Linus Björnstam who brought up the performance issues plus a
> bunch of suggestions of how to improve them and followed along all the way.
>
> * About
>
> guile-json is a JSON module for Guile. It supports parsing and building
> JSON documents according to the http://json.org specification.
>
> - Complies with http://json.org specification.
> - Builds JSON documents programmatically using scheme data types.
> - Allows JSON pretty printing.
>
> * Download
>
> Compressed sources and a GPG detached signature[*]:
>
> http://download.savannah.nongnu.org/releases/guile-json/guile-json-4.0.0.tar.gz
> http://download.savannah.nongnu.org/releases/guile-json/guile-json-4.0.0.tar.gz.sig
>
> [*] To verify download both files and then run:
>
>gpg --keyserver keys.openpgp.org \
> --recv-keys 7CEC5511C8D057A9EF17470C54D4CC6FFC7468F4
>
>gpg --verify guile-json-4.0.0.tar.gz.sig
>
> * Changes since 3.5.0
>
> https://github.com/aconchillo/guile-json/blob/master/NEWS
>
> Bugs and comments can be reported at
> https://github.com/aconchillo/guile-json/issues
>
> Happy hacking!
>
> Aleix



Re: C programs in Scheme syntax

2020-05-29 Thread Zelphir Kaltstahl
Hi,

There is also Schemetran: https://gitlab.com/codetk/schemetran Perhaps
that was it?

Regards,

Zelphir

On 29.05.20 05:23, Keith Wright wrote:
> I am thinkging about a project that uses Scheme macros
> to generate C code.  To this end I want to encode C 
> programs as S-expressions.  For example, the C program
> that is encoded in Ascii as
>
> for (j=0;j<12;++j) a[j] = j*pi/6;
>
> might be encoded as an S-expression as
>
> (for ((= j 0)(< j 12) (++ j)) (= (sub a j)(/ (* j pi) 6)))
>
> Note that this is not a valid Scheme program, even with
> non-standard functions defined.  It is a re-encoding
> of the Ascii C syntax as an S-expression.
>
> I think I have read about something like this, perhaps
> on this list, I am not sure.  (Note to future language
> inventors: a single letter name makes a horrible Google
> search query.  Name things with made up but pronouncable
> words---perl, fortran...)
>
> I most need to convert S-expr encoded C, to Ascii encoded C,
> but I am interested in
> (a) programs to convert S-expresions to C
> (b) specifications for the form of the S-expr encoding
> (c) better plans; advice from those who have tried and failed.
>
> Any pointers?
>
>-- Keith
>
>



Normal distribution random numbers

2020-05-30 Thread Zelphir Kaltstahl
Hi Guile Users!

I recently wrote a little program involving lots of uniformly
distributed random integers. For that I used SRFI-27 and it works fine.

Then I thought: How would I get normal distributed random numbers? I
don't have a project or program in mind for this, but it struck me, that
I do not know, how to get a normal distribution from a uniform
distribution. So I dug into the matter …

Turns out the math is not really my friend:

* https://stackoverflow.com/a/3265174 – OK, if that's true, then don't
use Box-Muller-Transform
* https://stackoverflow.com/a/86885 – The what? I need to somehow
inverse the Gaussian distribution to get a function to calculate normal
distributed values from uniformly distributed values? Something like
that. Safe to say it is above my current math skills.
* The wiki page also does not help me much:
https://en.wikipedia.org/wiki/Inverse_transform_sampling Seems too
complicated.

So I thought: "OK, maybe I can simply copy, how other languages
implement it!" The wiki page mentions, that R actually makes use of the
inverse thingy. So I set out to look at R source code:

* https://github.com/wch/r-source/blob/master/src/nmath/rnorm.c – OK,
looks simple enough … Lets see what `norm_rand` is …
* https://github.com/wch/r-source/blob/master/src/nmath/snorm.c#L62 –
yeah … well … I'm not gonna implement _that_ pile of … Just look at the
lines
https://github.com/wch/r-source/blob/master/src/nmath/snorm.c#L135-L196
what a mess! Not a single comment to help understanding in it. Such a
disappointment.
* Python also seems to only use an approximation with magic constants:
https://github.com/python/cpython/blob/3.8/Lib/random.py#L443

So it seems, that there is no easy way to implement it properly with
correct tails to the left and right side of the distribution, something
clean and not made with mathematical traps built-in. Or is there?

I found a post about using 2 normal distributions to do
Box-Muller-transform:
https://www.alanzucconi.com/2015/09/16/how-to-sample-from-a-gaussian-distribution/

However, it seems to require a uniform float not integer and it is the
Box-Muller-transform, which is said to clamp between -6 and 6 according
to the people writing the answers on stackoverflow.

So my question is: Is there a good implementation in the Guile universe
already? (Or a simple way to implement it?) I don't really need it right
now, but I think this thing could be an obstacle for many people without
serious math knowledge and it would be good to know, where to find it,
should one have need for normal distributed random numbers.

Regards,
Zelphir




Re: Normal distribution random numbers

2020-05-30 Thread Zelphir Kaltstahl
I just realized, that I did not check what Guile implements as
non-SRFIs. I found:
https://www.gnu.org/software/guile/manual/html_node/Random.html which
has `random:normal`! I should have checked that first. Still good to
know, what a can of worms normal distribution implementation can be.

On 30.05.20 22:21, Zelphir Kaltstahl wrote:
> Hi Guile Users!
>
> I recently wrote a little program involving lots of uniformly
> distributed random integers. For that I used SRFI-27 and it works fine.
>
> Then I thought: How would I get normal distributed random numbers? I
> don't have a project or program in mind for this, but it struck me, that
> I do not know, how to get a normal distribution from a uniform
> distribution. So I dug into the matter …
>
> Turns out the math is not really my friend:
>
> * https://stackoverflow.com/a/3265174 – OK, if that's true, then don't
> use Box-Muller-Transform
> * https://stackoverflow.com/a/86885 – The what? I need to somehow
> inverse the Gaussian distribution to get a function to calculate normal
> distributed values from uniformly distributed values? Something like
> that. Safe to say it is above my current math skills.
> * The wiki page also does not help me much:
> https://en.wikipedia.org/wiki/Inverse_transform_sampling Seems too
> complicated.
>
> So I thought: "OK, maybe I can simply copy, how other languages
> implement it!" The wiki page mentions, that R actually makes use of the
> inverse thingy. So I set out to look at R source code:
>
> * https://github.com/wch/r-source/blob/master/src/nmath/rnorm.c – OK,
> looks simple enough … Lets see what `norm_rand` is …
> * https://github.com/wch/r-source/blob/master/src/nmath/snorm.c#L62 –
> yeah … well … I'm not gonna implement _that_ pile of … Just look at the
> lines
> https://github.com/wch/r-source/blob/master/src/nmath/snorm.c#L135-L196
> what a mess! Not a single comment to help understanding in it. Such a
> disappointment.
> * Python also seems to only use an approximation with magic constants:
> https://github.com/python/cpython/blob/3.8/Lib/random.py#L443
>
> So it seems, that there is no easy way to implement it properly with
> correct tails to the left and right side of the distribution, something
> clean and not made with mathematical traps built-in. Or is there?
>
> I found a post about using 2 normal distributions to do
> Box-Muller-transform:
> https://www.alanzucconi.com/2015/09/16/how-to-sample-from-a-gaussian-distribution/
>
> However, it seems to require a uniform float not integer and it is the
> Box-Muller-transform, which is said to clamp between -6 and 6 according
> to the people writing the answers on stackoverflow.
>
> So my question is: Is there a good implementation in the Guile universe
> already? (Or a simple way to implement it?) I don't really need it right
> now, but I think this thing could be an obstacle for many people without
> serious math knowledge and it would be good to know, where to find it,
> should one have need for normal distributed random numbers.
>
> Regards,
> Zelphir
>
>



Re: Normal distribution random numbers

2020-05-30 Thread Zelphir Kaltstahl
Hi Arne!

Thanks for the pointers!

On 5/30/20 11:30 PM, Arne Babenhauserheide wrote:
> Hi Zelphir,
>
> Zelphir Kaltstahl  writes:
>> Then I thought: How would I get normal distributed random numbers? I
>> don't have a project or program in mind for this, but it struck me, that
>> I do not know, how to get a normal distribution from a uniform
>> distribution. So I dug into the matter …
> …
>> So my question is: Is there a good implementation in the Guile universe
>> already? (Or a simple way to implement it?) I don't really need it right
>> now, but I think this thing could be an obstacle for many people without
>> serious math knowledge and it would be good to know, where to find it,
>> should one have need for normal distributed random numbers.
> I don’t know how random:normal does it, just that I used it.
>
> See https://www.gnu.org/software/guile/manual/html_node/Random.html
>
> If you want to add defined covariance, you can use cholesky
> decomposition: 
> https://hg.sr.ht/~arnebab/wisp/browse/examples/cholesky.scm?rev=91ec8dc32652
>
> Best wishes,
> Arne



Re: Normal distribution random numbers

2020-05-31 Thread Zelphir Kaltstahl
Hi!

Interesting technique, that when thinking about it, intuitively makes
sense to me. Thanks for sharing!

Regards,
Zelphir   

On 31.05.20 17:12, tantalum wrote:
> surely not the ideal way to generate numbers with a normal
> distribution, but there is a way to use custom probabilities from a
> list, which i think is nice to know.
> it works like this:
>
> have a list of probabilities. can be as long as you want. i think that
> is called probability density.
> ->
> (1 0 3 1)
>
> create the cumulative sums for this list. that is, sums like this
>   (a b c ...) -> (a (+ a b) (+ a b c) ...)
> i think that is called cumulative distribution.
> ->
> (1 1 4 5)
>
> create a random number up to the largest sum
> ->
> (random 5)
>
> return the first index of the list of cumulative sums that is greater
> than the random number.
> given the distribution above, you would see index 2 a lot, never index
> 1, and index 0 and 3 rarely.
>
> ~~~
> (use-modules ((srfi srfi-1) #:select (last)))
>
> (define (cusum a . b)
>   "calculate cumulative sums from the given numbers.
>    (a b c ...) -> (a (+ a b) (+ a b c) ...)"
>   (cons a (if (null? b) (list) (apply cusum (+ a (car b)) (cdr b)
>
> (define* (random-discrete-f probabilities #:optional (state
> *random-state*))
>   "(real ...) [random-state] -> procedure:{-> integer}"
>   (let* ((cuprob (apply cusum probabilities)) (sum (last cuprob)))
>     (lambda ()
>   (let ((deviate (random sum state)))
>     (let loop ((a 0) (b cuprob))
>   (if (null? b) a (if (< deviate (car b)) a (loop (+ 1 a) (cdr
> b)
>
> (define random* (random-discrete-f (list 1 0 3 1)
> (random-state-from-platform)))
> (display (random*))
> ~~~
>
>



Re: Normal distribution random numbers

2020-06-04 Thread Zelphir Kaltstahl
Hi Mikael!

Thanks for putting that into perspective and giving some numbers!

When I looked at the code of Guile for random:normal, I also guessed,
that it makes use of that Box-Muller-transform, but wasn't sure, so
thanks for confirming that as well.

So basically the tails are wrong, but to draw a number in the area where
the tails are wrong is so unlikely, that it would take that much time,
as stated in your number example, if I understand this correctly(?/.)

Regards,

Zelphir

On 04.06.20 17:03, Mikael Djurfeldt wrote:
> Hi Zelphir,
>
> random:normal actually uses the Box-Muller-transform. But since it
> uses 64 bits, we only loose values that would be generated once in
> 2*10^20. That is, if we could draw one billion numbers per second,
> such values would be drawn once in 7000 years. So, we would start
> noticing an anomaly after maybe 10 years or so.
>
> But maybe we should replace this with some more correct and efficient
> algorithm at some point.
>
> Best regards,
> Mikael
>
> Den lör 30 maj 2020 22:43Zelphir Kaltstahl  <mailto:zelphirkaltst...@posteo.de>> skrev:
>
> I just realized, that I did not check what Guile implements as
> non-SRFIs. I found:
> https://www.gnu.org/software/guile/manual/html_node/Random.html which
> has `random:normal`! I should have checked that first. Still good to
> know, what a can of worms normal distribution implementation can be.
>
> On 30.05.20 22:21, Zelphir Kaltstahl wrote:
> > Hi Guile Users!
> >
> > I recently wrote a little program involving lots of uniformly
> > distributed random integers. For that I used SRFI-27 and it
> works fine.
> >
> > Then I thought: How would I get normal distributed random numbers? I
> > don't have a project or program in mind for this, but it struck
> me, that
> > I do not know, how to get a normal distribution from a uniform
> > distribution. So I dug into the matter …
> >
> > Turns out the math is not really my friend:
> >
> > * https://stackoverflow.com/a/3265174 – OK, if that's true, then
> don't
> > use Box-Muller-Transform
> > * https://stackoverflow.com/a/86885 – The what? I need to somehow
> > inverse the Gaussian distribution to get a function to calculate
> normal
> > distributed values from uniformly distributed values? Something like
> > that. Safe to say it is above my current math skills.
> > * The wiki page also does not help me much:
> > https://en.wikipedia.org/wiki/Inverse_transform_sampling Seems too
> > complicated.
> >
> > So I thought: "OK, maybe I can simply copy, how other languages
> > implement it!" The wiki page mentions, that R actually makes use
> of the
> > inverse thingy. So I set out to look at R source code:
> >
> > * https://github.com/wch/r-source/blob/master/src/nmath/rnorm.c
> – OK,
> > looks simple enough … Lets see what `norm_rand` is …
> > *
> https://github.com/wch/r-source/blob/master/src/nmath/snorm.c#L62 –
> > yeah … well … I'm not gonna implement _that_ pile of … Just look
> at the
> > lines
> >
> https://github.com/wch/r-source/blob/master/src/nmath/snorm.c#L135-L196
> > what a mess! Not a single comment to help understanding in it.
> Such a
> > disappointment.
> > * Python also seems to only use an approximation with magic
> constants:
> > https://github.com/python/cpython/blob/3.8/Lib/random.py#L443
> >
> > So it seems, that there is no easy way to implement it properly with
> > correct tails to the left and right side of the distribution,
> something
> > clean and not made with mathematical traps built-in. Or is there?
> >
> > I found a post about using 2 normal distributions to do
> > Box-Muller-transform:
> >
> 
> https://www.alanzucconi.com/2015/09/16/how-to-sample-from-a-gaussian-distribution/
> >
> > However, it seems to require a uniform float not integer and it
> is the
> > Box-Muller-transform, which is said to clamp between -6 and 6
> according
> > to the people writing the answers on stackoverflow.
> >
> > So my question is: Is there a good implementation in the Guile
> universe
> > already? (Or a simple way to implement it?) I don't really need
> it right
> > now, but I think this thing could be an obstacle for many people
> without
> > serious math knowledge and it would be good to know, where to
> find it,
> > should one have need for normal distributed random numbers.
> >
> > Regards,
> > Zelphir
> >
> >
>


Re: What is the status of guile-gnome, or gtk\guile?

2020-06-07 Thread Zelphir Kaltstahl
This is what I have been looking up just yesterday as well!

I remember some e-mails here on the Guile user list definitely later
than 2017. However, they also did not turn up on my search engine search
yesterday.

I also wonder, if there is a tutorial somewhere, which shows the basics
of using guile-gnome for making a GUI application. I'd love to use Guile
+ GTK3 for an application I want to write for a long time.

Regards,
Zelphir

On 07.06.20 03:03, Dale Mellor wrote:
> As far as I can tell nothing has happened since 2017.  Has the project
> died?
>
>



Re: What is the status of guile-gnome, or gtk\guile?

2020-06-07 Thread Zelphir Kaltstahl
Ah right! Might have been guile-gi, what I read about on this mailing
list! Thanks for that pointer.

On 07.06.20 12:57, Dale Mellor wrote:
> On Sun, 2020-06-07 at 10:39 +0200, Zelphir Kaltstahl wrote:
>> This is what I have been looking up just yesterday as well!
>>
>> I remember some e-mails here on the Guile user list definitely later
>> than 2017. However, they also did not turn up on my search engine search
>> yesterday.
>>
>> I also wonder, if there is a tutorial somewhere, which shows the basics
>> of using guile-gnome for making a GUI application. I'd love to use Guile
>> + GTK3 for an application I want to write for a long time.
>I have since found out about two successor projects, unfortunately both
> in very early stages of development: g-golf and guile-gi.  If you are
> starting a new project, you most likely want to look at using one or other
> of these, but you will have to be prepared to help that project to shake
> out its bugs.
>
>



Re: guile-json 4.1.0 released

2020-06-07 Thread Zelphir Kaltstahl
Really thanks a lot for building this part of Guile ecosystem!

On 07.06.20 02:09, Aleix Conchillo Flaqué wrote:
> Hi!
>
> I'm happy to announce guile-json 4.1.0. This version improves number
> parsing performance by a 2x factor and cleans up and simplifies the builder
> code specially unicode related.
>
>  https://github.com/aconchillo/guile-json/
>
> * About
>
> guile-json is a JSON module for Guile. It supports parsing and building
> JSON documents according to the http://json.org specification.
>
> - Complies with http://json.org specification.
> - Builds JSON documents programmatically using scheme data types.
> - Allows JSON pretty printing.
>
> * Download
>
> Compressed sources and a GPG detached signature[*]:
>
> http://download.savannah.nongnu.org/releases/guile-json/guile-json-4.1.0.tar.gz
> http://download.savannah.nongnu.org/releases/guile-json/guile-json-4.1.0.tar.gz.sig
>
> [*] To verify download both files and then run:
>
>gpg --keyserver keys.openpgp.org \
> --recv-keys 7CEC5511C8D057A9EF17470C54D4CC6FFC7468F4
>
>gpg --verify guile-json-4.1.0.tar.gz.sig
>
> * Changes since 4.0.1
>
> https://github.com/aconchillo/guile-json/blob/master/NEWS
>
> Bugs and comments can be reported at
> https://github.com/aconchillo/guile-json/issues
>
> Happy hacking!
>
> Aleix



Re: Blog post about Hall

2020-06-11 Thread Zelphir Kaltstahl
So far I've not figured out how to use guile-hall and have been looking
forward to some nice tutorial. This will come in handy!

On 11.06.20 17:10, Jérémy Korwin-Zmijowski wrote:
> Dear hackers,
>
> I want to share with you my last blog post about Hall !
>
> Hope it can be helpful.
>
> Here is the english version :
>
> https://jeko.writeas.com/hall-a-project-manager-for-the-guile-programming-language
>
> You can also find the french version on the blog.
>
> Cheers!
>
> Jérémy
>
>




guile-hall error on probably every command

2020-06-11 Thread Zelphir Kaltstahl
Hi Guile users!

I was about to follow the guile-hall tutorial posted on the list today,
but unfortunately, I get an error the first time I need to input a
guile-hall command:


xiaolong@xlx200:~/dev/Guile/guile-hall-example-project$ hall init dummy 
--author="Red Nose Hacker" --license="gpl3+" --prefix="guile" --execute
guile: warning: failed to install locale
Backtrace:
In ice-9/boot-9.scm:
  1736:10  9 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
   8 (apply-smob/0 #)
In ice-9/boot-9.scm:
718:2  7 (call-with-prompt _ _ #)
In ice-9/eval.scm:
619:8  6 (_ #(#(#)))
   293:34  5 (_ #(#(#) ("/?" ?)))
In config.scm:
62:13  4 (getopt-config-auto _ _)
   106:22  3 (getopt-config-x ("/gnu/store/3ip3nm2kjv046v37gi1wy?" ?) ?)
In srfi/srfi-1.scm:
   836:15  2 (any1 # ?)
In ice-9/regex.scm:
   131:12  1 (string-match "^-[a-Z]*h[a-Z]*$|^--help$" "/gnu/store/3?")
In unknown file:
   0 (make-regexp "^-[a-Z]*h[a-Z]*$|^--help$")

ERROR: In procedure make-regexp:
In procedure make-regexp: Invalid range end


Here are my versions:

Guile:


xiaolong@xlx200:~/dev/Guile/guile-hall-example-project$ guile --version
guile (GNU Guile) 3.0.2
Copyright (C) 2020 Free Software Foundation, Inc.

License LGPLv3+: GNU LGPL 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


guile-hall: errors. But it is installed through GUIX package manager, so
it is version:


xiaolong@xlx200:~/dev/Guile/guile-hall-example-project$ guix search guile-hall
guile: warning: failed to install locale
name: guile-hall
version: 0.3.1
outputs: out
systems: x86_64-linux i686-linux
dependencies: autoconf@2.69 automake@1.16.2 guile-config@0.4.1 guile@3.0.2 
pkg-config@0.29.2
+ texinfo@6.7
location: 
]8;;file://xlx200/gnu/store/xcyarhvbxz5m3l6yvarryx5wm10j9j4k-guix-module-union/share/guile/site/3.0/gnu/packages/guile-xyz.scmgnu/packages/guile-xyz.scm:1441:2]8;;
homepage: https://gitlab.com/a-sassmannshausen/guile-hall
license: ]8;;https://www.gnu.org/licenses/gpl.htmlGPL 3+]8;;
synopsis: Guile project tooling  
description: Hall is a command-line application and a set of Guile libraries 
that allow you to
+ quickly create and publish Guile projects.  It allows you to transparently 
support the GNU build
+ system, manage a project hierarchy & provides tight coupling to Guix.
relevance: 20


Any ideas, what could be the problem with my guile-hall?

Regards,
Zelphir



Re: guile-hall error on probably every command

2020-06-11 Thread Zelphir Kaltstahl
Hi Aleix!

Ah, so that means, once the guile-config Guix package is updated,
guile-hall installed through Guix package manager would also get that
fix, correct?

Regards,
Zelphir

On 11.06.20 21:07, Aleix Conchillo Flaqué wrote:
> Hi!
>
> I provided a fix for this a couple of weeks ago, I believe...
>
> https://gitlab.com/a-sassmannshausen/guile-config/-/commit/0c6335194db214ad6ef20e13805008bf389b44c4
>
> The fix is in guile-config.
>
> Aleix
>
> On Thu, Jun 11, 2020, 11:59 AM Zelphir Kaltstahl
> mailto:zelphirkaltst...@posteo.de>> wrote:
>
> Hi Guile users!
>
> I was about to follow the guile-hall tutorial posted on the list
> today,
> but unfortunately, I get an error the first time I need to input a
> guile-hall command:
>
> 
> xiaolong@xlx200:~/dev/Guile/guile-hall-example-project$ hall init
> dummy --author="Red Nose Hacker" --license="gpl3+"
> --prefix="guile" --execute
> guile: warning: failed to install locale
> Backtrace:
> In ice-9/boot-9.scm:
>   1736:10  9 (with-exception-handler _ _ #:unwind? _ # _)
> In unknown file:
>            8 (apply-smob/0 #)
> In ice-9/boot-9.scm:
>     718:2  7 (call-with-prompt _ _ # default-prompt-handle?>)
> In ice-9/eval.scm:
>     619:8  6 (_ #(#(#)))
>    293:34  5 (_ #(#(#) ("/?" ?)))
> In config.scm:
>     62:13  4 (getopt-config-auto _ _)
>    106:22  3 (getopt-config-x ("/gnu/store/3ip3nm2kjv046v37gi1wy?"
> ?) ?)
> In srfi/srfi-1.scm:
>    836:15  2 (any1 # (t?> ?)
> In ice-9/regex.scm:
>    131:12  1 (string-match "^-[a-Z]*h[a-Z]*$|^--help$"
> "/gnu/store/3?")
> In unknown file:
>            0 (make-regexp "^-[a-Z]*h[a-Z]*$|^--help$")
>
> ERROR: In procedure make-regexp:
> In procedure make-regexp: Invalid range end
> 
>
> Here are my versions:
>
> Guile:
>
> 
> xiaolong@xlx200:~/dev/Guile/guile-hall-example-project$ guile
> --version
> guile (GNU Guile) 3.0.2
> Copyright (C) 2020 Free Software Foundation, Inc.
>
> License LGPLv3+: GNU LGPL 3 or later
> <http://gnu.org/licenses/lgpl.html>.
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> 
>
> guile-hall: errors. But it is installed through GUIX package
> manager, so
> it is version:
>
> 
> xiaolong@xlx200:~/dev/Guile/guile-hall-example-project$ guix
> search guile-hall
> guile: warning: failed to install locale
> name: guile-hall
> version: 0.3.1
> outputs: out
> systems: x86_64-linux i686-linux
> dependencies: autoconf@2.69 automake@1.16.2 guile-config@0.4.1
> guile@3.0.2 pkg-config@0.29.2
> + texinfo@6.7
> location: 
> 
> ]8;;file://xlx200/gnu/store/xcyarhvbxz5m3l6yvarryx5wm10j9j4k-guix-module-union/share/guile/site/3.0/gnu/packages/guile-xyz.scmgnu/packages/guile-xyz.scm:1441:2
> ]8;;
> homepage: https://gitlab.com/a-sassmannshausen/guile-hall
> license:  ]8;;https://www.gnu.org/licenses/gpl.htmlGPL 3+ ]8;;
> synopsis: Guile project tooling 
> description: Hall is a command-line application and a set of Guile
> libraries that allow you to
> + quickly create and publish Guile projects.  It allows you to
> transparently support the GNU build
> + system, manage a project hierarchy & provides tight coupling to
> Guix.
> relevance: 20
> 
>
> Any ideas, what could be the problem with my guile-hall?
>
> Regards,
> Zelphir
>


Re: guile-hall error on probably every command

2020-06-11 Thread Zelphir Kaltstahl
I see! I also haven't seen [a-Z] before, anywhere, I think. Thanks for
the explanation!

On 11.06.20 21:09, to...@tuxteam.de wrote:
> On Thu, Jun 11, 2020 at 08:59:35PM +0200, Zelphir Kaltstahl wrote:
>> Hi Guile users!
>>
>> I was about to follow the guile-hall tutorial posted on the list today,
>> but unfortunately, I get an error the first time I need to input a
>> guile-hall command:
> [...]
>
>> In unknown file:
>>0 (make-regexp "^-[a-Z]*h[a-Z]*$|^--help$")
>> ERROR: In procedure make-regexp:
>> In procedure make-regexp: Invalid range end
> I think Guile relies on the system lib for regexps. Not all take [a-Z] as
> a valid range (FWIW my plain "grep" on some Debian GNU/Linux complains
> also about an "invalid range end".
>
> I think the longer version [A-Za-z] is safer.
>
> Cheers
> -- t



Re: guile-hall error on probably every command

2020-06-12 Thread Zelphir Kaltstahl
Hi Alex!

Sounds great! No stress! I'll try it when it is there.

I still have a project, which I would like to publish on GUIX package
manager and I guess guile-hall can help me with that.

Regards,
Zelphir

On 11.06.20 23:22, Alex Sassmannshausen wrote:
> Hi Zelphir,
>
> Always nice to hear someone is interested in Hall!  Sorry you ran into
> this issue though :-(
>
> Aleix and Tomas rightly point out the issue is caused by the regexp
> used in guile-config.  Aleix provided a merge request fixing the issue,
> but as you correctly point out, I have not rolled a new release yet.
>
> I will attempt to release a new version this weekend and push the new
> release to Guix.
>
> I'll make an announcement when it's done!
>
> Best wishes,
>
> Alex
>
> On Thu, 2020-06-11 at 20:59 +0200, Zelphir Kaltstahl wrote:
>> Hi Guile users!
>>
>> I was about to follow the guile-hall tutorial posted on the list
>> today,
>> but unfortunately, I get an error the first time I need to input a
>> guile-hall command:
>>
>> 
>> xiaolong@xlx200:~/dev/Guile/guile-hall-example-project$ hall init
>> dummy --author="Red Nose Hacker" --license="gpl3+" --prefix="guile"
>> --execute
>> guile: warning: failed to install locale
>> Backtrace:
>> In ice-9/boot-9.scm:
>>   1736:10  9 (with-exception-handler _ _ #:unwind? _ # _)
>> In unknown file:
>>8 (apply-smob/0 #)
>> In ice-9/boot-9.scm:
>> 718:2  7 (call-with-prompt _ _ #> handle?>)
>> In ice-9/eval.scm:
>> 619:8  6 (_ #(#(#)))
>>293:34  5 (_ #(#(#) ("/?"
>> ?)))
>> In config.scm:
>> 62:13  4 (getopt-config-auto _ _)
>>106:22  3 (getopt-config-x ("/gnu/store/3ip3nm2kjv046v37gi1wy?" ?)
>> ?)
>> In srfi/srfi-1.scm:
>>836:15  2 (any1 #
>> ?)
>> In ice-9/regex.scm:
>>131:12  1 (string-match "^-[a-Z]*h[a-Z]*$|^--help$"
>> "/gnu/store/3?")
>> In unknown file:
>>0 (make-regexp "^-[a-Z]*h[a-Z]*$|^--help$")
>>
>> ERROR: In procedure make-regexp:
>> In procedure make-regexp: Invalid range end
>> 
>>
>> Here are my versions:
>>
>> Guile:
>>
>> 
>> xiaolong@xlx200:~/dev/Guile/guile-hall-example-project$ guile --
>> version
>> guile (GNU Guile) 3.0.2
>> Copyright (C) 2020 Free Software Foundation, Inc.
>>
>> License LGPLv3+: GNU LGPL 3 or later <
>> http://gnu.org/licenses/lgpl.html>;.
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.
>> 
>>
>> guile-hall: errors. But it is installed through GUIX package manager,
>> so
>> it is version:
>>
>> 
>> xiaolong@xlx200:~/dev/Guile/guile-hall-example-project$ guix search
>> guile-hall
>> guile: warning: failed to install locale
>> name: guile-hall
>> version: 0.3.1
>> outputs: out
>> systems: x86_64-linux i686-linux
>> dependencies: autoconf@2.69 automake@1.16.2 guile-config@0.4.1 
>> guile@3.0.2 pkg-config@0.29.2
>> + texinfo@6.7
>> location:
>> ]8;;file://xlx200/gnu/store/xcyarhvbxz5m3l6yvarryx5wm10j9j4k-guix-
>> module-union/share/guile/site/3.0/gnu/packages/guile-
>> xyz.scmgnu/packages/guile-xyz.scm:1441:2]8;;
>> homepage: https://gitlab.com/a-sassmannshausen/guile-hall
>> license: ]8;;https://www.gnu.org/licenses/gpl.htmlGPL 3+]8;;
>> synopsis: Guile project tooling  
>> description: Hall is a command-line application and a set of Guile
>> libraries that allow you to
>> + quickly create and publish Guile projects.  It allows you to
>> transparently support the GNU build
>> + system, manage a project hierarchy & provides tight coupling to
>> Guix.
>> relevance: 20
>> 
>>
>> Any ideas, what could be the problem with my guile-hall?
>>
>> Regards,
>> Zelphir
>>




Re: guile-hall error on probably every command

2020-06-14 Thread Zelphir Kaltstahl
Hi Ludo!

That would be "MATE Terminal 1.12.1".

Regards,
Zelphir

On 12.06.20 22:34, Ludovic Courtès wrote:
> Hi Zelphir,
>
> Zelphir Kaltstahl  skribis:
>
>> xiaolong@xlx200:~/dev/Guile/guile-hall-example-project$ guix search 
>> guile-hall
>> guile: warning: failed to install locale
>> name: guile-hall
>> version: 0.3.1
>> outputs: out
>> systems: x86_64-linux i686-linux
>> dependencies: autoconf@2.69 automake@1.16.2 guile-config@0.4.1 guile@3.0.2 
>> pkg-config@0.29.2
>> + texinfo@6.7
>> location: 
>> ]8;;file://xlx200/gnu/store/xcyarhvbxz5m3l6yvarryx5wm10j9j4k-guix-module-union/share/guile/site/3.0/gnu/packages/guile-xyz.scmgnu/packages/guile-xyz.scm:1441:2]8;;
>> homepage: https://gitlab.com/a-sassmannshausen/guile-hall
>> license: ]8;;https://www.gnu.org/licenses/gpl.htmlGPL 3+]8;;
> Not related to Hall, but what terminal gave you the above result?
> (Terminals are supposed to ignore escapes that they can’t interpret.)
>
> Ludo’.
>
>




Re: guile-hall error on probably every command

2020-06-16 Thread Zelphir Kaltstahl
Thanks, I will look out for it!

On 14.06.20 22:16, Ludovic Courtès wrote:
> Hi,
>
> Zelphir Kaltstahl  skribis:
>
>> That would be "MATE Terminal 1.12.1".
> Thanks, hopefully it was fixed in the meantime:
>
>   https://issues.guix.gnu.org/41811
>
> Ludo’.



Re: guile-json 4.2.0 released

2020-06-30 Thread Zelphir Kaltstahl
Hi Aleix!

On 6/30/20 9:26 AM, Aleix Conchillo Flaqué wrote:
> Hi!
>
> I'm happy to announce guile-json 4.2.0. This new version introduces a new
> feature to allow converting a JSON object into a record type and vice
> versa. This feature works well, for example, when creating REST APIs. The
> code was originally obtained from GNU Guix (thank you Ludo!) and I added
> the possibility to convert a record type into a JSON object added as well.
>
>  https://github.com/aconchillo/guile-json/

That's quite a nice idea, no matter, where it is from and it is good to
know, that guile-json can do this.

> * About
>
> guile-json is a JSON module for Guile. It supports parsing and
> building JSON documents
> according to the http://json.org specification.
>
> - Complies with http://json.org specification.
> - Builds JSON documents programmatically using scheme data types.
> - Allows JSON pretty printing.
>
> * Download
>
> Compressed sources and a GPG detached signature[*]:
>
> http://download.savannah.nongnu.org/releases/guile-json/guile-json-4.2.0.tar.gz
> http://download.savannah.nongnu.org/releases/guile-json/guile-json-4.2.0.tar.gz.sig
>
> [*] To verify download both files and then run:
>
>gpg --keyserver keys.openpgp.org \
> --recv-keys 7CEC5511C8D057A9EF17470C54D4CC6FFC7468F4
>
>gpg --verify guile-json-4.2.0.tar.gz.sig
>
> * Changes since 4.1.0
>
> https://github.com/aconchillo/guile-json/blob/master/NEWS
>
> Bugs and comments can be reported at https://github.com/aconchillo/guile-
> json/issues
>
> Happy hacking!
>
> Aleix

Thanks for advancing guile-json even further!

Best regards,

Zelphir





Re: Naming conventions

2020-07-07 Thread Zelphir Kaltstahl
Hi Simen!

(comments in between)

On 07.07.20 13:05, Simen Endsjø wrote:
>
> Hi, I'm quite new to scheme/lisp and haven't coded in a dynamic
> language in many
> years. I notice there are some naming conventions, but I'm not sure
> how they are
> used/supposed to be used.
>
> - *symbol* :: ? Global scope variable?
> - SYMBOL :: ? Also global scope variable?
> - %symbol :: ? private function?
> - %symbol% :: ? private variable?


I have seen the % being used for objects. For example in the Racket docs
for its GUI library:
https://docs.racket-lang.org/gui/windowing-overview.html#%28part._.Creating_.Windows%29

I am not sure, whether this is a Racket-only thing.


> - symbol* :: ? extended version of function with same name?
> - symbol? :: predicate function returning bool
> - symbol! :: Non-pure/mutating function?- <> :: ?
> -  :: ? As a macro parameter, and symbol will be defined  in
> parent scope..?
> - <> :: ?
> - type1->type2 :: convertion from type1 to type2
>
> What does all of these mean? Are some of them
> anti-patterns/deprecated? Are there others?
>
> I also see functions named type-operation and operation-type. Is one
> preferable to the other?


Regards,

Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl




Re: "Missing" libraries/concepts found in other languages/ecosystems?

2020-07-08 Thread Zelphir Kaltstahl
Hi Simen!

On 7/8/20 6:00 PM, guile-user-requ...@gnu.org wrote:
> Hi, I'm new to scheme/lisp, so I'm trying to find out how to do 
> things the "lisp
> way". On the other hand, I like things from other ecosystems too, 
> and I'm having
> problems finding this for Guile. It might be because there's no 
> need for it/I'm
> terrible at searching/nobody had the time yet, or something else.
>
> I've been trying to find implementations for https://reactivex.io 
> without any
> luck. And I'm unable to find implementation of FP concepts as 
> found in Haskell
> and other languages. Functor, Monad, lenses (and other helpers for 
> working with
> immutable data).
>
> Does things like this exists, or is it better to use something 
> else?
>
> Regards Simen

To what others already have written I will add:

>From time to time one can copy ideas from Racket or look at what exists
in Racket for solving a problem or seeing what the approach is.

Catonano identified already the lack of examples in the Guile guide. I
fight with that myself, so I created a repository with examples. Perhaps
I should somehow add them to the guide. I've not looked into how to do
that. Probably some commit in a repo somewhere for the guide:

https://notabug.org/ZelphirKaltstahl/guile-examples

Hope this can help!

If you want to create something the Guile ecosystem lacks, I guess you
can find things from other language ecosystems, but it is probably a
good idea to ask in specific about anything existing on the mailing list
and I don't know where else.

So far we have GNU Artanis and the very basic web server module(s). So
in the area of web development on the server side, there is probably a
lot of space for improvements.

On the other hand we Schemers are often minimalistic people in our
approach to programming. Or is that by accident?

Regards,
Zelphir




Re: "Missing" libraries/concepts found in other languages/ecosystems?

2020-07-09 Thread Zelphir Kaltstahl
Hi Leo!

On 7/9/20 8:12 PM, Leo Butler wrote:
> Zelphir Kaltstahl  writes:
>
> 
>
>> To what others already have written I will add:
>>
>> From time to time one can copy ideas from Racket or look at what exists
>> in Racket for solving a problem or seeing what the approach is.
>>
>> Catonano identified already the lack of examples in the Guile guide. I
>> fight with that myself, so I created a repository with examples. Perhaps
>> I should somehow add them to the guide. I've not looked into how to do
>> that. Probably some commit in a repo somewhere for the guide:
>>
>> https://notabug.org/ZelphirKaltstahl/guile-examples
>>
>> Hope this can help!
> Oh yes, thank you. That repository is a gem.
>
> (I think it wouldn't take too much work to transform the repo as is into
> a texinfo document on its own.)
>
> ---
>
> The guile guide has been knocked. I agree that it could use more
> examples, but I have found it is well-written and accurate.
>
> Leo

Thanks for the compliment.

I agree with the guide being well written. Once I see an example or
figure one out (not always hard to do, but sometimes), I think: "Hmm ah
yes, actually that was sort of in the guide …". Perhaps I am a different
kind of learner or too used to the "example culture" in other languages,
where you can find almost everything on StackOverflow.

Of course examples would be nice to have, not going to argue against that.






Re: "Missing" libraries/concepts found in other languages/ecosystems?

2020-07-10 Thread Zelphir Kaltstahl
Hi all!

On 7/10/20 1:20 PM, Catonano wrote:
> Il giorno ven 10 lug 2020 alle ore 12:21 Chris Vine 
> ha scritto:
>
>> On Fri, 10 Jul 2020 10:49:37 +0200
>> Catonano  wrote:
>>> Il giorno mer 8 lug 2020 alle ore 20:22 Zelphir Kaltstahl <
>>> zelphirkaltst...@gmail.com> ha scritto:
>>>
>>>> Hi Simen!
>>>>
>>>> On 7/8/20 6:00 PM, guile-user-requ...@gnu.org wrote:
>>>>> Hi, I'm new to scheme/lisp, so I'm trying to find out how to do
>>>>> things the "lisp
>>>>> way". On the other hand, I like things from other ecosystems too,
>>>>> and I'm having
>>>>> problems finding this for Guile. It might be because there's no
>>>>> need for it/I'm
>>>>> terrible at searching/nobody had the time yet, or something else.
>>>>>
>>>>> I've been trying to find implementations for https://reactivex.io
>>>>> without any
>>>>> luck. And I'm unable to find implementation of FP concepts as
>>>>> found in Haskell
>>>>> and other languages. Functor, Monad, lenses (and other helpers for
>>>>> working with
>>>>> immutable data).
>>>>>
>>>>> Does things like this exists, or is it better to use something
>>>>> else?
>>>>>
>>>>> Regards Simen
>>>> To what others already have written I will add:
>>>>
>>>> From time to time one can copy ideas from Racket or look at what exists
>>>> in Racket for solving a problem or seeing what the approach is.
>>>>
>>>> Catonano identified already the lack of examples in the Guile guide. I
>>>> fight with that myself, so I created a repository with examples.
>> Perhaps
>>>> I should somehow add them to the guide. I've not looked into how to do
>>>> that. Probably some commit in a repo somewhere for the guide:
>>>>
>>>> https://notabug.org/ZelphirKaltstahl/guile-examples
>>>>
>>>> Hope this can help!
>>>>
>>> Thank you, yes that helps
>>>
>>> In fact, it's a precious resource !
>>>
>>> I was especially delighted with the examples of using exceptions !
>>>
>>> I had so missed examples of those !
>>>
>>> As for the manual, very recently a mention of Guile Hall ended up being
>>> included in the manual
>>>
>>> The same could be done with your examples collection
>>>
>>> I also think that your collection could be mentioned by the Guile web
>> site,
>>> maybe in the "learn" section
>>>
>>> Here's the repo for the web site:
>>> https://git.savannah.gnu.org/cgit/guile/guile-web.git/
>>>
>>> a regular patch could do
>>>
>>> What do people think of mentioning this resource on the Guile web site ?
>> Whilst I don't have strong feelings, as a general approach I think it is
>> better to include additional examples (where needed) in the body of the
>> manual, which I think is generally well written.
>>
> As long as some examples are reachable from an officially sanctioned
> documentation source, I'm ok with that
>
> What I find problematic is the casualness in referring to bits scattered
> all around
>
> The web site was just an idea, the manual would be perfectly fine
>
> Also, at this level of detail what some find helpful others don't.  You
>> were delighted above with the exceptions example, whereas (if I read
>> the right one) I thought that that was one of the weaker ones.  It
>> concentrates on R6RS/R7RS exceptions and with-exception-handler rather
>> than with guile's much easier to use catch expression (for guile-2.2)
>> or (for guile-3.0) its beefed-up with-exception-handler and exception
>> objects.
>>
> Ah there has been a misunderstanding here
>
> I was convinced that the exceptions example was of the last layout for
> using exceptions reached recently in Guile 3.x
>
> If it's not, I agree it's less valuable
>
> But I think the author was just confused or led astray by the casualness of
> referring to scattered bits, I'm not blaming them
>
> I'd be grateful if anyone with enough understanding of the issue would
> contribute a proper example of how to use exceptions according to the last
> exceptions reorganization in Guile 3.x
>
> I would be happy to send a patch for the manual containing such example and
&g

Re: "Missing" libraries/concepts found in other languages/ecosystems?

2020-07-10 Thread Zelphir Kaltstahl
The comments about exception handling also reminded me of the following
blog post:

https://blog.sulami.xyz/posts/common-lisp-restarts/

Pretty cool concept as well.

If there anything like it in Guile or is something like it possible
(probably, right?)?


On 7/11/20 2:19 AM, Zelphir Kaltstahl wrote:
> Hi all!
>
> On 7/10/20 1:20 PM, Catonano wrote:
>> Il giorno ven 10 lug 2020 alle ore 12:21 Chris Vine 
>> ha scritto:
>>
>>> On Fri, 10 Jul 2020 10:49:37 +0200
>>> Catonano  wrote:
>>>> Il giorno mer 8 lug 2020 alle ore 20:22 Zelphir Kaltstahl <
>>>> zelphirkaltst...@gmail.com> ha scritto:
>>>>
>>>>> Hi Simen!
>>>>>
>>>>> On 7/8/20 6:00 PM, guile-user-requ...@gnu.org wrote:
>>>>>> Hi, I'm new to scheme/lisp, so I'm trying to find out how to do
>>>>>> things the "lisp
>>>>>> way". On the other hand, I like things from other ecosystems too,
>>>>>> and I'm having
>>>>>> problems finding this for Guile. It might be because there's no
>>>>>> need for it/I'm
>>>>>> terrible at searching/nobody had the time yet, or something else.
>>>>>>
>>>>>> I've been trying to find implementations for https://reactivex.io
>>>>>> without any
>>>>>> luck. And I'm unable to find implementation of FP concepts as
>>>>>> found in Haskell
>>>>>> and other languages. Functor, Monad, lenses (and other helpers for
>>>>>> working with
>>>>>> immutable data).
>>>>>>
>>>>>> Does things like this exists, or is it better to use something
>>>>>> else?
>>>>>>
>>>>>> Regards Simen
>>>>> To what others already have written I will add:
>>>>>
>>>>> From time to time one can copy ideas from Racket or look at what exists
>>>>> in Racket for solving a problem or seeing what the approach is.
>>>>>
>>>>> Catonano identified already the lack of examples in the Guile guide. I
>>>>> fight with that myself, so I created a repository with examples.
>>> Perhaps
>>>>> I should somehow add them to the guide. I've not looked into how to do
>>>>> that. Probably some commit in a repo somewhere for the guide:
>>>>>
>>>>> https://notabug.org/ZelphirKaltstahl/guile-examples
>>>>>
>>>>> Hope this can help!
>>>>>
>>>> Thank you, yes that helps
>>>>
>>>> In fact, it's a precious resource !
>>>>
>>>> I was especially delighted with the examples of using exceptions !
>>>>
>>>> I had so missed examples of those !
>>>>
>>>> As for the manual, very recently a mention of Guile Hall ended up being
>>>> included in the manual
>>>>
>>>> The same could be done with your examples collection
>>>>
>>>> I also think that your collection could be mentioned by the Guile web
>>> site,
>>>> maybe in the "learn" section
>>>>
>>>> Here's the repo for the web site:
>>>> https://git.savannah.gnu.org/cgit/guile/guile-web.git/
>>>>
>>>> a regular patch could do
>>>>
>>>> What do people think of mentioning this resource on the Guile web site ?
>>> Whilst I don't have strong feelings, as a general approach I think it is
>>> better to include additional examples (where needed) in the body of the
>>> manual, which I think is generally well written.
>>>
>> As long as some examples are reachable from an officially sanctioned
>> documentation source, I'm ok with that
>>
>> What I find problematic is the casualness in referring to bits scattered
>> all around
>>
>> The web site was just an idea, the manual would be perfectly fine
>>
>> Also, at this level of detail what some find helpful others don't.  You
>>> were delighted above with the exceptions example, whereas (if I read
>>> the right one) I thought that that was one of the weaker ones.  It
>>> concentrates on R6RS/R7RS exceptions and with-exception-handler rather
>>> than with guile's much easier to use catch expression (for guile-2.2)
>>> or (for guile-3.0) its beefed-up with-exception-handler and exception
>>> objects.
>>>
>> Ah

Re: "Missing" libraries/concepts found in other languages/ecosystems?

2020-07-12 Thread Zelphir Kaltstahl
Hi!

On 7/12/20 6:08 PM, Catonano wrote:
> Il giorno sab 11 lug 2020 alle ore 12:14 Chris Vine 
> ha scritto:
>
>> On Sat, 11 Jul 2020 02:19:43 +0200
>> Zelphir Kaltstahl  wrote:
>> [snip]
>>> I would be glad, if any non-optimal example was extended or updated by a
>>> more knowledgeable person or I was told what I could improve in some
>>> example. The examples in the repository are only, what I was able to
>>> understand and I often find myself looking up, how to do something again.
>>>
>>> If anyone wants to take any example and put it in the docs, go ahead.
>>> Only don't think that my examples are the last word on how to do things.
>>> Far from it!
>>>
>>> About the exceptions thing: Aha! I should look into that again. I
>>> thought the "conditions" thing was already pretty cool and useful. Once
>>> an exception happens, you can react on it. I did not understand the
>>> "call/ec helper" part, but perhaps I can understand it, when I check the
>>> docs for the new exceptions in Guile 3.
>> The issue is that "non-continuable" in "non-continuable exception" does
>> not mean an exception that the program cannot survive, it means an
>> exception for which, after handling, control cannot return to the point
>> at which the exception was raised[1].  (To answer the question in your
>> following email, continuable exceptions are in some sense analogous to
>> common lisp restarts.)  Most guile exceptions are non-continuable.  The
>> point arising from this is that in the case of a non-continuable
>> exception the handler procedure passed to with-exception-handler must
>> not return, or a &non-continuable exception will be raised when
>> control does attempt to return.
>>
>> With R6RS/R7RS's with-exception-handler, for non-continuable exceptions
>> the handler procedure should normally therefore either invoke a call/ec
>> continuation object to unwind the stack to the point where the
>> exception is handled, or it should (after it has done what it is
>> intended to do) re-raise the exception to be handled and/or unwound
>> elsewhere.  Guile-3.0's with-exception-handler procedure will do the
>> former for you automatically if you set its #:unwind? argument to
>> true.  The nearest to guile-2.2's catch expression in guile-3.0's
>> exception system is to use with-exception-handler with #:unwind? set
>> as #t.  R6RS/R7RS's guard form is a wrapper for this which also
>> incorporates a cond form to enable different exception types to be
>> handled by different handlers.
>>
>> I therefore suggest that your first example using
>> with-exception-handler should set #:unwind? to #t so that the program
>> does not end with a &non-continuable exception.  I also suggest that,
>> if intended for guile-3.0 and not guile-2.2, you should use guile's
>> exception objects rather than R6RS conditions (basically you use
>> 'make-exception' instead of 'condition' - the two are in effect the
>> same).
>>
>
> If it can be of any help, I applied your suggestions to the original
> example
>
> This is supposed to be compatible with Guile 3.x only
>
> Here it is (a question follows)
>
> (define even-simpler-display
>   (lambda (sth)
> (display
>  (simple-format
>   #f "~a\n" sth
>
>
> (define divide
>   (lambda (a b)
> (cond
>  [(= b 0)
>   (raise-continuable
>(make-exception
> (make-exception-with-message "division by zero")
> (make-exception-with-irritants (list a b))
> (make-exception-with-origin 'divide)))]
>  [else
>   (/ a b)])))
>
>
> (with-exception-handler
> (lambda (conditions-or-value)
>   (even-simpler-display
>;; We can get the simple exceptions from a compound exception with
> the
>;; `simple-exceptions` getter.
>(simple-exceptions conditions-or-value)))
>   (lambda ()
> (divide 2 0))
> #:unwind? #t)
>
> I run this in the REPL and it seems to work
>
> The question, now, is:
>
> say that the exception handler knows (somehow) that the correct divisor is
> 1 rather than 0
>
> So we are saying that this exception is continuable
>
> How would we continue ?
>
> Can "divide" return as if it had been called with 1 as its second argument ?
>
> Or have I misunderstood ?
>
> How would you go about that ?

Ah, I started putting "to do changes" in a list to apply them later,
with better understanding:
https://notabug.org/ZelphirKaltstahl/guile-examples/src/d670fa02369918cd3fa896cc19d5aa82966f64a3/exception-handling/notes.org
I was going to come back to points, if I do not understand anything
properly.

Perhaps I can already copy some parts from here^^

Thanks!
Zelphir




Starting a GNU Guile awesome list

2020-07-13 Thread Zelphir Kaltstahl
Hello Guile Users,

I followed up on that idea I mentioned recently on the mailing list and
started creating an awesome list:

https://notabug.org/ZelphirKaltstahl/awesome-guile

I'd prefer to render only the org-mode file, as that is what I write and
feel most comfortable in, but I decided that the wrong / incomplete
rendering on notabug would seriously limit accessibility, so I exported
markdown and texinfo from org-mode.

If you know more things, which should be added to the list, please tell
me or create a PR or open an issue or … you get it.

Also links to usage examples would be very welcome.

I would like to keep the list informal and easily extendable. A few
questions though:

  * Do you think license information should be written next to each item
in the list?
  * Do you think each item should have a short description or not? Or
perhaps whenever one is readily available?
  * Do you think the rendered readme.md should be handwritten instead of
exported from org-mode? (Perhaps I should not ask this question …
the amount of markdown typing … my fingers hurt.)

Best regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl



Re: Starting a GNU Guile awesome list

2020-07-14 Thread Zelphir Kaltstahl
Hi Dmitry!


On 7/14/20 11:00 AM, Dmitry Alexandrov wrote:
> Zelphir Kaltstahl  wrote:
>> I ‹…› started creating an awesome list
>> https://notabug.org/ZelphirKaltstahl/awesome-guile
> +1!
>
> However, even if you are not going to apply for inclusion¹ in meta-list 
> <https://awesome.re> and therefore are free from complying with all rules 
> that might come to the mind of a macboy in state of administrative ecstasy²; 
> calling your list ‘an awesome list’ implies a certain format nonetheless.
>
> And that format actually answers two of the there of your questions.

Thanks for informing and mentioning those things! I did not even know.


> -
> ¹ In any case, I am not sure, whether they accept lists with the primary 
> repository outside of github.com at all.

I'm surely not going to create any repositories on GitHub in the near
future, unless somehow MS becomes the new saint of the free software
movement ; )


> ² E. g., recently he had broken local clones and invalidated all the 
> pull-request backlog by renaming ‘master’ branch to ‘main’, and now require 
> all the lists to follow his example.

Ha, the whole thing about renaming master branch sounds so silly to me,
I'd never do that. Perhaps that person got too much time or something.

I wonder, can people even still get a "master degree" or write a "master
thesis"? Can I still write my master degree on my CV or is it now shameful?


>> * Do you think each item should have a short description or not?
> Thatʼs the key feature of ‘awesome lists’, number one in the ‘manifesto’ [1]:
>
> | Comment on why something is awesome
> |
> | Apart from suggesting a particular item on your list, you should also 
> inform your readers why it's on the list and how they will benefit from it.
>
> [1] https://github.com/sindresorhus/awesome/blob/main/awesome.md

OK, it can be useful. I'll see, when and if I can get around to writing
the descriptions.

The thing is: For some modules / packages / libraries I don't even know
how to describe them correctly and would need the authors' help or quote
their texts. It would be nice, if people sharing adding Guile things to
the list gave short descriptions, if able to do so.


>> * Do you think the rendered readme.md should be handwritten instead of 
>> exported from org-mode?
> Again, ‘awesome list’ format implies [2] Markdown as a source format.  Nobody 
> says, though, that a source is something handtyped.
>
> [2] https://github.com/sindresorhus/awesome/blob/main/pull_request_template.md

To me this awesome list thing seemed like an Internet software
development phenomenon, which would be nice to carry into the Guile
world, in order to increase discoverability. That's how I have
experienced it so far. I've never even heard of https://awesome.re. I
should have looked it up / researched it more, beforehand. Didn't think
there was anything more to it, than creating a list inside a repository.

I think their rules are theirs and we can do as we wish. I don't think
anyone can claim the word "awesome" as a prefix for themselves and
impose rules on how anything has to be, when having the prefix. However,
I'd consider using another word instead (Why not do our own thing?), if
it is consensus (What do people think about renaming the list?), that
the name should be changed due to the list at https://awesome.re
existing and the author of that trying to impose stuff. Possibly this
comes at the cost of a little bit of discoverability. There is still
"ingenious guile" :D


>> (Perhaps I should not ask this question …  the amount of markdown typing … 
>> my fingers hurt.)
> ???  The only thing where org-mode saves typing over markdown-mode is ToC 
> generation.  But there are lots ToC helpers for Markdown!  (describe-package 
> 'markdown-toc), for instance.
>
> In the case you will stick with Org, there at least should be a runnable 
> build recipe (i. e. a Makefile).

I'm sorry, you are (understandably) misunderstanding me here. I was not
very clear.

I've been hinting at RSI, which I need to look out for, not at any
advantage in number of characters or key presses to type in Markdown vs
Org-mode : ) I am not even sure which one would require less typing,
considering the comfort Emacs offers for org-mode.

In Emacs one can easily export to Markdown from Org-mode or to many
other formats. The table of contents is already generated by org-mode
export. I am not sure, whether one can use Emacs functionality from
outside of Emacs. I remember there being a library about Emacs stuff,
possibly written in Guile. Forgot the name though. It was I think also
shared on this mailing list at least once. (I should probably find it
again and put it on the list!)

What I will not do is discarding the or

Re: Starting a GNU Guile awesome list

2020-07-14 Thread Zelphir Kaltstahl
Hi Aleix!

On 14.07.20 00:56, Aleix Conchillo Flaqué wrote:
>
>
> On Mon, Jul 13, 2020 at 2:20 PM Zelphir Kaltstahl
> mailto:zelphirkaltst...@posteo.de>> wrote:
>
> Hello Guile Users,
>
> I followed up on that idea I mentioned recently on the mailing
> list and
> started creating an awesome list:
>
> https://notabug.org/ZelphirKaltstahl/awesome-guile
>
> I'd prefer to render only the org-mode file, as that is what I
> write and
> feel most comfortable in, but I decided that the wrong / incomplete
> rendering on notabug would seriously limit accessibility, so I
> exported
> markdown and texinfo from org-mode.
>
> If you know more things, which should be added to the list, please
> tell
> me or create a PR or open an issue or … you get it.
>
> Also links to usage examples would be very welcome.
>
> I would like to keep the list informal and easily extendable. A few
> questions though:
>
>   * Do you think license information should be written next to
> each item
>     in the list?
>   * Do you think each item should have a short description or not? Or
>     perhaps whenever one is readily available?
>   * Do you think the rendered readme.md should be handwritten
> instead of
>     exported from org-mode? (Perhaps I should not ask this question …
>     the amount of markdown typing … my fingers hurt.)
>
>
> This is awesome :-) Zelphir!
>
> - I don't think license should be included. It might change (even
> though it usually does not) but if so it would be hard to maintain.
> - Maybe that would be good. The list could be actually simplified with
> just (with sections as you already have):
>
> [project](url): description.    (using markdown format here)
>
> I would actually remove repository and documentation links and just
> depend on the project's URL. I believe it will be easier to maintain
> (plus shorter), IMHO.
>
> - Not everyone is used to org-mode. Do you have any specific setup
> that generates the markdown file? Or is it vanilla org-mode? If you
> keep it simple as I suggested it might be easier to maintain a
> handwritten version.
>
> Whatever it is, this is great!
>
> Btw, a couple of my own missing: 
> https://github.com/aconchillo/homebrew-guile
> https://github.com/aconchillo/guile-xmlrpc
>
> Best,
> Aleix

I don't have a special setup currently, only exporting straight out of
org-mode.

Thank you for your input!

Regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl



Re: Starting a GNU Guile awesome list

2020-07-15 Thread Zelphir Kaltstahl
Hi Arne,

On 15.07.20 08:36, Dr. Arne Babenhauserheide wrote:
> Zelphir Kaltstahl  writes:
>
>> One can write whole scientific books in org-mode
> Or roleplaying books, which actually have higher requirements :-)
> (I did both)
>
>>>> * Do you think license information should be written next to each item in 
>>>> the list?
>>> First at foremost, the list _itself_ has to be licensed as a free 
>>> documentation.  FWIW, most of ‘awesome lists’ are under CC0.
>> While the list is not CC0, I meant to put it under "GNU Free
>> Documentation License v1.3", which I think should be appropriate (Is it
>> not?) and free as in freedom. Good that you hint at the license, because
>> I thought it had a license already.
> GFDL isn’t considered as free by the debian standards, because it can
> have invariant sections. CC by-sa might be a good fit, since it is
> compatible with GPLv3 and wikipedia at the same time.
>
> Best wishes,
> Arne

Thanks for providing more info on the licenses.

I just read multiple articles about GFDL and CC0 and still don't know
what the better choice is for the list.

In particular I do not find information about whether CC0 is copyleft or
not (1), which perhaps means, that it is not and I do not understand the
impact of invariant sections on the list (2).

Can you help me out?

Best regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl





Re: Starting a GNU Guile awesome list

2020-07-15 Thread Zelphir Kaltstahl
Hi Arne!

On 14.07.20 16:14, Dr. Arne Babenhauserheide wrote:
> Zelphir Kaltstahl  writes:
>
>> https://notabug.org/ZelphirKaltstahl/awesome-guile
>>
>> If you know more things, which should be added to the list, please tell
>> me or create a PR or open an issue or … you get it.
> Would enter-three-witches apply? Write executable game-stories like
> theater plays, as used in dryads-wake:
> https://hg.sr.ht/~arnebab/dryads-wake
>
> Example: 
> https://hg.sr.ht/~arnebab/dryads-wake/browse/dryads-wake.w?rev=c677727bbd2c#L1129

I will add dryad-awake under "Games".

Do you have some repository link for "enter-three-witches"?

>>   * Do you think the rendered readme.md should be handwritten instead of
>> exported from org-mode? (Perhaps I should not ask this question …
>> the amount of markdown typing … my fingers hurt.)
> I prefer org-mode, a lot. And it is easy to write with other tools. Also
> it can export to beautiful LaTeX and allows embedding tweaks for that.
>
> Liebe Grüße,
> Arne

Regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl




Re: A licence for an ‘awesome list’ (was: Starting a GNU Guile awesome list)

2020-07-16 Thread Zelphir Kaltstahl
Hi Dmitry!

On 16.07.20 11:18, Dmitry Alexandrov wrote:
> Zelphir Kaltstahl  wrote:
>> On 15.07.20 08:36, Dr. Arne Babenhauserheide wrote:
>>> Zelphir Kaltstahl  writes:
>>>>> First at foremost, the list _itself_ has to be licensed as a free 
>>>>> documentation.  FWIW, most of ‘awesome lists’ are under CC0.
>>>> While the list is not CC0, I meant to put it under "GNU Free Documentation 
>>>> License v1.3", which I think should be appropriate (Is it not?) and free 
>>>> as in freedom. Good that you hint at the license, because I thought it had 
>>>> a license already.
>>> GFDL isn’t considered as free by the debian standards, because it can have 
>>> invariant sections. CC by-sa might be a good fit, since it is compatible 
>>> with GPLv3 and wikipedia at the same time.
>> I just read multiple articles about GFDL and CC0 and still don't know what 
>> the better choice is for the list.
> Sometimes itʼs better to read a text itself than multiple texts about text. 
> ;-)  As least FSF have always tried to keep their licences in English, not 
> legalese.
>
> Doing it, you would find out right away, than GNU FDL is a licence for 
> “manuals, textbooks, or other functional and useful documents”; and most of 
> it is about things like ‘Front Cover’, ‘Back Cover’, ‘Title Page’, 
> ‘Dedications’, ‘Endorsements’, etc, and what one have to do when printing 
> 101+ copies.
>
> What is not written in it, though, is the fact itʼs _not_ compatible with any 
> version of GNU GPL.
>
>> In particular I do not find information about whether CC0 is copyleft or not 
>> (1)
> Quoth <https://www.gnu.org/licenses/license-list.html#CC0> (emphasis mine):
> | A work released under CC0 is dedicated to the public domain to the fullest 
> extent permitted by law. If that is not possible for any reason, CC0 also 
> provides a *lax, permissive* license as a fallback. Both public domain works 
> and the lax license provided by CC0 are compatible with the GNU GPL.
> |
> | If you want to release your non-software work to the public domain, we 
> recommend you use CC0.
>
> Besides being GPL-compatible, itʼs FDL-compatible as well, while CC BY-SA is 
> not.

I read on https://www.gnu.org/licenses/license-list.html#CC0 about the 2
licenses, but not the original text, assuming, that they are multiple
hour reads for the purpose of understanding them.

Specifically about GFDL it says:

"We also recommend the GNU FDL for dictionaries, encyclopedias, and any
other works that provide information for practical use."

That /"[…] any other works that provide information for practical use."/
seems like a perfect fit for a list of links meant to help people find
stuff.

But then in the text about CC0 it says:

/"If you want to release your non-software work to the public domain, we
recommend you use CC0."/

OK, again seems like a perfect fit. It is not software work, only a list
of links to software. So with that knowledge both GFDL and CC0 seem to
be recommended. CC0 does not have copyleft character, which is why I
currently think GFDL might be better. But then again it has been
expressed in responses, that it is not compatible with GPL and CC0 has
been brought up.

Perhaps I am misinterpreting the mentioning of CC0 as a preference here?

What is the impact or are the consequences of incompatibility with GPL,
with regard to the list of links?

I also read a lot on
https://www.debian.org/vote/2006/vote_001.en.html#amendmenttexta.
Somehow invariant sections seem to not apply in the case of the awesome
list project, except perhaps for the pretext?

It also says there:

/"[…] GFDL allows everybody who disagrees with a personal position
expressed in an invariant section to add their own secondary section and
to describe their objections or additions. This is a reasonable method
to improve the available secondary sections, a method that does not lead
to misrepresenting the authors opinion or to censorship."/

That sounds like a good idea to me.

I guess what I would like most would be CC0 with copyleft or GFDL
without any problems from invariant sections or problems stemming from
incompatibility with GNU GPL.

On the same page it also says:

/"For this reason, we encourage documentation authors to license their
works (or dual-license, together with the GFDL) under the same terms as
the software they refer to, or any of the traditional free software
licenses like the GPL or the BSD license."/

But I thought GPL is only meant to be used for software? Think I read
that many times in the past, that you should not use GPL for things
other than software.

Or is it simply GPL that fit the bill of what I am looking for?

Ultimately I also want to choose something the community agrees with,
since I would like it to be a resource from and for the community.

Regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl



Re: Handling object communication in GOOPS

2020-07-17 Thread Zelphir Kaltstahl
Hello Jan,

to me this sounds like you need to implement perhaps 2 things:

1. a setter for the , which takes care of updating things,
when a completely new  is added.

2. some kind of observer pattern, where the  registers
itself as a listener to changes in the . Probably a method
at the , something like `register-change-listener`, which
adds the argument it takes to a list or a set of listeners. Then you
need to take care, that on relevant updates all registered listeners are
notified of the change.

Furthermore you can register the  as a listener at the
 when the  is set using the setter and
unregister as listener at the previously set  (which is now
replaced by the new one).

I have not worked with GOOPS yet, so my answer is not GOOPS specific and
perhaps there are better ways, but I think this is the classic approach
to the problem.

Regards,
Zelphir

On 17.07.20 01:24, Jan Wielkiewicz wrote:
> Hello,
>
> I would like make objects of two different classes communicate, but I'm
> not sure how to implement it or if there already exists something for
> the purpose.
>
> Say I have two classes:  and .
> During initialization of an  object, it creates a slot
> containing  object.
>
> I would like to make the  object to know when address in
> the address bar is changed, for example (set-address address-bar1
> "/home/user").
>
> Any suggestions? Thanks in advance.
>
>
> Jan Wielkiewicz
>
-- 
repositories: https://notabug.org/ZelphirKaltstahl





Another find for Guile software

2020-07-21 Thread Zelphir Kaltstahl
Hi Guile Users!

Today evening I accidentally found
http://sph.mn/foreign/guile-software.csv, when searching for
guile-web-diver. Thought it could be a good find for people on the list.

I'll go through it and add things from it to the awesome list as well.

(Thanks Tantalum!)

Regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl




Re: test anything? (Re: My Guile Hacker Handbook)

2020-07-23 Thread Zelphir Kaltstahl
Definitely. Already marking e-mails as "extract information" to add to
the list later. I also already added your tutorial in the tutorial
category. ; )

On 23.07.20 12:40, Jérémy Korwin-Zmijowski wrote:
> Hi Frank and Marc,
>
> I've never tried to use these frameworks. I will give them a try.
>
> They could be part of the awesome-guile list Zelphir initiated.
>
> Thank you for bringing this and also taking time to give feedback !
>
> Jérémy
>
>
-- 
repositories: https://notabug.org/ZelphirKaltstahl




  1   2   3   4   >