Open In App

Naming Conventions in LISP

LISP is a programming language that has an overall style that is organized around expressions and functions. Every Lisp procedure is a function, and when called, it returns a data object as its value. It is also commonly referred to as “functions” even though they may have side effects.

Lisp is the second-oldest high-level programming language in the world which is invented by John McCarthy in the year 1958 at the Massachusetts Institute of Technology.



Features of  LISP Programming Language

Let’s say for writing “GeeksforGeeks” we can use the below syntax:

Syntax:



(write-line string)

Example:




(write-line "GeeksforGeeks")

Output:

GeeksforGeeks

Explanation: The write-line is a method that writes the specified line on the output stream. We have passed “GeeksforGeeks” as a string.

Now let’s look into the Naming Conventions in LISP. 

Naming Conventions:

The naming Conventions mean the way we are declaring variables in a program. It includes the variable names and syntax formats

Lets us discuss the conventions:

A variable can contain any number of alphanumeric characters other than whitespace, open, and closing parentheses.

Example:

Acceptable: hello,akshit, etc
Not Acceptable: hell()0,sat{ akshit{,,,,,,,,etc

A variable can not contain double and single quotes, backslash, comma, colon, semicolon, and vertical bar.

Example:

Acceptable: hello,akshit, etc
Not Acceptable: hell””)0,sat//*& aka//>vab{,,,,,,,,etc

A variable can not start with a digit but it can contain any number of digits

Example:

Acceptable: hello88Geeks, a45akshit, ,,,,,etc
Not Acceptable: 40geeks,4akshit,….etc

Now let’s take a look at a couple of examples to better understand the Naming convention in LISP.

Example 1: Naming Conventions in LISP.




;acceptable naming conventions
  
(write-line "akshit")
    
(terpri)
    
(write-line "akshit99")
    
(terpri)
    
(write-line "hello geeks")

Output:

akshit
akshit99
hello geeks

Example 2: Naming Conventions in LISP.




;acceptable naming conventions
(write-line "hello_Geek")
    
(terpri)
    
(write-line "hello123")

Output:

hello_Geek
hello123

Article Tags :