Page 1 of 1

What it means ?

Posted: Fri Jun 29, 2012 12:44 am
by mparsa
I can not understand this line of code :
(defun loop?_0 (x) (eql x 4))
"?" is a part of the function's name ? or something else !?

Re: What it means ?

Posted: Fri Jun 29, 2012 1:23 am
by Goheeca
Until it's a reader macro (though ugly) then it's simply a symbol/identifier. CL is quite benevolent in this.

Re: What it means ?

Posted: Fri Jun 29, 2012 4:00 am
by wvxvw
Some times people use "?" in a function name to signal that the function will return a boolean or a generalized boolean value. But your variant looks more like a manga style smiley :) I didn't encounter this kind of naming before.
On the same note, the below are also valid function names:

Code: Select all

(defun >__< () (princ "(>__<)"))
(defun *.* () (princ "(*.*)"))
(defun @_= () (princ "(@_=)")
(defun ^..^ () (princ "(^..^)")
; which you can use like this:
(>__<) (*.*) (@_=) (^..^)
But you don't really have to use them...

Re: What it means ?

Posted: Tue Jul 31, 2012 4:33 am
by virex
mparsa wrote:I can not understand this line of code :
(defun loop?_0 (x) (eql x 4))
"?" is a part of the function's name ? or something else !?
Lisp allows you to use all ascii-characters (IIRC, could be printable ascii characters) or unicode characters, depending on the native character set of your implementation, in symbol names, with the exception of the space, the #, the \, the @, the `, the ' and the ( and ) (I might be missing one). So, it's perfectly fine to use a!=b? as the name of a function.