From @purdle@@ @ending from gm@il@com  Tue Oct 16 01:02:40 2018
From: @purdle@@ @ending from gm@il@com (Abs Spurdle)
Date: Tue, 16 Oct 2018 12:02:40 +1300
Subject: [Rd] 
 sys.call() inside replacement functions incorrectly returns *tmp*
In-Reply-To: <F139A45B-0BDF-41FC-A809-9A00AC2E79A0@dans.knaw.nl>
References: <CAB8pepwA52R9ZKOe7_83BMWzwsQcZ8eKG+wg3ihBL5+Qs5YPOQ@mail.gmail.com>
 <F139A45B-0BDF-41FC-A809-9A00AC2E79A0@dans.knaw.nl>
Message-ID: <CAB8pepxoVFZvBnuBFyfyOwTNWTyA_pQOjr4za-zeWmeFTiaBqw@mail.gmail.com>

Kia Ora

> Although I'm not sure what problem it would solve...

Given that you asked, I was interested in writing a multiple assignment
function as a replacement function, so something like:
massign (x, y, z) = construct.some list ()

Obviously, that's not possible.

Probably the best example I can think of is converting cartesian
coordinates to polar coordinates.
Then we might have something like (note, untested, written in my email):
cart2polar = function (x, y)
    list (theta=atan (y / x), r=sqrt (x * x + y * y) )

massign (r, theta) = cart2polar (x, y)

Now, I'm considering a multiple assignment operator, so something like:
c (theta, r) $<-$ cart2polar (x, y)

And while we're on the topic, I'm also considering an attribute operator
(to access object attributes), something like:
myobject%$%myattribute

This would be similar to . in C++/Java or @ in S4.
And seems like something obvious that's missing from R.

Implementing an attribute read this way is easy, however, implementing an
attribute assignment this way (without language level support) is difficult.


kind regards
Abs

	[[alternative HTML version deleted]]



[Rd] sys.call() inside replacement functions incorrectly returns *tmp*
Abs Spurdle