From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nala Ginrut Newsgroups: gmane.lisp.guile.devel Subject: [Request] How about adding with-locale? Date: Sat, 24 Mar 2012 12:37:50 +0800 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d042fd94024836b04bbf5b4f9 X-Trace: dough.gmane.org 1332563883 8958 80.91.229.3 (24 Mar 2012 04:38:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 24 Mar 2012 04:38:03 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Mar 24 05:38:03 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SBIjq-0002D3-G8 for guile-devel@m.gmane.org; Sat, 24 Mar 2012 05:38:02 +0100 Original-Received: from localhost ([::1]:58144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBIjp-00074w-9u for guile-devel@m.gmane.org; Sat, 24 Mar 2012 00:38:01 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:33215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBIji-00074j-KA for guile-devel@gnu.org; Sat, 24 Mar 2012 00:37:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SBIjg-0000i5-O9 for guile-devel@gnu.org; Sat, 24 Mar 2012 00:37:54 -0400 Original-Received: from mail-vx0-f169.google.com ([209.85.220.169]:43907) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBIjg-0000hZ-Hy for guile-devel@gnu.org; Sat, 24 Mar 2012 00:37:52 -0400 Original-Received: by vcbfk14 with SMTP id fk14so4174146vcb.0 for ; Fri, 23 Mar 2012 21:37:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=h7zuFlYrVY21Ya30zW9o0MzM8StlkcFlJ/sryCZhwAw=; b=vV326Al7jAr3A4LTUFv6Us8LylUF3w2dcrPkOrpfCaT5pz9B/FOXnkxVn1Crj/UJi2 5CHA2t24NjVTdLZqJh7ZBX6I9X2RgQI+hwl7qKLtD/IraHluoWb2JtX713xqWpz6vdFg pdyrr/csyOWKq2AcT77/q8ECtwZbl6dHUK/UJFT+odjLYCGo8vBkwXv3cxRedHMHWvcN ldmjm+6TpxyNVfmnGEESsyvESCd2Mojd2aNnmRtMru8fjFUNcdQb2SuhYPsiNzdFhk+a tmPHA4esiQ2k7xbkYH1MlJqVSmK39xyx722WEkwJ9vTpvFMH9IwiYsVwElaxBNaUuckw fGoQ== Original-Received: by 10.220.116.20 with SMTP id k20mr7286677vcq.54.1332563870515; Fri, 23 Mar 2012 21:37:50 -0700 (PDT) Original-Received: by 10.52.88.231 with HTTP; Fri, 23 Mar 2012 21:37:50 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.220.169 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:14174 Archived-At: --f46d042fd94024836b04bbf5b4f9 Content-Type: text/plain; charset=UTF-8 Hi folks! I encountered a bug in my project for these days. Finally I realized it's because of my locale is zh_CN.UTF-8 in default. But in many protocols, it needs the result of strftime be in English. Anyway, I think there should be an elegant way to change locale temperately. So I think maybe with-locale would be useful. --------------------------------------------------------------------- (define-syntax-rule (with-locale i c e0 e1 ...) (let ([old (setlocale i)]) (dynamic-wind (lambda () (setlocale i c)) (lambda () (begin e0 e1 ...)) (lambda () (setlocale i old))))) --------------------------------------------------------------------- What you guys think? Regards. --f46d042fd94024836b04bbf5b4f9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi folks!
I encountered a bug in my project for these days. Finally I re= alized it's because of my locale is zh_CN.UTF-8 in default. But in many= protocols, it needs
the result of strftime be in English. Anyway, I thi= nk there should be an elegant way to change locale temperately. So I think = maybe with-locale would be useful.

---------------------------------------------------------------------(define-syntax-rule (with-locale i c e0 e1 ...)
=C2=A0 (let ([old (set= locale i)])
=C2=A0=C2=A0=C2=A0 (dynamic-wind
=C2=A0=C2=A0=C2=A0 (lamb= da () (setlocale i c))
=C2=A0=C2=A0=C2=A0 (lambda () (begin e0 e1 ...))<= br> =C2=A0=C2=A0=C2=A0 (lambda () (setlocale i old)))))
--------------------= -------------------------------------------------

What you guys thin= k?

Regards.
--f46d042fd94024836b04bbf5b4f9--