Why comma is special?

Started by Kazimir Majorinc, July 09, 2008, 03:03:37 AM

Previous topic - Next topic

Kazimir Majorinc

I noted that comma cannot be part of the symbol; it appears identifier



x,y



is understood like it is the sequence of three symbols



x , y



Is it intentional?
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

Jeff

#1
Yes, it is intentional.  The comma is a newlisp idiom for establishing local variables in a function:


(define (foo param , a b c)
  ;; here, a, b, and c are nil
  (println "Hello world"))
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

DrDave

#2
From the manual
QuoteSome of the example programs contain functions that use a comma to separate the parameters into two groups. This is not a special syntax of newLISP, but rather a visual trick. The comma is a symbol just like any other symbol.
...it is better to first strive for clarity and correctness and to make programs efficient only if really needed.

\"Getting Started with Erlang\"  version 5.6.2

Jeff

#3
It is a symbol and may be set, but the comma is recognized individually by the parser and is not a valid character in other symbols.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code