From Waclaw.Marcin.Kusnierczyk at idi.ntnu.no  Sat Mar  7 23:28:32 2009
From: Waclaw.Marcin.Kusnierczyk at idi.ntnu.no (Wacek Kusnierczyk)
Date: Sat, 07 Mar 2009 23:28:32 +0100
Subject: [Rd] question
In-Reply-To: <49B2B125.4030609@TU-Dresden.de>
References: <49B23FA7.9090006@idi.ntnu.no>	<000325575fc2f3201e046488263f@google.com>	<971536df0903070628x46a4951dt9d14da97ea720dd0@mail.gmail.com>	<50d1c22d0903070638g2a2f65dexefc45b69d4118dfe@mail.gmail.com>	<49B2ACAF.5030905@pburns.seanet.com>
	<49B2B125.4030609@TU-Dresden.de>
Message-ID: <49B2F510.6050906@idi.ntnu.no>

Thomas Petzoldt wrote:
> Patrick Burns wrote:
>> One idea of program design is that users
>> should be protected against themselves.

... and r coherently implements this idea :]

>>
>> It is my experience that users, especially
>> novices, tend to over-split items rather than
>> over-clump items.  The fact that items are
>> returned by the same function call would
>> argue to me that there is a connection between
>> the items.
>>
>>
>> Patrick Burns
>> patrick at burns-stat.com
>> +44 (0)20 8525 0696
>> http://www.burns-stat.com
>> (home of "The R Inferno" and "A Guide for the Unwilling S User")
>
> Hi Gabor, Patrick, Ivo and vQ,

hello thomas,

>
> I agree with Patrick and Gabor that it is not needed. IMHO it is good
> design that a function (in a mathematical sense) returns ONE object,
> let it a single value, a list or an S3/S4 object. 

in r functions are not functions in the mathematical sense.  r is not
quite a functional programming language, though it's certainly closer to
fp than c or fortran, say.

if one were really interested in whether the feature is desired as a
convenience rather than in enforcing one's own opinion, one'd ask
users.  it's certainly not *needed* in the sense that you can do without
it -- but then there are many more features in r which are not needed
(and some of them are more harmful than multiple return values would be).


> This can be passed to another function as a whole or can be splitted
> to its parts according to different needs. 

right, but that's extra work with coding and performance penalty. 

> If only single parts are required, than I would suggest to use
> accessor functions preferably written as generics working on returned
> S3 or S4 objects. I'm strongly against going back to the past S
> behaviour and I wonder a little bit about this discussion. 

i don't know that s behaviour, it's quite possible that it was really
wrong.  but the fact that s had it wrong (if it did) does not mean that
multiple return values are wrong per se.

> I like it to have a clean workspace with only a few objects.

why would letting others choose for themselves be a bad idea?  that's
what perl, python, ruby, or more recent languages such as scala, do --
functions can return (tuples of) multiple values which you can capture
separately and/or collectively.  multiple assignment is a fairly common
feature in modern programming languages.

it seems that this is a remote dream in r, because 'users should be
protected against themselves'.

vQ



[Rd] question
Wacek Kusnierczyk