Re: a cookbook

2022-02-16 Thread Catonano
Il giorno lun 14 feb 2022 alle ore 17:56 Olivier Dion via Developers list
for Guile, the GNU extensibility library  I've started a small TexInfo manual for that.  I will try to share it by
> the end of the week or this weekend.
>
> Thank you, Olivier
>
> I'm looking forward to it
>


Re: a cookbook

2022-02-16 Thread Catonano
Il giorno lun 14 feb 2022 alle ore 18:01 Vijay Marupudi <
vi...@vijaymarupudi.com> ha scritto:

> > Is there any interest/possibility to have such a cookbook hosted
> > within the Guile official documentation (as it is for Guix) ?
>
> I personally think that a Cookbook should be an independent effort, with
> links from the Guile Manual if possible. This would lighten the load on
> the maintainers, and allow for quicker collaboration.
>

but then the discoverability of the cookbook would be diminished 🙁





> I've personally started on this effort yesterday, writing about error
> handling in Guile.
>
> https://vijaymarupudi.com/blog/2022-02-13-error-handling-in-guile.html
>
> I'd be happy to create a website compiling everything together, but the
> hard part is writing and finding the tutorials.
>


First: thank you so much for this write up about the new exception
framework !

I couldn't come around and read it yet but this has been sorely missing
until now !

As for you creating a web site, I'd prefer such a website to be a
communitarian effort, rather than depend on a single person

Maybe a wiki on Gitlab could do and it could have several mantainers ?
I'd be happy to be one

This is a test by me
https://gitlab.com/humanitiesNerd/guilecookbook/-/wikis/read-a-file

I could add a page with a collection of the tutorials you indicated, better
yet if you would do that yourself 🙂

It's pretty dry now but it's also pretty young 🙂

Maybe it can grow, given some time 🙂


Re: a cookbook

2022-02-16 Thread Neil Jerram
On Wed, 16 Feb 2022 at 09:04, Catonano  wrote:
>
> Il giorno lun 14 feb 2022 alle ore 18:01 Vijay Marupudi 
>  ha scritto:
>>
>> > Is there any interest/possibility to have such a cookbook hosted
>> > within the Guile official documentation (as it is for Guix) ?
>>
>> I personally think that a Cookbook should be an independent effort, with
>> links from the Guile Manual if possible. This would lighten the load on
>> the maintainers, and allow for quicker collaboration.
>
>
> but then the discoverability of the cookbook would be diminished 🙁

Yes, agree that the resulting cookbook needs to be easily
discoverable.  Perhaps that means that if you install a guile-doc
package, it appears as a top-level Info item like Guile Reference
does.  Perhaps it doesn't need to be quite as specific as that.
(Although personally I really like doc being available locally, e.g.
in Info form, instead of always going online.)

But as you also say...

> [...]
>
> As for you creating a web site, I'd prefer such a website to be a 
> communitarian effort, rather than depend on a single person
>
> Maybe a wiki on Gitlab could do and it could have several mantainers ?
> I'd be happy to be one

Yes, definitely feels right to crowd-source this, instead of having it
centralized in the core Guile repo.

It feels to me that with the right structure in place, people will
readily come and contribute the detailed material to it.  So it's
worth spending a little time to decide the right structure.

Best wishes,
Neil



Re: a cookbook

2022-02-16 Thread Developers list for Guile, the GNU extensibility library
On Mon, 14 Feb 2022, Vijay Marupudi  wrote:
>> Is there any interest/possibility to have such a cookbook hosted
>> within the Guile official documentation (as it is for Guix) ?

> I've personally started on this effort yesterday, writing about error
> handling in Guile.
>
> https://vijaymarupudi.com/blog/2022-02-13-error-handling-in-guile.html

Awesome blogpost.  Very clean and fun to read!  Is this generated with
static website generator for org-mode?

-- 
Olivier Dion
Polymtl



Re: a cookbook

2022-02-16 Thread Catonano
Il giorno mer 16 feb 2022 alle ore 10:54 Neil Jerram 
ha scritto:

>
>
>
> > As for you creating a web site, I'd prefer such a website to be a
> communitarian effort, rather than depend on a single person
> >
> > Maybe a wiki on Gitlab could do and it could have several mantainers ?
> > I'd be happy to be one
>
> Yes, definitely feels right to crowd-source this, instead of having it
> centralized in the core Guile repo.
>
> It feels to me that with the right structure in place, people will
> readily come and contribute the detailed material to it.  So it's
> worth spending a little time to decide the right structure.
>

Have you any suggestion about a structure you would deem appropriate ?


Re: a cookbook

2022-02-16 Thread Vijay Marupudi
> Awesome blogpost.  Very clean and fun to read!  Is this generated with
> static website generator for org-mode?

That's great to hear! Appreciate the feedback, I'm glad the writing
style is working, will try to maintain it.

The website is a static website that is implemented in Guile, but does
not use any static website generator library.

However, it does use Nectar, which is a markup library that allows you
to use Guile in the markup itself. I will write documentation for it
soon, and try to implement an Org-Mode converter (Markdown was recently
implemented). My goal is to use the library to supercharge the tutorial
and guide writing and viewing experience. Nectar will allow me to make a
very interactive and useful website, for which content can also be
transpiled into Texinfo, Markdown, Plain text, Org-Mode, or anything else
people would like.

My website was a dogfooding attempt, and it has worked well, so
hopefully more good things to come :)

Blog post source / Nectar sample:
https://gitlab.com/vijaymarupudi/vijaymarupudi.com/-/blob/master/content/2022-02-13-error-handling-in-guile.nct

Nectar: https://gitlab.com/vijaymarupudi/nectar

Website source code: https://gitlab.com/vijaymarupudi/vijaymarupudi.com



Re: Pausable continuations

2022-02-16 Thread Stefan Israelsson Tampe
I have been working on improving the interface, And this works
(define gen
  (make-generator
   (lambda (x)
 (let lp ((i 0))
   (when (< i 2000)
 (return x i)
 (lp (+ i 1)))

(define (test)
  (let ((g (gen)))
(let lp ((s 0))
  (let ((i (next g)))
(if (eq? i 'finished)
s
(lp (+ s i)))

This nice funktional interface runs with no measurable speed overhead
compared to old cases. Also this is essentially python generators and this
code runs in 0.3s where a python generator example runs in 0.5s, using
delimited continuation we are talking about 6-7s.

On Sun, Feb 13, 2022 at 11:31 AM Stefan Israelsson Tampe <
stefan.ita...@gmail.com> wrote:

> (define (f x)
>   (let lp ((i 0))
> (if (< i 10)
> (begin
>   (pk 'value-from-parent (pause x i))
>   (lp (+ i 1))
>
> (define (test-1)
>   (let ((x   (make-pause-stack))
> (ret 0))
> (let lp ((i 0))
>   (let-values (((k x) (resume x (- i
> (cond
>  ((= k pause)
>   (pk 'value-from-child x)
>   (lp (+ i 1)))
>
>  ((= k parent)
>   (pk 'parent))
>
>  ((= k leave)
>   (pk 'leave))
>
>  ((= k child)
>   (pk 'child)
>   (f x)
>   (leave x)
>   (set! ret  i)
>
>
> (pk 'finish x)
> ret))
>
> On Sun, Feb 13, 2022 at 11:27 AM Mikael Djurfeldt 
> wrote:
>
>> Hi,
>>
>> I'm trying to understand this.
>>
>> The example of a generator which you give below counts upwards, but I
>> don't see how the value of n is passed out of the generator.
>>
>> Could you give another example of a generator which does pass out the
>> values, along with a usage case which prints out the values returned by the
>> generator?
>>
>> Best regards,
>> Mikael
>>
>> Den tors 10 feb. 2022 17:52Stefan Israelsson Tampe <
>> stefan.ita...@gmail.com> skrev:
>>
>>> Consider a memory barrier idiom constructed from
>>> 0, (mk-stack)
>>> 1. (enter x)
>>> 2. (pause x)
>>> 3. (leave x)
>>>
>>> The idea is that we create a separate stack object and when entering it,
>>> we will swap the current stack with the one in the argument saving the
>>> current stack in x  and be in the 'child' state and move to a paused
>>> position in case of a pause, when pausing stack x, we will return to where
>>> after where entered saving the current position in stack and ip, and be in
>>> state 'pause' and when we leave we will be in the state 'leave and move
>>> to the old stack, using the current
>>> ip. At first encounter the function stack frame is copied over hence
>>> there will be a fork limited to the function only.
>>>
>>> This means that we essentially can define a generator as
>>> (define (g x)
>>>   (let lp ((n 0))
>>> (if (< n 10)
>>> (begin
>>>(pause x)
>>>(lp (+ n 1))
>>>
>>> And use it as
>>> (define (test)
>>> (let ((x (mk-stack)))
>>> (let lp ()
>>>(case (enter x)
>>>((pause)
>>>(pk 'pause)
>>>(lp))
>>> ((child)
>>>  (g x)
>>>  (leave x
>>>
>>> A paused or leaved stack cannot be paused, an entered stack cannot be
>>> entered and one cannot leave a paused stack, but enter a leaved stack.
>>>
>>> Anyhow this idea is modeled like a fork command instead of functional
>>> and have the benefit over delimited continuations that one does not need to
>>> copy the whole stack and potentially speed up generator like constructs.
>>> But not only this, writing efficient prolog code is possible as well. We
>>> could simplify a lot of the generation of prolog code, speed it up and also
>>> improve compiler speed of prolog code significantly.
>>>
>>> How would we approach the  prolog code. The simplest system is to use
>>> return the
>>> alternate pause stack when succeeding things becomes very simple,
>>>
>>> x   = stack to pause to in case of failure
>>> cc = the continuation
>>>
>>> ( (x cc)  goal1 goal2)
>>>  :: (cc (goal1 (goal2 x))
>>>
>>> (   (x cc)  goal1 goal2)
>>> ::  (let ((xx (mkstack)))
>>>  (case (enter xx)
>>>  ((child)
>>>   (cc (goal2 xx)))
>>>
>>> ((pause)
>>>  (cc (goal2 x)
>>>
>>> Very elegant, and we also can use some heuristics to store already made
>>> stacks when
>>> leaving a stack and reuse at the next enter which is a common theme in
>>> prolog,
>>>
>>> Anyhow we have an issue, consider the case where everythings
>>> succeds forever. Then we will blow the stack . There is no concept of tail
>>> calls here. So what you can do is the following for an ,
>>>
>>> (let ((xx (mk-stack)))
>>> (case (enter xx)
>>>   ((child)
>>>(goal1 x (lambda (xxx) (pause xx xxx)))
>>>
>>>   ((pause xxx)
>>>  (goal2 xxx cc
>>>
>>> This enable cuts so that a cutted and (and!) in kanren lingo will use
>>> (g

Re: a cookbook

2022-02-16 Thread Catonano
Hi,


> I've personally started on this effort yesterday, writing about error
> handling in Guile.
>
> https://vijaymarupudi.com/blog/2022-02-13-error-handling-in-guile.html
>
>
I've finally read your post

It's nice that it clears the distinction between old forms and new ones

I'd like to have continuable exceptions covered, though

Those are the main departure of Guile from more widespread exception
handling solutions and as far as I can tell something similar is available
only in Common Lisp so drawing experience/intuition from other languages is
more difficult/rare