What it means ?

Discussion of Common Lisp

What it means ?

Postby 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 !?
mparsa
 
Posts: 26
Joined: Mon Jun 25, 2012 6:15 am

Re: What it means ?

Postby 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).
User avatar
Goheeca
 
Posts: 165
Joined: Thu May 10, 2012 12:54 pm

Re: What it means ?

Postby 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...
wvxvw
 
Posts: 125
Joined: Sat Mar 26, 2011 6:23 am

Re: What it means ?

Postby 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.
virex
 
Posts: 17
Joined: Fri Oct 28, 2011 3:41 pm


Return to Common Lisp

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests