From phgrosjean at sciviews.org  Mon Aug 23 22:27:24 2010
From: phgrosjean at sciviews.org (Philippe Grosjean)
Date: Mon, 23 Aug 2010 22:27:24 +0200
Subject: [Rd] small syntax suggestion
In-Reply-To: <04831FEE-4137-484E-8942-427085663D2F@stat.ubc.ca>
References: <AANLkTimvja3=JJ-Y8yS=8K+m8ePP7XrCUTEvzg=L9bjn@mail.gmail.com>	<AANLkTinwC0h+oX2QhcskS_9xRuws=X9XQ2RuGnOxVCyG@mail.gmail.com>
	<04831FEE-4137-484E-8942-427085663D2F@stat.ubc.ca>
Message-ID: <4C72D9AC.1080906@sciviews.org>

I tell to my students that it is very important (not only for 
legibility) to place spaces between operands. They have to write such a 
code like this:

if (x < -3) do_something

That way, there is no ambiguity. Don't you think it's important to write 
clear code, including by using spaces where it makes it easier to 
read,... and less ambiguous, as you just realize?

Best,

Philippe Grosjean

On 23/08/10 19:06, Davor Cubranic wrote:
> On 2010-08-23, at 6:15 AM, Barry Rowlingson wrote:
>
>> On Sun, Aug 22, 2010 at 4:33 PM, ivo welch<ivo.welch at gmail.com>  wrote:
>>> I have found that my students often make the mistake of
>>> mixing up comparisons and assignments with negative numbers:
>>>
>>>   if (x<-3) do_something;
>>
>> If you tell your students not to use '<-' for assignment, then they
>> can't make this mistake, because = for assignment has additional
>> restrictions on it:
>
> The students are trying to *compare* to a negative number, and trip on R's parsing of "<-". They could use '=' for assignment all they want (which I thought is being discouraged as a code style these days, BTW), and they'll still run into this problem.
>
> Davor
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>



[Rd] small syntax suggestion
Philippe Grosjean