Symbol in LISP

Source: Internet
Author: User
Tags setf

1. Symbols Definition

SymbolsAre used for theirObjectIdentity to name varous entities
InCommon LISP, Including (but not limited to) Linguistic entities such
AsVariablesAndFunctions.

 

2. built-in symbol

Intern symbol --Interned SymbolIs uniquely identifiable by its
NameFrom anyPackageIn which it isAccessible.

 

3. Convert the string to symbol

;;;

; Description: the right side of the code => "..." indicates the output of each line of code.

;;;

(SETF symbol-string "sym") => "sym"

(SETF symbol-object (intern symbol-string) => sym

(Symbolp symbol-object) => T

(SETF (get symbol-object 'symbol-name) "sym") => "sym"

(SETF (get symbol-object 'symbol-value) "sym") => "sym"

 

4. symbol Structure

Each symbol has the following main structure:

; Name ---> "foo"

; Package ---> in some package

; Value ---> 27

; Function --- ># <function>

; Plist ---> (color red)

From Paul Graham's ANSI Common Lisp. p135

 

5. fboudp checks whether a symbol is a function name.

(Fboundp 'acs-Main-loop) => T; ACs-Main-loop is a function name.

(Fboundp 'asymbol) => nil; asymbol is just a symbol

 

6. Determine whether a symbol is a class name

(Find-class 'patc-pattern nil) => T; patc-pattern is a class name

(Find-class 'patx-pattern nil) => nil; patx-pattern is not a class

Pay attention to the following parameters of find-class:

Syntax:
Find-class Symbol& OptionalErrorp Environment=> Class

(SETF(Find-class Symbol& OptionalErrorp
Environment
)New-class)

When errorp is set to nil, type error is not thrown.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.