behavior of =

A.J. Rossini
08 Nov 2002 08:41:57 -0800

>>>>> "philippe" == Philippe Grosjean <> writes:

    philippe> Deprecating '_' for assignment in the perspective of reusing it in variables
    philippe> names is nice (not just a personal impression bacause it is also common in
    philippe> other languages). I am fighting too often with unreadable codes like
    philippe> var_value, even without spaces before and after '_'!!!
    philippe> Addition of '=' for assignment is nice too (also commonly used in other
    philippe> languages), except for this problem with named arguments...! I know this is
    philippe> a major change that would require patching all R code, but perhaps a
    philippe> solution would be to replace '=' in named arguments with something else,...
    philippe> ('_'  for instance.. no, I am kidding!). But perhaps, ':=' would be a nice
    philippe> candidate. So:

    philippe> foo(a=b)  # Assignment of b to a, and a is passed as first argument to
    philippe> function foo()
    philippe> foo(a:=b) # b is passed to the named argument 'a' of function foo()

No, no, no.

While I can see depreciating "_" as assignment, I would seriously
worry about reusing it in variable names, breaking old code and all of
that.  Currently, we've got "."  for separation if you need it.
Sure, other languages use it for methods, and in a sense, so does S3
classes, but it's what you are given.

The "<-" assignment operator is beautiful.  It's taken me over a
decade, but I have come to appreciate it.  It isn't common, and there
are fewer and fewer ex-APL'ers, but I think it's a great choice.

The use of "=" for named arguments in a function call signature makes
sense, and the use of "==" for equality makes sense.

But syntactical sugar should only be messed with if broken (and yes,
this may be one of the few points that I'd disagree with John; I wish
he'd never introduced "=" as a possible assignment).


A.J. Rossini				Rsrch. Asst. Prof. of Biostatistics
U. of Washington Biostatistics	
FHCRC/SCHARP/HIV Vaccine Trials Net
-------------- ----------------
FHCRC: M: 206-667-7025 (fax=4812)|Voicemail is pretty sketchy/use Email
UW:   Th: 206-543-1044 (fax=3286)|Change last 4 digits of phone to FAX
(my tuesday/wednesday/friday locations are completely unpredictable.)

r-devel mailing list -- Read
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: