Stavros Macrakis wrote: > On Thu, Dec 18, 2008 at 1:37 PM, Wacek Kusnierczyk < > waclaw.marcin.kusnierc...@idi.ntnu.no> wrote: > > >> Kenn Konstabel wrote: >> >>>> ...foo({x = 2}) >>>> >> ... >> >> This is legal but doesn't do what you probably expect -- although >> >>> documentation for `<-` says the value (returned by <-) is 'value' i.e. >>> whatever is on the right side ... >>> > >
(just to make clear: here stavros is answering kenn, not me) > What do you expect this to do that is different from what it does, namely > assign 2 to x and call foo on the value 2, which is the same as the value of > x? As long as foo doesn't do tricks with substitute, all the following > should be identical: > <snip> > >>> [kenn] If you really hate <-, you should do either >>> foo({(x=42)}) # or .... >>> > > Why the () nested within the {} ? Either one alone is enough. > > these are not identical: x = 1 (x = 1) <snip> >> [vQ] who said = is more intuitive for assignments? i said i prefer it, and >> that's because of aesthetics, silly me. in an earlier post, someone >> said it is more natural for his students [1]. argue to the contrary. >> >> it depends on how you program, mostly. if you're doing functional >> programming with no reassignments, = is just perfect. >> >> > > The character string denoting assignment really has no deep importance, > whether it's = (Fortran, C); := (Algol, Pascal, Ada); <- (R); : (Maxima); > etc. However, using the same symbol to denote two quite different things > which can be meaningful in the same contexts, namely assignment and argument > naming, strikes me as a poor design decision. > as i said, my choice is based on aesthetics, silly me. i find many enough poor design decisions in r not be concerned with this superficial detail. vQ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.