guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Request] How about adding with-locale?


From: Nala Ginrut
Subject: Re: [Request] How about adding with-locale?
Date: Sat, 24 Mar 2012 16:45:49 +0800



On Sat, Mar 24, 2012 at 2:54 PM, Mark H Weaver <address@hidden> wrote:
Nala Ginrut <address@hidden> writes:
> I know it's not the best implementation, I didn't consider the
> multi-threads situation.

Yes, unfortunately there is no way to set the locale on a per-thread
basis.  This is a limitation of the C library.


Will it be a proper solution if I use "monitor"?
------------------------------------------------------------------
(define-syntax-rule (with-locale i c e0 e1 ...)
  (let ([old (setlocale i)])
    (monitor
      (dynamic-wind
       (lambda () (setlocale i c))
       (lambda () (begin e0 e1 ...))
       (lambda () (setlocale i old))))))
------------------------------------------------------------------

But I believe it will drag my program based on multi-threads much slowly.
And I'm considering to drop my old design, so that I can set locale to "C" in default.
 
>     in many protocols, it needs
>     the result of strftime be in English.

For protocol use, IMO it's better to avoid 'strftime' and other
locale-specific formatting tools.  For example, 'write-date' in
module/web/http.scm is a simple date formatter based on SRFI-19.


I guess I should change the old code into new Guile web API. It's more completely. 

Regards.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]