[Rd] assign("FALSE", TRUE)

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Wed Nov 19 13:24:26 CET 2008


Martin Maechler wrote:
> but notably not mainly by the above. I'd consider the backtick
> operator as -- very nice -- syntactic sugar for  
> assign() and get().
>
> And, for "normal" identifiers,
>
>     foo   <- 1
>     `foo` <- 1
>     assign("foo", 1)
>   

"foo" <- 1
# same effect as above

> and 
>     foo
>     `foo`
>     get("foo")
>   

"foo"
# not 1?

(that is to say, i find this a tiny little bit incoherent, but perhaps
useful for assignments, as " is easier to get from my keyboard than `)

> are each three-fold equivalent.  If a user does not *know* about
> keywords/reserved words, (s)he can get a bit confused by 
> how e.g. break or `break` e.g. are handled:
> Recall that Joe Average User does not know about assign, get,
> `..` etc, but does know about  ls()  and typing an object name:
> If he does ls(), sees "break"  (which stems from previous
> assign("break", 3) or `break` <- 3)
> and then types 
>   > break
>   or 
>   > str(break)
>   
btw. i find the following sequence of error messages a tiny little bit
confusing:

break(1)
# Error: no loop to break from, jumping to top level

"break" = function(arg) arg
break(1)
# Error in break : argument "arg" is missing, with no default

"break" = function(arg=1) arg
break(1)
# Error: attempt to apply non-function

"if" = function(arg) arg
if(1)
# keeps waiting for more input
if(1) 2
# Error in if (1) 2 : unused argument(s) (2)


vQ



More information about the R-devel mailing list