unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Christopher Allan Webber <cwebber@dustycloud.org>
To: Marko Rauhamaa <marko@pacujo.net>
Cc: guile-user@gnu.org
Subject: Re: 8sync tutorial part 1
Date: Sun, 24 Apr 2016 17:15:00 -0500	[thread overview]
Message-ID: <87d1peejrv.fsf@dustycloud.org> (raw)
In-Reply-To: <87a8kiwwbo.fsf@elektro.pacujo.net>

Marko Rauhamaa writes:

> Christopher Allan Webber <cwebber@dustycloud.org>:
>
>>   http://dustycloud.org/tmp/8sync-tutorial-part1.html
>>
>> It gets into the basics of the agenda, using delays to keep things
>> simple.
>
> Comments:
>
>  * A typo: The text talks about "run-at" but the example has
>    "run-delay".

You're right!  Fixed.  Run-at exists, but is not what we're using here.

>  * I'm guessing "run-delay" is a macro. In my opinion you should use
>    macros very sparingly. Here, the only point of the macro seems to be
>    to avoid a "lambda". I would prefer:
>
>      (run-delay (lambda (hello-snore)) 1)

I'm not sure how this one would run...

>    or -- in this particular case --
>
>      (run-delay hello-snore 1)

Anyway, yes you're right, run, run-at, and foo are all macros to
simplify things.  As said in the document though, you don't have to use
them.  They're very lightweight sugar around (make-run-request).  The
tutorial even shows you how to not use them and construct the
run-request yourself!  The run-request gets sent back to the agenda, and
is used to build the next step of the queue.  You can always return your
own run-request object.

The (8sync (run-this-func 'some-arg)) stuff however *does* use a macro
in a way that's not easy to do yourself.  You could do it on your own,
but the macro takes care of a lot of stuff very carefully for you:
constructing the promise, aborting to the prompt, taking the information
returned from the asynchronously run procedure and returning it, and
catching errors in the asynchronous procedure and re-raising them in the
original procedure (!!!!) which are all nice features.

I tried looking into how to do these with just procedures, but I found no
nice way to do it.  You don't have to use the (8sync) special form,
though, and just break things up into a lot of manual procedures which
return run-requests.  It *will* make your life a lot easier to use the
(8sync) special form though.

>  * I'm guessing the "run-delay" macro as well as "start-agenda" operate
>    on a singleton, global context.

They don't, so that assumption is wrong.

The only "global" in the system is that there's a parameterized prompt
that is aborted to if you use the (8sync) special form.  Again, if you
just return run-request objects at the end of the procedure call and
don't use (8sync) that's never even brought into play.  But aborting via
delimited continuations is too good of a win.

Even there, you could avoid the parameter!  You could pass in the prompt
symbol to every function you might want to abort to.  It would require a
lot of manual plumbing, or a lot of complicated monad massaging, but you
can do it today as-is with the existing library.  But you'd have to do
all the work that the (8sync) special form does for you, and my guess is
that by the time you start working your way through that, you'll find
that it makes your life a lot easier.

>> IO / ports stuff is coming in the next chapter.
>
> That's when things will get interesting. Looking forward to the
> installment.

Yes, I think so too.  :)

> Warning: I actually *like* the callback hell, which you have said you
> want to avoid. On the other hand, the first chapter of the tutorial
> seems to consist of nothing but callbacks!

Nothing but callbacks with the exception of the (8sync-delay), and
that's true :)

If you like callback hell, you can live in it with 8sync too... that's
totally compatible with 8sync's agenda!  8sync just provides a path out,
if you want it.

Thanks for the feedback!
 - Chris



  reply	other threads:[~2016-04-24 22:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-24 20:22 8sync tutorial part 1 Christopher Allan Webber
2016-04-24 21:06 ` Marko Rauhamaa
2016-04-24 22:15   ` Christopher Allan Webber [this message]
2016-04-25  4:50     ` Marko Rauhamaa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d1peejrv.fsf@dustycloud.org \
    --to=cwebber@dustycloud.org \
    --cc=guile-user@gnu.org \
    --cc=marko@pacujo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).