From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: with-url Date: Sat, 21 Jan 2017 23:26:07 +0300 Message-ID: References: <87mvffva75.fsf@gnus.org> <9bd035f3-c7cd-0c8d-81b8-226fb24f608e@yandex.ru> <87bmv0beoa.fsf@gnus.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1485030419 20968 195.159.176.226 (21 Jan 2017 20:26:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 21 Jan 2017 20:26:59 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Thunderbird/51.0 Cc: emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 21 21:26:52 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cV2FP-0004is-C7 for ged-emacs-devel@m.gmane.org; Sat, 21 Jan 2017 21:26:51 +0100 Original-Received: from localhost ([::1]:33231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cV2FU-00009m-04 for ged-emacs-devel@m.gmane.org; Sat, 21 Jan 2017 15:26:56 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cV2Eq-00009U-Kj for emacs-devel@gnu.org; Sat, 21 Jan 2017 15:26:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cV2En-0004ov-2V for emacs-devel@gnu.org; Sat, 21 Jan 2017 15:26:16 -0500 Original-Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:36478) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cV2Em-0004oW-Rp for emacs-devel@gnu.org; Sat, 21 Jan 2017 15:26:13 -0500 Original-Received: by mail-lf0-x241.google.com with SMTP id h65so11113137lfi.3 for ; Sat, 21 Jan 2017 12:26:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=/VxsAwznp4LYjlr6pDJZYWOIkHbhN6KvXQtWxxSNOzE=; b=W4fr+AZucJ7agddwCAeb2lvEryqcDFbQEso59ZH1HFwSu4xxrxib6RSPZkpVkGh0ng iIuS0h7ZFiurRQ3fa12V9+gCrqzpzcbG4qA8luQ+Df5qHScTehLSWgfJLGOGpRe/C1Nq 8/3ZK4r8pAFGCuvxG00TbdrVLnPY7B7qd3kU+BizVNk7h+t0VkXVNT+C7Q+ebBWanMBu fy1RaoEqSLhNi96QQeckldnAy57TViJe4pAXlHGMAtJSN003bI10VaUjUxx/NuQD+/39 jqfrGO5n7TYEMGKJsTgPqKsKztPXfwYlJ4JSd5jyZgazLIgaEsdDOyi8Mwg/7Lv0earR pXew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/VxsAwznp4LYjlr6pDJZYWOIkHbhN6KvXQtWxxSNOzE=; b=kMedSc3s1vG0d9IbMb1RTqhAotBgZwstIT/MqTqW3W7fcm+L+dhlSDfd7O8jBmOwAz sDYpQ89umVGE8Ar4XtKHqwH2OVh9HHvLIouxwBK9A53X3pnkgs2xZrH6FZs5uOlshKO1 OyjvpHxhSlTwziFXt1K9YqNFHPhnqTzlQSX1kbcK5leD4SFmnPDV6LDcK9xGccvd0gem AKKIUvI6KWXQVi/FIwVvUCCvxRtx+oKjFeuHxmMJoqkSNr6Wm182JPfrQwHXaHKzr1NK Q6DB75gVYxgx1Lw/sQXRkfmvGinylXjyFxq/mpTVXMev4Tk9lfoRfp98iMKjcN23iE6i 9oPQ== X-Gm-Message-State: AIkVDXKi0sT5j5K5gomO6GTWYgEez3+WOrops2aX50ZNl6MIvoU203vl1Hg1FCI5FGxu5g== X-Received: by 10.25.4.9 with SMTP id 9mr6154488lfe.45.1485030369802; Sat, 21 Jan 2017 12:26:09 -0800 (PST) Original-Received: from [192.168.1.174] ([178.252.127.239]) by smtp.googlemail.com with ESMTPSA id 4sm4817075ljv.40.2017.01.21.12.26.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Jan 2017 12:26:08 -0800 (PST) In-Reply-To: <87bmv0beoa.fsf@gnus.org> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::241 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:211488 Archived-At: On 21.01.2017 18:44, Lars Ingebrigtsen wrote: > Nope. You should only signal an error if you have an error, and getting > a 404 isn't an error. Whether 404 is an error or not, depends on an application. And I'm saying that as someone with a few years of experience writing web applications that do HTTP requests themselves. Consider the case where an application calls a function foo (which implements some sort of abstraction layer), and the said function uses with-url. If foo is supposed to be general purpose (used in different applications), it would have to handle errors in a general way, so that any of its callers could still handle any kinds of errors, without being a macro. I'd rather with-url (or its replacement) was an example of doing that already. >> Something else I take an issue with, is with `with-url' being a >> macro. :) That violates The First Rule of Macro Club. > > Yes, the first rule is "use a macro when it makes sense". Not really. And macros make sense the most when we add a control flow construct, or some sort of definition syntax for a new facility. Neither of which is really the case here. You're basically joining a library function with a control flow construct together. >> 2) Basically require to use the newly-introduced threads for >> asynchrony. > > Using the new threads is a trivial rewrite and doesn't affect the > signature of the macro. It could simplify it, by allowing to treat asynchronous code like synchronous one. > Anyway, I think the best option here would be to just have an > :ignore-errors parameter to `with-url'. In that case, the body will > just be evaluated if we get non-error response. I'm rather more worried about being able to handle errors in an asynchronous fashion. You could say 404 is not an error, but handling it in a similar way to all other "actual" errors like "can't resolve the hostname" and "connection timeout" can be pretty handy.