SlideShare a Scribd company logo
Macros in Lisp
CL macro facility allows the user to define arbitrary functions that convert certain lisp forms into different forms before evaluating or compiling them. Macros makes it possible to write codes that are clear and elegant. In CL, macros are not functions In particular, macros cannot be used as the functional arguments to functions such as apply, funcall, or map.
overview Macro definition Macro expansion Destructuring Compiler macros Environments
Macro definition defmacro construct is used to define a macro. Macro-function determines whether the given function is the name of the macro. macro-function symbol The argument must be a symbol, if the function has a global function definition( macro definition) then the expansion function is returned else nil is returned. Macro-function cannot work on local variables it can only determine the global definitions. Setf is used as a macro function to install a macro as a symbols global function definition To add an optional environment argument to macro-function: macro-function symbol &optional env (setf (macro-function symbol)  fn)
defmacro has the same syntax as the defun Here, name is the symbol whose macro definition we are creating. Lambda-list is similar in form to a lambda-list,  Forms constitute the body of the expander function. The defmacro function returns the name. defmacro name lambda-list [[ {declaration}* | doc-string ]]  {form}* [Macro]
Defmacro lambda-list keywords Some of the lambda-list key words are: &optional, &rest, &key, &allow-other-keys, &aux &body:  this is identical in function to &rest, it informs certain output-formatting and editing functions that the remainder of the form is treated as a body and should be intended accordingly. &whole: this is followed by a single variable that is bound to the entire macro-call form. &environment: this is followed by a single variable that is bound to an environment representing the lexical environment in which the macro call is to be interpreted.
Macro-expansion If form is a macro call, then macroexpand-1 will expand the macro call once and return two values.( the expansion and t) if form is not macro call then two values ( form and nil) are returned. A form is said to be a macro call only if it is a cons whose car is a symbol that names a macro. The macro expansion function is used for expanding a macro call.
Macro-expansion steps followed Once the macroexpand-1 has determined that a symbol names a macro, it obtains the expansion function for that macro. The value of the variable *macro-expand-hook* is then called as a function of three arguments: the expansion function, the form, and the environment env. The value returned from this call is taken to be the expansion of the macro call. The evaluator makes use of the macro calls as if through the use of macroexpand-1; eval also makes use of *macroexpand-hook* Macroexpand is similar to macroexpand-1, but repeatedly expands forms until it is no longer a macro call.
Destructing To make the destructing feature of the defmacro available use: This macro binds the variables specified in lambda-list to the corresponding values in the tree structure resulting from evaluating the expression, then executes the forms as the an implicit progn. If the result of the evaluating expression does not match the destructuring pattern, an error should be signaled. Destructuring-bind lambda-list expression {declaration}* {form}[Macro]
Compiler macros Compiler macros are used to transform the selective source code when the compiler is processing the code. This is similar to defmacro except the definition is not stored in the symbol function cell of name and is not seen by macroexpand-1 The lambda-list may include &environment, &whole and may include destructuring. Return-form is used to exit from the function. define-compiler-macro name lambda-list                          {declaration | doc-string}* {form}*
Name must be a symbol, if it has been defined as a compiler macro, then the compiler-macro-function returns the macro expansion function, else returns nil. Expander function is obtained as if by a call to compiler-macro-function on the car of the form rather than by a call to macro-function. Two values are returned, the expansion and the value if expansion is true else nil. compiler macro function name &optional env compiler-macroexpand from &optional  env compiler-macroexpand-1 from &optional  env
Three cases when no expansion occurs: There is no compiler macro definition for the car of the form. There is such a definition but there is also a not inline declaration, either globally or in lexical environment env. A global compiler macro definition is shadowed by a local function or macro definition.
Environments There is a minimal set of accessors and a constructor for environments. Define-declaration is used to define all the standard declaration specifiers, with the exception of special. The function returns the interpretation  of the symbol variable when it appears as a variable within the lexical environment env. Three values are returned: The first value indicates the type of definition in the env which may be :special, :lexical, :symbol-macro, :constant Variable-information variable &optional env
2. The second value is true if there is a local binding else it returns nil. 3.  The third value is an a-list containing information about the declarations that apply to the apparent binding of the variable. Returns the information about the  interpretation of the function when it appears in the functional position of the lexical environment env. This function also returns three values: Type of definition or binding of the function name which is apparent in env (nil, :function, :macro, :special-form)  The second value is true if the function is local else nil. The third value is an a-list containing information about declarations that apply to the apparent binding of the function. function-information function  &optional env
argument-environment env &key :variable  :symbol-macro :fuction :macro :declare returns a new environment containing the information present in enc augmented with the information provided by the key word arguments. The arguments used are: ,[object Object]
:symbol-macro  list of symbol macro definitions
:function  list of function-names that will be visible as local function bindings in the new environment.
:macro list of local macro definitions
:declare list of declaration specifiers,[object Object]

More Related Content

What's hot

Assignment#01
Assignment#01Assignment#01
Assignment#01
Sunita Milind Dol
 
Oracle plsql and d2 k interview question1
Oracle plsql and d2 k interview question1Oracle plsql and d2 k interview question1
Oracle plsql and d2 k interview question1
Arunkumar Gurav
 
Oracle plsql and d2 k interview questions
Oracle plsql and d2 k interview questionsOracle plsql and d2 k interview questions
Oracle plsql and d2 k interview questions
Arunkumar Gurav
 
Class 10
Class 10Class 10
Functions
FunctionsFunctions
Functions
Septi Ratnasari
 
4. function
4. function4. function
4. function
Shankar Gangaju
 
BAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 LectureBAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 Lecture
Wake Tech BAS
 
Programming style guideline very good
Programming style guideline very goodProgramming style guideline very good
Programming style guideline very good
Dang Hop
 
ELENA MICROPROCESSOR
ELENA MICROPROCESSORELENA MICROPROCESSOR
ELENA MICROPROCESSOR
ranjeetdon
 
SAS Macros part 3
SAS Macros part 3SAS Macros part 3
SAS Macros part 3
venkatam
 
functions
functionsfunctions
functions
Itishree Soni
 
Complete list of all sap abap keywords
Complete list of all sap abap keywordsComplete list of all sap abap keywords
Complete list of all sap abap keywords
Prakash Thirumoorthy
 
Lecture11 abap on line
Lecture11 abap on lineLecture11 abap on line
Lecture11 abap on line
Milind Patil
 
Ism normalization pine valley 2012
Ism normalization pine valley 2012Ism normalization pine valley 2012
Ism normalization pine valley 2012
Akshit R Shah
 
SAS Macros part 2
SAS Macros part 2SAS Macros part 2
SAS Macros part 2
venkatam
 
Procedure and Functions in pl/sql
Procedure and Functions in pl/sqlProcedure and Functions in pl/sql
Procedure and Functions in pl/sql
Ñirmal Tatiwal
 
DAC training-batch -2020(PLSQL)
DAC training-batch -2020(PLSQL)DAC training-batch -2020(PLSQL)
DAC training-batch -2020(PLSQL)
RajKumarSingh213
 
SQL / PL
SQL / PLSQL / PL
SQL / PL
srijanani2030
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
koolkampus
 
Modularisation techniques new
Modularisation techniques newModularisation techniques new
Modularisation techniques new
Jeet Thombare
 

What's hot (20)

Assignment#01
Assignment#01Assignment#01
Assignment#01
 
Oracle plsql and d2 k interview question1
Oracle plsql and d2 k interview question1Oracle plsql and d2 k interview question1
Oracle plsql and d2 k interview question1
 
Oracle plsql and d2 k interview questions
Oracle plsql and d2 k interview questionsOracle plsql and d2 k interview questions
Oracle plsql and d2 k interview questions
 
Class 10
Class 10Class 10
Class 10
 
Functions
FunctionsFunctions
Functions
 
4. function
4. function4. function
4. function
 
BAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 LectureBAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 Lecture
 
Programming style guideline very good
Programming style guideline very goodProgramming style guideline very good
Programming style guideline very good
 
ELENA MICROPROCESSOR
ELENA MICROPROCESSORELENA MICROPROCESSOR
ELENA MICROPROCESSOR
 
SAS Macros part 3
SAS Macros part 3SAS Macros part 3
SAS Macros part 3
 
functions
functionsfunctions
functions
 
Complete list of all sap abap keywords
Complete list of all sap abap keywordsComplete list of all sap abap keywords
Complete list of all sap abap keywords
 
Lecture11 abap on line
Lecture11 abap on lineLecture11 abap on line
Lecture11 abap on line
 
Ism normalization pine valley 2012
Ism normalization pine valley 2012Ism normalization pine valley 2012
Ism normalization pine valley 2012
 
SAS Macros part 2
SAS Macros part 2SAS Macros part 2
SAS Macros part 2
 
Procedure and Functions in pl/sql
Procedure and Functions in pl/sqlProcedure and Functions in pl/sql
Procedure and Functions in pl/sql
 
DAC training-batch -2020(PLSQL)
DAC training-batch -2020(PLSQL)DAC training-batch -2020(PLSQL)
DAC training-batch -2020(PLSQL)
 
SQL / PL
SQL / PLSQL / PL
SQL / PL
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
 
Modularisation techniques new
Modularisation techniques newModularisation techniques new
Modularisation techniques new
 

Viewers also liked

Retrieving Data From A Database
Retrieving Data From A DatabaseRetrieving Data From A Database
Retrieving Data From A Database
DataminingTools Inc
 
Introduction to Data-Applied
Introduction to Data-AppliedIntroduction to Data-Applied
Introduction to Data-Applied
DataminingTools Inc
 
Data Applied: Association
Data Applied: AssociationData Applied: Association
Data Applied: Association
DataminingTools Inc
 
Communicating simply
Communicating simplyCommunicating simply
Communicating simply
Mustansir Husain
 
RapidMiner: Nested Subprocesses
RapidMiner:   Nested SubprocessesRapidMiner:   Nested Subprocesses
RapidMiner: Nested Subprocesses
DataminingTools Inc
 
Procedures And Functions in Matlab
Procedures And Functions in MatlabProcedures And Functions in Matlab
Procedures And Functions in Matlab
DataminingTools Inc
 
R: Apply Functions
R: Apply FunctionsR: Apply Functions
R: Apply Functions
DataminingTools Inc
 
R Environment
R EnvironmentR Environment
R Environment
DataminingTools Inc
 
PresentacióN De Quimica
PresentacióN De QuimicaPresentacióN De Quimica
PresentacióN De Quimica
guestf6a53c
 
XL-MINER:Prediction
XL-MINER:PredictionXL-MINER:Prediction
XL-MINER:Prediction
DataminingTools Inc
 
Data Applied:Tree Maps
Data Applied:Tree MapsData Applied:Tree Maps
Data Applied:Tree Maps
DataminingTools Inc
 
Paramount Search Partners
Paramount Search PartnersParamount Search Partners
Paramount Search Partners
jjmcdermott
 
MySql:Basics
MySql:BasicsMySql:Basics
MySql:Basics
DataminingTools Inc
 
建築師法修正草案總說明
建築師法修正草案總說明建築師法修正草案總說明
建築師法修正草案總說明Filip Yang
 
MED dra Coding -MSSO
MED dra Coding -MSSOMED dra Coding -MSSO
MED dra Coding -MSSO
drabhishekpitti
 
Facebook: An Innovative Influenza Pandemic Early Warning System
Facebook: An Innovative Influenza Pandemic Early Warning SystemFacebook: An Innovative Influenza Pandemic Early Warning System
Facebook: An Innovative Influenza Pandemic Early Warning System
Chen Luo
 
Mphone
MphoneMphone
Data Applied:Decision Trees
Data Applied:Decision TreesData Applied:Decision Trees
Data Applied:Decision Trees
DataminingTools Inc
 
C,C++ In Matlab
C,C++ In MatlabC,C++ In Matlab
C,C++ In Matlab
DataminingTools Inc
 
LíRica Latina 2ºBac Lara Lozano
LíRica Latina 2ºBac Lara LozanoLíRica Latina 2ºBac Lara Lozano
LíRica Latina 2ºBac Lara Lozanolara
 

Viewers also liked (20)

Retrieving Data From A Database
Retrieving Data From A DatabaseRetrieving Data From A Database
Retrieving Data From A Database
 
Introduction to Data-Applied
Introduction to Data-AppliedIntroduction to Data-Applied
Introduction to Data-Applied
 
Data Applied: Association
Data Applied: AssociationData Applied: Association
Data Applied: Association
 
Communicating simply
Communicating simplyCommunicating simply
Communicating simply
 
RapidMiner: Nested Subprocesses
RapidMiner:   Nested SubprocessesRapidMiner:   Nested Subprocesses
RapidMiner: Nested Subprocesses
 
Procedures And Functions in Matlab
Procedures And Functions in MatlabProcedures And Functions in Matlab
Procedures And Functions in Matlab
 
R: Apply Functions
R: Apply FunctionsR: Apply Functions
R: Apply Functions
 
R Environment
R EnvironmentR Environment
R Environment
 
PresentacióN De Quimica
PresentacióN De QuimicaPresentacióN De Quimica
PresentacióN De Quimica
 
XL-MINER:Prediction
XL-MINER:PredictionXL-MINER:Prediction
XL-MINER:Prediction
 
Data Applied:Tree Maps
Data Applied:Tree MapsData Applied:Tree Maps
Data Applied:Tree Maps
 
Paramount Search Partners
Paramount Search PartnersParamount Search Partners
Paramount Search Partners
 
MySql:Basics
MySql:BasicsMySql:Basics
MySql:Basics
 
建築師法修正草案總說明
建築師法修正草案總說明建築師法修正草案總說明
建築師法修正草案總說明
 
MED dra Coding -MSSO
MED dra Coding -MSSOMED dra Coding -MSSO
MED dra Coding -MSSO
 
Facebook: An Innovative Influenza Pandemic Early Warning System
Facebook: An Innovative Influenza Pandemic Early Warning SystemFacebook: An Innovative Influenza Pandemic Early Warning System
Facebook: An Innovative Influenza Pandemic Early Warning System
 
Mphone
MphoneMphone
Mphone
 
Data Applied:Decision Trees
Data Applied:Decision TreesData Applied:Decision Trees
Data Applied:Decision Trees
 
C,C++ In Matlab
C,C++ In MatlabC,C++ In Matlab
C,C++ In Matlab
 
LíRica Latina 2ºBac Lara Lozano
LíRica Latina 2ºBac Lara LozanoLíRica Latina 2ºBac Lara Lozano
LíRica Latina 2ºBac Lara Lozano
 

Similar to LISP: Macros in lisp

LISP: Program structure in lisp
LISP: Program structure in lispLISP: Program structure in lisp
LISP: Program structure in lisp
LISP Content
 
LISP:Program structure in lisp
LISP:Program structure in lispLISP:Program structure in lisp
LISP:Program structure in lisp
DataminingTools Inc
 
C language 3
C language 3C language 3
C language 3
Arafat Bin Reza
 
User defined functions in matlab
User defined functions in  matlabUser defined functions in  matlab
User defined functions in matlab
Infinity Tech Solutions
 
Task Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdfTask Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdf
acsmadurai
 
Module 5.pdf
Module 5.pdfModule 5.pdf
Module 5.pdf
SE14Darshan
 
Functions-Computer programming
Functions-Computer programmingFunctions-Computer programming
Functions-Computer programming
nmahi96
 
Functions
FunctionsFunctions
Functions
zeeshan841
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
home
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
home
 
