*args isn't a variable you can override

5 views
Skip to first unread message

Eric Man

unread,
Feb 20, 2012, 8:27:54 AM2/20/12
to Programming Nu
From the documentation, it says *args is just a variable that can be
overridden.

"However, if a parameter named *args appears in a block or function's
argument list, it will override the implicit variable."

However, it doesn't seem to be the case for cdr:

% (let ((*l '( '(1 2 3)))) (apply cdr *l))
(2 3)
% (let ((*args '( '(1 2 3)))) (apply cdr *args))
Nu uncaught exception: NuCdrCalledOnAtom: cdr called on atom for
object <Nu_cdr_operator: 0x7fd039e04e30>
from <TopLevel>:-1: in <Nu_cdr_operator:39e04e30>
from <TopLevel>:-1: in eval
from <TopLevel>:2: in apply
from <TopLevel>:2: in let

Am I doing it wrong?

Eric Man

unread,
Feb 20, 2012, 8:35:27 AM2/20/12
to Programming Nu
The first example also fails if wrapped into a vararg function...
% (let ((*l '( '(1 2 3)))) (apply cdr *l))
(2 3)
% ((do (*l) (apply cdr *l)) '(1 2 3))
Nu uncaught exception: NSRangeException: -[__NSCFConstantString
substringWithRange:]: Range or index out of bounds
from <TopLevel>:2: in 1
from <TopLevel>:-1: in <Nu_cdr_operator:39e04e30>
from <TopLevel>:-1: in eval
from <TopLevel>:2: in apply
from <TopLevel>:2: in (do (*l) (apply cdr *l))

Does anyone know what I'm doing wrong?
Reply all
Reply to author
Forward
0 new messages