What it means ?

Discussion of Common Lisp
Post Reply
mparsa
Posts: 26
Joined: Mon Jun 25, 2012 6:15 am

What it means ?

Post by mparsa » Fri Jun 29, 2012 12:44 am

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 !?

Goheeca
Posts: 271
Joined: Thu May 10, 2012 12:54 pm
Contact:

Re: What it means ?

Post by Goheeca » Fri Jun 29, 2012 1:23 am

Until it's a reader macro (though ugly) then it's simply a symbol/identifier. CL is quite benevolent in this.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.

wvxvw
Posts: 127
Joined: Sat Mar 26, 2011 6:23 am

Re: What it means ?

Post by wvxvw » Fri Jun 29, 2012 4:00 am

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...

virex
Posts: 17
Joined: Fri Oct 28, 2011 3:41 pm

Re: What it means ?

Post by virex » Tue Jul 31, 2012 4:33 am

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.

Post Reply