From pdalgd at gmail.com  Mon Jan 20 17:21:07 2014
From: pdalgd at gmail.com (peter dalgaard)
Date: Mon, 20 Jan 2014 17:21:07 +0100
Subject: [Rd] formals() adds 0 to complex function arguments
In-Reply-To: <52DC5929.8070609@gmail.com>
References: <CANLFJPpnu2_n9qPXMGnRCupNWtrS6Mm_TjH-pTkSdvUQ523sLA@mail.gmail.com>
	<7630243D-EAA3-4FDA-89D5-25CAEDFEAC94@gmail.com>
	<52DC4795.9060202@gmail.com> <52DC5929.8070609@gmail.com>
Message-ID: <E21B8A3C-FFEC-41DD-9E2B-820B53E4A1B4@gmail.com>


On 20 Jan 2014, at 00:00 , Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
>>> 
>>> Someone might want to fix this by implementing a full syntax for complex constants, but meanwhile, I think a passable workaround could be
>> 
>> That might be nice to do.  Not sure if it's easy or hard...
> 
> I think it's hard.  After seeing the 1, when the parser gets a "+", it's not clear whether you're in the middle of a complex number or some other kind of sum.  And since users can redefine "+", it could be a really different kind, even if it's followed by 2i.

Yes. That's what I suspected; you may need to actually change the syntax. 

I was thinking something like a=1C+2i, or even more radically a=_Const_(1+2i) with the idea of evaluating the contents of _Const_() at parse time or maybe rather function definition time.  

The latter idea might solve some other issues where R structures can't be defined as constants (pretty much any nonscalar vector, for instance), and the associated issues with non-reversibility of deparse().

But as you say, it's likely to be hard.

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] formals() adds 0 to complex function arguments
peter dalgaard