comma in parameter lists

Started by nikus80, December 02, 2006, 07:00:27 AM

Previous topic - Next topic

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

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


(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

#2
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:


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


Lutz