From: Dmitry Gutov <dgutov@yandex.ru>
To: emacs-devel@gnu.org
Subject: Re: with-url
Date: Sun, 1 Jan 2017 04:07:56 +0300 [thread overview]
Message-ID: <9bd035f3-c7cd-0c8d-81b8-226fb24f608e@yandex.ru> (raw)
In-Reply-To: <87mvffva75.fsf@gnus.org>
On 29.12.2016 03:41, Lars Ingebrigtsen wrote:
> That is, you can put the error handling form at the start if the first
> symbol is `error' in that form. Well, it can't be `error', but perhaps
> `url-error'. Or...
>
> Opinions? :-)
I think you're trying to magic it up too much, by adding error handling
forms to the macro. Personally, I'd prefer to use condition-case to
handle errors.
Of course, that will require a new error type (or several) to be defined.
That usage conflicts with asynchronous requests, though. More on that
later (*).
Another thing to note is that a 404 status should be an error for some
applications, but others would prefer to treat all statuses the same,
avoid following redirects, etc, and parse the response headers and body
anyway. So whether `with-url' should signal an error in those cases,
should probably be governed by another keyword argument. In "serious"
libraries, in e.g. Ruby, we make this choice using wrappers, like
client-side middleware.
Something else I take an issue with, is with `with-url' being a macro.
:) That violates The First Rule of Macro Club.
I think we can do without, by using one of the more traditional control
flow solutions. First of all, the fact that `url-retrieve' uses a
callback is one of its lesser problems. The arguments that the callback
gets passed are a much bigger one. So we would stop at fixing just that.
The other options are:
1) Return a Promise value. Emacs could use a standardized Promise
structure in other places, too.
2) Basically require to use the newly-introduced threads for asynchrony.
The library would suspend the current thread and resume it when
something happens (a response or an error). Someone should investigate
the validity of this approach, but the good news is, it can be layered
on top of (1) later. This option can also be compatible with using
`condition-case' to handle errors (*).
next prev parent reply other threads:[~2017-01-01 1:07 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-29 0:41 with-url Lars Ingebrigtsen
2016-12-29 1:06 ` with-url Stefan Monnier
2016-12-29 1:12 ` with-url Lars Ingebrigtsen
2016-12-29 16:05 ` with-url Eli Zaretskii
2016-12-29 16:35 ` with-url Lars Ingebrigtsen
2016-12-29 16:40 ` with-url Lars Ingebrigtsen
2016-12-29 16:58 ` with-url Eli Zaretskii
2016-12-29 18:52 ` with-url Lars Ingebrigtsen
2016-12-29 20:31 ` with-url Eli Zaretskii
2016-12-30 14:12 ` with-url Lars Ingebrigtsen
2016-12-30 15:23 ` with-url Lars Ingebrigtsen
2016-12-30 16:58 ` with-url Eli Zaretskii
2017-01-21 15:31 ` with-url Lars Ingebrigtsen
2017-01-21 15:33 ` with-url Lars Ingebrigtsen
2017-01-21 15:54 ` with-url Eli Zaretskii
2017-01-21 16:32 ` with-url Lars Ingebrigtsen
2017-01-21 16:40 ` with-url Eli Zaretskii
2017-01-22 15:55 ` with-url Lars Ingebrigtsen
2017-01-22 16:39 ` with-url Eli Zaretskii
2016-12-29 16:53 ` with-url Eli Zaretskii
2016-12-29 18:48 ` with-url Lars Ingebrigtsen
2017-01-01 1:07 ` Dmitry Gutov [this message]
2017-01-03 17:47 ` with-url Stefan Monnier
2017-01-26 23:00 ` with-url Ted Zlatanov
2017-01-26 23:08 ` with-url Lars Ingebrigtsen
2017-01-27 13:49 ` with-url Ted Zlatanov
2017-01-21 15:44 ` with-url Lars Ingebrigtsen
2017-01-21 20:26 ` with-url Dmitry Gutov
2017-01-21 20:32 ` with-url Lars Ingebrigtsen
2017-01-21 20:36 ` with-url Dmitry Gutov
2017-01-21 20:49 ` with-url Lars Ingebrigtsen
2017-01-21 21:05 ` with-url Dmitry Gutov
2017-01-21 21:12 ` with-url Lars Ingebrigtsen
2017-01-21 21:16 ` with-url Dmitry Gutov
2017-01-21 21:23 ` with-url Lars Ingebrigtsen
2017-01-21 21:27 ` with-url Dmitry Gutov
2017-01-21 21:37 ` with-url Lars Ingebrigtsen
2017-01-21 21:54 ` with-url Dmitry Gutov
2017-01-21 22:07 ` with-url Lars Ingebrigtsen
2017-01-22 12:14 ` with-url Yuri Khan
2017-01-22 14:46 ` with-url Lars Ingebrigtsen
2017-01-22 15:13 ` with-url Dmitry Gutov
2017-01-22 16:36 ` with-url Eli Zaretskii
2017-01-22 21:27 ` with-url Dmitry Gutov
2017-01-22 14:22 ` with-url Dmitry Gutov
2017-01-22 14:42 ` with-url Lars Ingebrigtsen
2017-01-21 20:34 ` with-url Lars Ingebrigtsen
2017-01-21 20:38 ` with-url Dmitry Gutov
2017-01-21 20:48 ` with-url Lars Ingebrigtsen
2017-01-21 22:25 ` with-url John Mastro
2017-01-22 16:04 ` with-url Lars Ingebrigtsen
2017-01-22 16:42 ` with-url Eli Zaretskii
2017-01-22 16:55 ` with-url Lars Ingebrigtsen
2017-01-22 23:56 ` not with-url Richard Stallman
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/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9bd035f3-c7cd-0c8d-81b8-226fb24f608e@yandex.ru \
--to=dgutov@yandex.ru \
--cc=emacs-devel@gnu.org \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).