USER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdf
USER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdfUSER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdf
USER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
User defined function in C.pptx
User defined function in C.pptxUser defined function in C.pptx
User defined function in C.pptx
Rhishav Poudyal
 
Cpp functions
Cpp functionsCpp functions
Cpp functions
NabeelaNousheen
 
Function in C++
Function in C++Function in C++
Function in C++
Prof Ansari
 
functions notes.pdf python functions and opp
functions notes.pdf python functions and oppfunctions notes.pdf python functions and opp
functions notes.pdf python functions and opp
KirtiGarg71
 
Java script function
Java script functionJava script function
Java script function
suresh raj sharma
 
FUNCTION CPU
FUNCTION CPUFUNCTION CPU
FUNCTION CPU
Krushal Kakadia
 
Writing command macro in stratus cobol
Writing command macro in stratus cobolWriting command macro in stratus cobol
Writing command macro in stratus cobol
Srinimf-Slides
 
Ch4 functions
Ch4 functionsCh4 functions
Ch4 functions
Hattori Sidek
 
[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++
Muhammad Hammad Waseem
 

Similar to LISP: Macros in lisp (20)

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
 
C language 3
C language 3C language 3
C language 3
 
User defined functions in matlab
User defined functions in  matlabUser defined functions in  matlab
User defined functions in matlab
 
Task Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdfTask Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdf
 
Module 5.pdf
Module 5.pdfModule 5.pdf
Module 5.pdf
 
Functions-Computer programming
Functions-Computer programmingFunctions-Computer programming
Functions-Computer programming
 
Functions
FunctionsFunctions
Functions
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
USER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdf
USER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdfUSER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdf
USER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdf
 
User defined function in C.pptx
User defined function in C.pptxUser defined function in C.pptx
User defined function in C.pptx
 
Cpp functions
Cpp functionsCpp functions
Cpp functions
 
Function in C++
Function in C++Function in C++
Function in C++
 
functions notes.pdf python functions and opp
functions notes.pdf python functions and oppfunctions notes.pdf python functions and opp
functions notes.pdf python functions and opp
 
Java script function
Java script functionJava script function
Java script function
 
FUNCTION CPU
FUNCTION CPUFUNCTION CPU
FUNCTION CPU
 
Writing command macro in stratus cobol
Writing command macro in stratus cobolWriting command macro in stratus cobol
Writing command macro in stratus cobol
 
Ch4 functions
Ch4 functionsCh4 functions
Ch4 functions
 
[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++
 

More from DataminingTools Inc

Terminology Machine Learning
Terminology Machine LearningTerminology Machine Learning
Terminology Machine Learning
DataminingTools Inc
 
Techniques Machine Learning
Techniques Machine LearningTechniques Machine Learning
Techniques Machine Learning
DataminingTools Inc
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
DataminingTools Inc
 
Areas of machine leanring
Areas of machine leanringAreas of machine leanring
Areas of machine leanring
DataminingTools Inc
 
AI: Planning and AI
AI: Planning and AIAI: Planning and AI
AI: Planning and AI
DataminingTools Inc
 
AI: Logic in AI 2
AI: Logic in AI 2AI: Logic in AI 2
AI: Logic in AI 2
DataminingTools Inc
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
DataminingTools Inc
 
AI: Learning in AI 2
AI: Learning in AI 2AI: Learning in AI 2
AI: Learning in AI 2
DataminingTools Inc
 
AI: Learning in AI
AI: Learning in AI AI: Learning in AI
AI: Learning in AI
DataminingTools Inc
 
AI: Introduction to artificial intelligence
AI: Introduction to artificial intelligenceAI: Introduction to artificial intelligence
AI: Introduction to artificial intelligence
DataminingTools Inc
 
AI: Belief Networks
AI: Belief NetworksAI: Belief Networks
AI: Belief Networks
DataminingTools Inc
 
AI: AI & Searching
AI: AI & SearchingAI: AI & Searching
AI: AI & Searching
DataminingTools Inc
 
AI: AI & Problem Solving
AI: AI & Problem SolvingAI: AI & Problem Solving
AI: AI & Problem Solving
DataminingTools Inc
 
Data Mining: Text and web mining
Data Mining: Text and web miningData Mining: Text and web mining
Data Mining: Text and web mining
DataminingTools Inc
 
Data Mining: Outlier analysis
Data Mining: Outlier analysisData Mining: Outlier analysis
Data Mining: Outlier analysis
DataminingTools Inc
 
Data Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence dataData Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence data
DataminingTools Inc
 
Data Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlationsData Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlations
DataminingTools Inc
 
Data Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysisData Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysis
DataminingTools Inc
 
Data warehouse and olap technology
Data warehouse and olap technologyData warehouse and olap technology
Data warehouse and olap technology
DataminingTools Inc
 
Data Mining: Data processing
Data Mining: Data processingData Mining: Data processing
Data Mining: Data processing
DataminingTools Inc
 

More from DataminingTools Inc (20)

Terminology Machine Learning
Terminology Machine LearningTerminology Machine Learning
Terminology Machine Learning
 
Techniques Machine Learning
Techniques Machine LearningTechniques Machine Learning
Techniques Machine Learning
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
 
Areas of machine leanring
Areas of machine leanringAreas of machine leanring
Areas of machine leanring
 
AI: Planning and AI
AI: Planning and AIAI: Planning and AI
AI: Planning and AI
 
AI: Logic in AI 2
AI: Logic in AI 2AI: Logic in AI 2
AI: Logic in AI 2
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
 
AI: Learning in AI 2
AI: Learning in AI 2AI: Learning in AI 2
AI: Learning in AI 2
 
AI: Learning in AI
AI: Learning in AI AI: Learning in AI
AI: Learning in AI
 
AI: Introduction to artificial intelligence
AI: Introduction to artificial intelligenceAI: Introduction to artificial intelligence
AI: Introduction to artificial intelligence
 
AI: Belief Networks
AI: Belief NetworksAI: Belief Networks
AI: Belief Networks
 
AI: AI & Searching
AI: AI & SearchingAI: AI & Searching
AI: AI & Searching
 
AI: AI & Problem Solving
AI: AI & Problem SolvingAI: AI & Problem Solving
AI: AI & Problem Solving
 
Data Mining: Text and web mining
Data Mining: Text and web miningData Mining: Text and web mining
Data Mining: Text and web mining
 
Data Mining: Outlier analysis
Data Mining: Outlier analysisData Mining: Outlier analysis
Data Mining: Outlier analysis
 
Data Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence dataData Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence data
 
Data Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlationsData Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlations
 
Data Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysisData Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysis
 
Data warehouse and olap technology
Data warehouse and olap technologyData warehouse and olap technology
Data warehouse and olap technology
 
Data Mining: Data processing
Data Mining: Data processingData Mining: Data processing
Data Mining: Data processing
 

Recently uploaded

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 

Recently uploaded (20)

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 

LISP: Macros in lisp

  • 2. CL macro facility allows the user to define arbitrary functions that convert certain lisp forms into different forms before evaluating or compiling them. Macros makes it possible to write codes that are clear and elegant. In CL, macros are not functions In particular, macros cannot be used as the functional arguments to functions such as apply, funcall, or map.
  • 3. overview Macro definition Macro expansion Destructuring Compiler macros Environments
  • 4. Macro definition defmacro construct is used to define a macro. Macro-function determines whether the given function is the name of the macro. macro-function symbol The argument must be a symbol, if the function has a global function definition( macro definition) then the expansion function is returned else nil is returned. Macro-function cannot work on local variables it can only determine the global definitions. Setf is used as a macro function to install a macro as a symbols global function definition To add an optional environment argument to macro-function: macro-function symbol &optional env (setf (macro-function symbol) fn)
  • 5. defmacro has the same syntax as the defun Here, name is the symbol whose macro definition we are creating. Lambda-list is similar in form to a lambda-list, Forms constitute the body of the expander function. The defmacro function returns the name. defmacro name lambda-list [[ {declaration}* | doc-string ]] {form}* [Macro]
  • 6. Defmacro lambda-list keywords Some of the lambda-list key words are: &optional, &rest, &key, &allow-other-keys, &aux &body: this is identical in function to &rest, it informs certain output-formatting and editing functions that the remainder of the form is treated as a body and should be intended accordingly. &whole: this is followed by a single variable that is bound to the entire macro-call form. &environment: this is followed by a single variable that is bound to an environment representing the lexical environment in which the macro call is to be interpreted.
  • 7. Macro-expansion If form is a macro call, then macroexpand-1 will expand the macro call once and return two values.( the expansion and t) if form is not macro call then two values ( form and nil) are returned. A form is said to be a macro call only if it is a cons whose car is a symbol that names a macro. The macro expansion function is used for expanding a macro call.
  • 8. Macro-expansion steps followed Once the macroexpand-1 has determined that a symbol names a macro, it obtains the expansion function for that macro. The value of the variable *macro-expand-hook* is then called as a function of three arguments: the expansion function, the form, and the environment env. The value returned from this call is taken to be the expansion of the macro call. The evaluator makes use of the macro calls as if through the use of macroexpand-1; eval also makes use of *macroexpand-hook* Macroexpand is similar to macroexpand-1, but repeatedly expands forms until it is no longer a macro call.
  • 9. Destructing To make the destructing feature of the defmacro available use: This macro binds the variables specified in lambda-list to the corresponding values in the tree structure resulting from evaluating the expression, then executes the forms as the an implicit progn. If the result of the evaluating expression does not match the destructuring pattern, an error should be signaled. Destructuring-bind lambda-list expression {declaration}* {form}[Macro]
  • 10. Compiler macros Compiler macros are used to transform the selective source code when the compiler is processing the code. This is similar to defmacro except the definition is not stored in the symbol function cell of name and is not seen by macroexpand-1 The lambda-list may include &environment, &whole and may include destructuring. Return-form is used to exit from the function. define-compiler-macro name lambda-list {declaration | doc-string}* {form}*
  • 11. Name must be a symbol, if it has been defined as a compiler macro, then the compiler-macro-function returns the macro expansion function, else returns nil. Expander function is obtained as if by a call to compiler-macro-function on the car of the form rather than by a call to macro-function. Two values are returned, the expansion and the value if expansion is true else nil. compiler macro function name &optional env compiler-macroexpand from &optional env compiler-macroexpand-1 from &optional env
  • 12. Three cases when no expansion occurs: There is no compiler macro definition for the car of the form. There is such a definition but there is also a not inline declaration, either globally or in lexical environment env. A global compiler macro definition is shadowed by a local function or macro definition.
  • 13. Environments There is a minimal set of accessors and a constructor for environments. Define-declaration is used to define all the standard declaration specifiers, with the exception of special. The function returns the interpretation of the symbol variable when it appears as a variable within the lexical environment env. Three values are returned: The first value indicates the type of definition in the env which may be :special, :lexical, :symbol-macro, :constant Variable-information variable &optional env
  • 14. 2. The second value is true if there is a local binding else it returns nil. 3. The third value is an a-list containing information about the declarations that apply to the apparent binding of the variable. Returns the information about the interpretation of the function when it appears in the functional position of the lexical environment env. This function also returns three values: Type of definition or binding of the function name which is apparent in env (nil, :function, :macro, :special-form) The second value is true if the function is local else nil. The third value is an a-list containing information about declarations that apply to the apparent binding of the function. function-information function &optional env
  • 15.
  • 16. :symbol-macro  list of symbol macro definitions
  • 17. :function  list of function-names that will be visible as local function bindings in the new environment.
  • 18. :macro list of local macro definitions
  • 19.
  • 20.
  • 21. If the first value is :variable or :function, then the second value must be a list, the elements of which are of the form (binding-name key value)
  • 22.
  • 23. 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