[R] unicode variable and function names?

Duncan Murdoch murdoch.duncan at gmail.com
Tue Jan 4 02:32:52 CET 2011


On 11-01-03 7:44 PM, stvienna wiener wrote:
> Dear List,
>
>
> Is it possible to have function names like ∀ (unicode universal quantifier)?
> This question is inspired by agda source code, which supports this.
>
> http://www.cs.nott.ac.uk/~nad/listings/lib-0.4/Algebra.html
>
> It would be handy to use. My guess is, however, that it's not supportet in R.

Why not just try it?  I get this:

 > ∀ <- 1
Error: unexpected input in "‚"
 > `∀` <- 1

i.e. it is seen as a non-syntactic name, so needs backquotes to be used, 
but then it's fine (except it's probably a bad idea, since non-UTF8 
systems will have trouble with it).  Looks like the error message needs 
fixing.

I was surprised how hard it was to find this documented, but it is there 
in the Introduction to R manual in section 1.8,  "R commands, case 
sensitivity, etc."  Someday someone should add this to the Language 
Definition manual.  The rule is that syntactic names need to start with 
. or a letter, and contain only letters, digits, . and _.  The confusing 
part is that "letter" doesn't have a universal definition, so the manual 
suggests limiting them to ASCII letters.

Duncan Murdoch



More information about the R-help mailing list