Re: [Rd] WISH: Sys.setlocale() to return value invisibly

2020-03-25 Thread Henrik Bengtsson
I case someone runs into this topic.  I just found the following
comment from 2012 on BugZilla explaining why Sys.setlocale() does
*not* return invisibly contrary to most++ other setters in R:

PR#15128: Sys.setlocale() - return previous setting invisibly?

Brian Ripley on 2012-12-09 16:53:43 UTC:
> It was a deliberate decision. Unlike options() the locale is usually set at 
> startup and it is major thing to change it in a session--and it is usually 
> only done recording the previous value to return to. The author certainly 
> wanted to see what he was changing from in a session.

https://bugs.r-project.org/bugzilla/show_bug.cgi?id=15128#c1

/Henrik

On Tue, Mar 20, 2018 at 2:11 PM Henrik Bengtsson
 wrote:
>
> Contrary to, say, Sys.setenv(), Sys.setlocale() returns it's value
> visibly.  This means that if you for instance add:
>
> Sys.setlocale("LC_COLLATE", "C")
>
> to your .Rprofile file, it will print:
>
> [1] "C"
>
> at startup. The workaround is to wrap the call in invisible(), but I'd
> argue that any "setter" function should return invisibly.
>
> Some more details:
>
> > withVisible(Sys.setlocale("LC_COLLATE", "C"))
> $value
> [1] "C"
>
> $visible
> [1] TRUE
>
> > withVisible(Sys.setenv(FOO = "C"))
> $value
> [1] TRUE
>
> $visible
> [1] FALSE
>
> /Henrik

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] WISH: Sys.setlocale() to return value invisibly

2018-03-20 Thread Henrik Bengtsson
Contrary to, say, Sys.setenv(), Sys.setlocale() returns it's value
visibly.  This means that if you for instance add:

Sys.setlocale("LC_COLLATE", "C")

to your .Rprofile file, it will print:

[1] "C"

at startup. The workaround is to wrap the call in invisible(), but I'd
argue that any "setter" function should return invisibly.

Some more details:

> withVisible(Sys.setlocale("LC_COLLATE", "C"))
$value
[1] "C"

$visible
[1] TRUE

> withVisible(Sys.setenv(FOO = "C"))
$value
[1] TRUE

$visible
[1] FALSE

/Henrik

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel