SlideShare une entreprise Scribd logo
1  sur  15
Declarations in Lisp
Declarations Declarations allow the user to specify extra information about the program to Lisp system. Declarations are truly optional but special declarations do effect the interpretation of the variable bindings and references and so must be specified wherever necessary. Declarations are one of the good ways to add documentation to the program.
overview Declaration syntax Declaration specifiers Type declaration for forms
Declaration syntax declare construct is used to embed declarations within the executable code. A declare form is known as the declaration. A declaration may occur only at the beginning of the bodies of the certain special forms. declare  {decl-spec}*
Declarations may occur in the lambda expressions and in the forms listed below:
Variable bindings appear only to the bindings made by the form at the head of whose body they appear. (defun foo (x)   (declare (type float x)).. (let  (( x’a)) …) ….)  The type declaration applies only to the outer binding of the x and not to the binding made in the let. The scope of the declaration always includes the body forms, as well as any “stepper” or “result” forms, of the special forms or lambda-expressions. If the declaration applies to a name binding, then the scope of declaration also includes the scope of the name binding.
locally  {declaration}* {form}* This macro is used to make local pervasive declarations where desired. This construct does not bind any variables. Special declaration may be used with lacally to pervasively affect references to, rather than bindings of, variables. The function proclaim takes a decl-spec as its argument and puts it into effect globally.
proclaim decl-spec The proclaim takes decl-spec as the argument and puts it into effect globally. Ex: (proclaim ‘(type float tolerance)) specifies that the dynamic value of the tolerance should always be a floating-point number. A proclaim takes special decl-spec as applying to all bindings as well as to all references of the mentioned variables. This macro is syntactically like declare and semantically like proclaim. It is an executable form and may be used anywhere proclaim may be called. declaim {decl-spec}*
Declaration specifiers List of valid declaration  specifiers for use in declare. (special var1 var2….) specifies that all of the variables named are to be considered special. (type var1, var2,…) affects only variable bindings and specifies that the variables mentioned will take on values only of the specified type.
(ftype type function-name-1, function-name-2,…) specifies that the named functions will be of the function type type. Ex: (declare (ftype(function (integer list) t) nth)                    (ftype (function (number) float) sin cos)) To extend ftype declaration specifiers to accept any function-name, one may write (declaim (ftype (function (list) t) (setf cadr)))
(inline function1, function2,…)specifies that it is desirable for the compiler to open code calls to the specified functions. The compiler is free to ignore this declaration. (notinline function1, function2,…)specifies that it is undesirable for the compiler to compile the specified functions inline. This declaration  is pervasive and the compiler is not free to ignore this declaration. (ignore var1,var2,….) affects only variable bindings and specifies that the bindings of the specified variables are never used. (optimize (quality1 value1) (quality2 vale2)…) advises compiler that each quality must be given attention according to the specified corresponding value.
(declaration name1, name2,…) advises the compiler that each namej is a valid but non-standard declaration name. The is kind of declaration may be used only as a proclamation. Ex: (proclaim ‘(declaration author                               target-language                               target-machine))    (proclaim ‘(target-language ada))    (proclaim ‘(target-machine IBM-650)) (defun strangep(x)   (declare (author “Harry Tweeker”))  (member  x’(strange weird odd peculiar)))
Type declarations for forms The special form is defined to declare the type of value held by a bound variable. (the type form)the type of value means the type of value of is declared to be of type type. the value-type formthe form is evaluated and whatever it produces is returned by the form, it is an error if what is returned by the form does not confirm to the data-type specified by value-type.
Examples: (the string (copy-seq x)) the result will be a string. (the integer (+ x 3)) the result of + will be an integer. (+ (the integer x) 3)the value of x will be an integer.
Visit more self help tutorials Pick a tutorial of your choice and browse through it at your own pace. The tutorials section is free, self-guiding and will not involve any additional support. Visit us at www.dataminingtools.net

Contenu connexe

Tendances

Tendances (17)

CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
Storage Classes and Functions
Storage Classes and FunctionsStorage Classes and Functions
Storage Classes and Functions
 
Storage class in c
Storage class in cStorage class in c
Storage class in c
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Lecture 13 - Storage Classes
Lecture 13 - Storage ClassesLecture 13 - Storage Classes
Lecture 13 - Storage Classes
 
Ooabapnoteswithprogram good 78
Ooabapnoteswithprogram good 78Ooabapnoteswithprogram good 78
Ooabapnoteswithprogram good 78
 
Pl sql programme
Pl sql programmePl sql programme
Pl sql programme
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
 
Storage classes in C
Storage classes in CStorage classes in C
Storage classes in C
 
Storage Class in C Progrmming
Storage Class in C Progrmming Storage Class in C Progrmming
Storage Class in C Progrmming
 
Lecture04(control structure part i)
Lecture04(control structure part i)Lecture04(control structure part i)
Lecture04(control structure part i)
 
First c program
First c programFirst c program
First c program
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing Tutorial
 
11 lec 11 storage class
11 lec 11 storage class11 lec 11 storage class
11 lec 11 storage class
 
C if else
C if elseC if else
C if else
 

Similaire à LISP:Declarations In Lisp

LISP: Program structure in lisp
LISP: Program structure in lispLISP: Program structure in lisp
LISP: Program structure in lispLISP Content
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cppsharvivek
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variablesSaurav Kumar
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniquesvalarpink
 
Functions in C++
Functions in C++Functions in C++
Functions in C++home
 
Embedded C The IoT Academy
Embedded C The IoT AcademyEmbedded C The IoT Academy
Embedded C The IoT AcademyThe IOT Academy
 
C presentation! BATRA COMPUTER CENTRE
C presentation! BATRA  COMPUTER  CENTRE C presentation! BATRA  COMPUTER  CENTRE
C presentation! BATRA COMPUTER CENTRE jatin batra
 
All About ... Functions
All About ... FunctionsAll About ... Functions
All About ... FunctionsMichal Bigos
 
C language presentation
C language presentationC language presentation
C language presentationbainspreet
 
BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12Dev Chauhan
 
User defined function in C.pptx
User defined function in C.pptxUser defined function in C.pptx
User defined function in C.pptxRhishav Poudyal
 
Lecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxLecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxSaqlainYaqub1
 
What is storage class
What is storage classWhat is storage class
What is storage classIsha Aggarwal
 
solidity programming.pptx
solidity programming.pptxsolidity programming.pptx
solidity programming.pptxRohiniBagul4
 

Similaire à LISP:Declarations In Lisp (20)

X++ 1.pptx
X++ 1.pptxX++ 1.pptx
X++ 1.pptx
 
LISP: Program structure in lisp
LISP: Program structure in lispLISP: Program structure in lisp
LISP: Program structure in lisp
 
LISP:Program structure in lisp
LISP:Program structure in lispLISP:Program structure in lisp
LISP:Program structure in lisp
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp
 
C functions list
C functions listC functions list
C functions list
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Embedded C The IoT Academy
Embedded C The IoT AcademyEmbedded C The IoT Academy
Embedded C The IoT Academy
 
C presentation! BATRA COMPUTER CENTRE
C presentation! BATRA  COMPUTER  CENTRE C presentation! BATRA  COMPUTER  CENTRE
C presentation! BATRA COMPUTER CENTRE
 
All About ... Functions
All About ... FunctionsAll About ... Functions
All About ... Functions
 
C++ quik notes
C++ quik notesC++ quik notes
C++ quik notes
 
C language presentation
C language presentationC language presentation
C language presentation
 
BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12
 
Notes(1).pptx
Notes(1).pptxNotes(1).pptx
Notes(1).pptx
 
User defined function in C.pptx
User defined function in C.pptxUser defined function in C.pptx
User defined function in C.pptx
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Lecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxLecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptx
 
What is storage class
What is storage classWhat is storage class
What is storage class
 
solidity programming.pptx
solidity programming.pptxsolidity programming.pptx
solidity programming.pptx
 

Plus de LISP Content

LISP: Control Structures In Lisp
LISP: Control Structures In LispLISP: Control Structures In Lisp
LISP: Control Structures In LispLISP Content
 
LISP: Errors In Lisp
LISP: Errors In LispLISP: Errors In Lisp
LISP: Errors In LispLISP Content
 
LISP: Input And Output
LISP: Input And OutputLISP: Input And Output
LISP: Input And OutputLISP Content
 
LISP: Object Sytstem Lisp
LISP: Object Sytstem LispLISP: Object Sytstem Lisp
LISP: Object Sytstem LispLISP Content
 
LISP: Loops In Lisp
LISP: Loops In LispLISP: Loops In Lisp
LISP: Loops In LispLISP Content
 
LISP: Type specifiers in lisp
LISP: Type specifiers in lispLISP: Type specifiers in lisp
LISP: Type specifiers in lispLISP Content
 
LISP: Symbols and packages in lisp
LISP: Symbols and packages in lispLISP: Symbols and packages in lisp
LISP: Symbols and packages in lispLISP Content
 
LISP: Scope and extent in lisp
LISP: Scope and extent in lispLISP: Scope and extent in lisp
LISP: Scope and extent in lispLISP Content
 
LISP: Predicates in lisp
LISP: Predicates in lispLISP: Predicates in lisp
LISP: Predicates in lispLISP Content
 
LISP: Macros in lisp
LISP: Macros in lispLISP: Macros in lisp
LISP: Macros in lispLISP Content
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lispLISP Content
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To LispLISP Content
 

Plus de LISP Content (12)

LISP: Control Structures In Lisp
LISP: Control Structures In LispLISP: Control Structures In Lisp
LISP: Control Structures In Lisp
 
LISP: Errors In Lisp
LISP: Errors In LispLISP: Errors In Lisp
LISP: Errors In Lisp
 
LISP: Input And Output
LISP: Input And OutputLISP: Input And Output
LISP: Input And Output
 
LISP: Object Sytstem Lisp
LISP: Object Sytstem LispLISP: Object Sytstem Lisp
LISP: Object Sytstem Lisp
 
LISP: Loops In Lisp
LISP: Loops In LispLISP: Loops In Lisp
LISP: Loops In Lisp
 
LISP: Type specifiers in lisp
LISP: Type specifiers in lispLISP: Type specifiers in lisp
LISP: Type specifiers in lisp
 
LISP: Symbols and packages in lisp
LISP: Symbols and packages in lispLISP: Symbols and packages in lisp
LISP: Symbols and packages in lisp
 
LISP: Scope and extent in lisp
LISP: Scope and extent in lispLISP: Scope and extent in lisp
LISP: Scope and extent in lisp
 
LISP: Predicates in lisp
LISP: Predicates in lispLISP: Predicates in lisp
LISP: Predicates in lisp
 
LISP: Macros in lisp
LISP: Macros in lispLISP: Macros in lisp
LISP: Macros in lisp
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
 

Dernier

(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 

Dernier (20)

(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 

LISP:Declarations In Lisp

  • 2. Declarations Declarations allow the user to specify extra information about the program to Lisp system. Declarations are truly optional but special declarations do effect the interpretation of the variable bindings and references and so must be specified wherever necessary. Declarations are one of the good ways to add documentation to the program.
  • 3. overview Declaration syntax Declaration specifiers Type declaration for forms
  • 4. Declaration syntax declare construct is used to embed declarations within the executable code. A declare form is known as the declaration. A declaration may occur only at the beginning of the bodies of the certain special forms. declare {decl-spec}*
  • 5. Declarations may occur in the lambda expressions and in the forms listed below:
  • 6. Variable bindings appear only to the bindings made by the form at the head of whose body they appear. (defun foo (x) (declare (type float x)).. (let (( x’a)) …) ….) The type declaration applies only to the outer binding of the x and not to the binding made in the let. The scope of the declaration always includes the body forms, as well as any “stepper” or “result” forms, of the special forms or lambda-expressions. If the declaration applies to a name binding, then the scope of declaration also includes the scope of the name binding.
  • 7. locally {declaration}* {form}* This macro is used to make local pervasive declarations where desired. This construct does not bind any variables. Special declaration may be used with lacally to pervasively affect references to, rather than bindings of, variables. The function proclaim takes a decl-spec as its argument and puts it into effect globally.
  • 8. proclaim decl-spec The proclaim takes decl-spec as the argument and puts it into effect globally. Ex: (proclaim ‘(type float tolerance)) specifies that the dynamic value of the tolerance should always be a floating-point number. A proclaim takes special decl-spec as applying to all bindings as well as to all references of the mentioned variables. This macro is syntactically like declare and semantically like proclaim. It is an executable form and may be used anywhere proclaim may be called. declaim {decl-spec}*
  • 9. Declaration specifiers List of valid declaration specifiers for use in declare. (special var1 var2….) specifies that all of the variables named are to be considered special. (type var1, var2,…) affects only variable bindings and specifies that the variables mentioned will take on values only of the specified type.
  • 10. (ftype type function-name-1, function-name-2,…) specifies that the named functions will be of the function type type. Ex: (declare (ftype(function (integer list) t) nth) (ftype (function (number) float) sin cos)) To extend ftype declaration specifiers to accept any function-name, one may write (declaim (ftype (function (list) t) (setf cadr)))
  • 11. (inline function1, function2,…)specifies that it is desirable for the compiler to open code calls to the specified functions. The compiler is free to ignore this declaration. (notinline function1, function2,…)specifies that it is undesirable for the compiler to compile the specified functions inline. This declaration is pervasive and the compiler is not free to ignore this declaration. (ignore var1,var2,….) affects only variable bindings and specifies that the bindings of the specified variables are never used. (optimize (quality1 value1) (quality2 vale2)…) advises compiler that each quality must be given attention according to the specified corresponding value.
  • 12. (declaration name1, name2,…) advises the compiler that each namej is a valid but non-standard declaration name. The is kind of declaration may be used only as a proclamation. Ex: (proclaim ‘(declaration author target-language target-machine))  (proclaim ‘(target-language ada)) (proclaim ‘(target-machine IBM-650)) (defun strangep(x) (declare (author “Harry Tweeker”)) (member x’(strange weird odd peculiar)))
  • 13. Type declarations for forms The special form is defined to declare the type of value held by a bound variable. (the type form)the type of value means the type of value of is declared to be of type type. the value-type formthe form is evaluated and whatever it produces is returned by the form, it is an error if what is returned by the form does not confirm to the data-type specified by value-type.
  • 14. Examples: (the string (copy-seq x)) the result will be a string. (the integer (+ x 3)) the result of + will be an integer. (+ (the integer x) 3)the value of x will be an integer.
  • 15. Visit more self help tutorials Pick a tutorial of your choice and browse through it at your own pace. The tutorials section is free, self-guiding and will not involve any additional support. Visit us at www.dataminingtools.net