From b.rowlingson at lancaster.ac.uk  Mon Aug 23 19:50:44 2010
From: b.rowlingson at lancaster.ac.uk (Barry Rowlingson)
Date: Mon, 23 Aug 2010 18:50:44 +0100
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: <AANLkTinazqHq2fpE68dxS0UM1DM1FBpvrx5mBSG2Gqz7@mail.gmail.com>

On Mon, Aug 23, 2010 at 6:06 PM, Davor Cubranic <cubranic at stat.ubc.ca> wrote:

> 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.

 Oops yes, negative logic assumption from me.

 Okay, back to the question...

 Looks tricky, because if(x=2){...} fails because of syntax. There's
stuff in gram.y that makes x=1 a bit special, and only lets it occur
as a top-level expression. However x<-1 is allowed anywhere an
expression can be. Both expressions then call the same 'primitive'
function. At that point I'm not sure how the code could find out if
it's being called from a <- or an = assignment. And then whether its a
top-level expression or not. And this would need checking on every <-
call, which could be a problem...

 Barry



[Rd] small syntax suggestion
Barry Rowlingson