lambda error update

Peter Dalgaard BSA
18 Sep 1999 01:53:55 +0200

Matthew Wiener <> writes:

> Two more details:
> Someone else who works here, and hasn't used 0.65.0, thinks he's seen the
> error before.  He restarted R, and it went away.
> Second, I think the relevant code is in 
> SEXP do_function, in eval.c in the main directory.
> line 695:  WrongArgCount("lambda")
> Beyond that I'm afraid I'm getting in over my head.
> Matt

"lambda" is essentially "function" (revealing the fact that R's engine
is really a Lisp/Scheme dialect). It's a very strange error you're
getting because the calls to "function" are almost impossible to
create, except by having the parser parse a

function (<args>) <body> 

construction and that would set up a call with the right number of
parameters (xxdefun in gram.y calls lang4). The arg count got changed
from 0.64.2 to 0.65.0 (from 3 to 4) to accommodate the stored source
attribute. I suppose that a function stored in a saved workspace might
cause some kind of mess when restored.

You can provoke the error by messing with the parse tree of function()
constructs, e.g.

> e<-quote(function()1)
> e[[4]]<-NULL
> eval(e)
Error: incorrect number of arguments to "lambda"
> e
function() 1
> e<-quote(function()1)
> e[[3]]<-NULL
> eval(e)
Error: incorrect number of arguments to "lambda"
> e
function() "function()1"
> e[[2]]<-NULL
> eval(e)
Error: incorrect number of arguments to "lambda"
> e
Segmentation fault (core dumped)

(That last one seems to indicate yet another spot where the deparser
needs to take better care).

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (             FAX: (+45) 35327907
r-devel mailing list -- Read
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: