comma in parameter lists

Notices and updates
Locked
nikus80
Posts: 16
Joined: Tue Nov 21, 2006 2:19 pm
Location: argentina

comma in parameter lists

Post by nikus80 »

I'm using newLISP v9.0 on win.
I read about comma in parameters lists but they don't seem to work, what I'm doing wrong?

(define (test2 , b c)
,)

(test2 1 2 3)
returns 1! the comma is bounded!. Why is that?

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

I don't think the comma - or the period - is special in newLISP, it's just another character.

Code: Select all

(define (, x y z) 
(+ x y z))

(define (. x y z) 
(* x y z))

(define (a . ,)
(+ . , ))

(, 1 2 3)
;-> 6

(. 4 5 6)
;-> 120

(a 2 3)
;-> 5

Most of the familiar punctuation characters (+ _ & ^ % $ @) are already reserved.

--
(define (‽) ; a unicode joke
"you what‽")

(‽)
--> you what‽

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Yes, the comma is just a symbol like any other character. This is all documented in chapter 19 of the manual:

file:///usr/share/newlisp/doc/newlisp_manual.html#commas

The differene between the comma and the period is that the period can be embedded in a symbol name, but the comma breaks the string, similar to the colon:

Code: Select all

> (set 'a 1 ', 2 'b 3)
3
> a,b
1
2
3
> 
Lutz

Locked