SlideShare a Scribd company logo
 Lisp Input and Output
overviewRead function.Parsing of numbers and symbolsMacro charactersInput functionsOutput functionsQuerying the user
Printed representationLisp presents a representation of most objects in printed representation which is used for input/output purposes.Functions such as print takes a lisp object and send the characters of its printed representation to a stream.The collection of routines that does this is called (Lisp)printer.
What read function acceptsLisp reader accepts characters, interpret them as a printed representation of the lisp object, and construct and return such an object.The reader can also be used as a lexical analyzer for a more general user-written parser.The reader is organized as a recursive descent parser.
The reader operates by reading a character from the input stream and treating it in one of the three ways:Whitespace characters are served as separators but otherwise ignored.
Constituent and escape characters are accumulated to make a token, which is then interpreted as number or symbol.
Macro characters trigger the invocation of the functions that can perform arbitrary parsing actions, including recursive invocation of the reader.Every character that appears in the input stream must be one of the following types:Illegal, whitespace, constituents ( [,],{,},?,and !)single escape, multiple escape or macro.
Parsing of numbers and symbolsWhen an extended token is read, it is interpreted as a number or symbol.Whitespace, macro or escape character will always be treated as alphabetic within an extended token.
Lisp syntax for numbersNumber::=integer|ratio|floating-point numberInteger::=[sign] {digit}+  [decimal-point]Ratio::= [sign] {digit}+ / {digit}+Floating-point-number::= [sign] {digit}* decimal-point {digit}+ [exponent]| [sign] {digit}+ [decimal-number {digit}*] exponentSign::= +|-Decimal-point::= .Digit::= 0|1|2|3|4|5|6|7|8|9Exponent::= exponent-marker [sign] {digit}+Exponent-marker::= e|s|f|d|l|E|S|F|D|L
Token must satisfy the following requirements:It consists entirely of digits, signs (+ or -), ratio markers (/), decimal points(.), extension characters(^ or _), and number markers.It consists at least one digit.It begins with a digit, sign, decimal point, or extension character.It does not end with a sign.Ex: 1b5000, 777777q, 1.7J, ^-43^, 3.1.2.6 etc.
symbolsThe following are always treated as symbols:*read-base*The value of read base controls the interpretation  of tokens by read as being integers or ratios.Its value is the radix in which the integers or ratios are to be read.The value must be any integer from 2 to 36,and it is normally 10. for ex if the *read-base* is set as 16(hexadecimal radix),  variables with names such as a,b,f , bad and face will be treated by the reader as numbers./         /5       +    1+     1-   foo+ ab.cd   -    ^        ^/-
*read-supress*if this value is set as nil, the Lisp reader operates normally, when it is not null the most interesting operation of the reader are suppressed.*read-eval* its default value is always t, if *read-eval* is false. Reader macro signals an error.
Macro charactersWhen a macro character is encountered, then the function associated with that macro is invoked and may produce an object to be returned.Macro characters are normally defined as follows:   The left parenthesis initiates reading a pair of list. The function read is called recursively to read successive objects until a right parenthesis is found to be next in the input stream. A list of objects read are returned.
‘ single-quote provides an abbreviation to make it easier to put constants in the programs.; is used to write comments.“ double-quote character represents the printed representation of a string.A back-quote is followed by a template, a picture of a data structure to be built.# is dispatching macro-character. It reads an optional digit string and then one more character, and uses that character to select a function to run as a macro-character function.
Standard dispatching macro character syntax #\x reads in a character object that represents a character x.#\name1 reads in as the character object whose name is name1. The name1 should have the syntax of the symbol.# ’ is an abbreviation for (function foo)A series of representations of objects enclosed by #( and )is read as a simple vector of those objects.If unsigned decimal integer appears between the # and (, it specifies explicitly the length of the vector.
#:foo requires foo to have a syntax of an unqualified symbol name.It denotes an uninterened symbol whose name is foo.Every time an uninterended symbol is created when this symbol is encountered.#,foo is read as the object resulting from the evaluation of the lisp object represented by foo, which may be the printed representation of any lisp object.#B reads rational in binary(radix 2) ex:#B110113#o reads rational in octal(radix 8) ex: #o777511#X reads rational in hexadecimal(radix 16) ex: #xFoo3840
#nA constructs an n-dimensional arrayEx: #2A ((0 1 5) (foo 2(hot dog))) represents a 2 cross 3 matrix: 0  1  5                             f00 2 (hot dog)#s (name slot1 value1 slot2 value2….) denotes a structure.#+ syntax provides a read time conditionality facility; the syntax is #+feature form#- form is equivalent to #+(not feature) form.If feature is true, then this syntax represents a lisp object whose printed representation is form.If the feature is false, then this syntax is effectively white space.
The following names are standards across all implementations:Newline, spaceRubout  delete characterPage the form-feed or page-separator characterTab the tabulate character Return carriage return characterLinefeed the line-feed character
Read tableRead table is the data structure used to control the reader.It has information about the syntax of each character.*read-table* is the current read tableTo program the reader for a different syntax, begin with the copy of the standard common lisp read table and then customize the individual characters within the copy.Copy-readtable &optional from-readtable to read-table
readtable case readtable is a function used to control the readers interpretation of the case.It provides access to a slot in the read table.The possible values of the slots are::upcase replaceable characters are converted to upper case:downcase replaceable characters are converted into lower case:preserve the cases of all characters remain unchanged:invert all replicable characters of same case are converted to opposite case
Input functionsCharacters in inputs take optional arguments called:Input-streamarguments is the argument from which to obtain the input from.
eof-error-p argument controls if the input is from a file, and end of file is reached.
If eof-error-p is true , an error will be signaled at the end of the file. If it is false, then no error is signaled, instead it returns eof-value.
if end-of-file is encountered and eof-error-p argument is not nil, the kind of error that is signaled may depend on the value of recursive-p.read &optional input-stream eof-error-p eof-value recursive-preads in the printed representation of the lisp object from the input stream, builds a corresponding lisp object, and returns the object.read-delimited-list char &optional input-stream recursive-pthis reads objects from the stream until the next character after an object representation is a char.read-line &optional input-stream eof-error-p eof-value recursive-pread-line a line of text terminated by a new-line.It returns the line as a character string. read-char &optional input-stream eof-error-p eof-value recursive-p read-char input one character from the input stream and returns it as character object.
Unread-char character &optional input-stream unread-char puts the character onto the front of the input-stream. listen &optional input-stream The predicate listen is true if there is a character immediately available from the input stream, and false if not. clear-input &optional input-streamClears any buffered input associated with the input stream. Read-byte binary-input-stream &optional eof-error-p eof-value read-byte tread one byte from the binary input stream and returns it in the form of an integer.
Output functions that operate on stream of functionsThese functions take an optional argument output-stream(defaults to variable *standard-output*) on where to send the output. write object &key :stream :escape :radix :base :circle :pretty :level :length :case :gensym :array: readable: right-margin :miser-width :lines and :pprint-dispatchthe printed representation of the object is written to the output stream specified by :stream, which defaults to the value *standard-output* The other keyword arguments specify values used to control the generation of the printed representation.
Prin1 object &optional output-streamprin1 outputs the printed representation  of object to output-stream.Print object &optional output-streamprinted representation of the object is preceded by newline and followed by a space.PPrin1 object &optional output-streamtrailing space is omitted and the object is printed with the *print-pretty* flag non-nil to produce “pretty” output.Princ object &optional output-stream Is similar to prin1 except that the output has no escape characters.
Write-char character &optional output-streamoutputs the character to the output stream and returns the characterWrite-string string &optional output-stream &key :start  :endWrite-line string &optional output-stream &key :start  :endwrites the character of the specified substring to the output-stream.The :start and :end delimit a substring of string in usual manner. write-lined does the same thing but then outputs a new-line afterwards.
finish-output &optional output-stream Attempts to ensure that all the output sent to the output stream has reached the destination, only then returns nil.force-output &optional output-streaminitiates the emptying of any internal buffers and returns nil without waiting for completion.clear-output &optional output-streamAttempts to abort any outstanding poutput operation in progress in order to allow as less output as possible.Output to binary streams:Write-byte integer binary-output-stream write-byte returns one byte, the value of the integer.
Formatted outputThe function format is used for producing nicely formatted text.format destination control-string &rest argumentsFormat outputs the characters of control stringA format directive consists of a tilde(~) , optional prefix parameters separated by commas, optional colon( : ) and ( @ ) sign modifiers, and a single character indicating what kind of directive this is.
Ad

More Related Content

What's hot (20)

A Role of Lexical Analyzer
A Role of Lexical AnalyzerA Role of Lexical Analyzer
A Role of Lexical Analyzer
Archana Gopinath
 
C Tokens
C TokensC Tokens
C Tokens
Ripon Hossain
 
Getting started with C++
Getting started with C++Getting started with C++
Getting started with C++
Asirbachan Sutar
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
Lex and Yacc ppt
Lex and Yacc pptLex and Yacc ppt
Lex and Yacc ppt
pssraikar
 
Lexical analysis-using-lex
Lexical analysis-using-lexLexical analysis-using-lex
Lexical analysis-using-lex
Dattatray Gandhmal
 
Lexical Analyzer Implementation
Lexical Analyzer ImplementationLexical Analyzer Implementation
Lexical Analyzer Implementation
Akhil Kaushik
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
Princess Doll
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
Radhakrishnan Chinnusamy
 
C++ Basics
C++ BasicsC++ Basics
C++ Basics
Himanshu Sharma
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
Farzana Aktar
 
Assignment5
Assignment5Assignment5
Assignment5
Sunita Milind Dol
 
3. Lexical analysis
3. Lexical analysis3. Lexical analysis
3. Lexical analysis
Saeed Parsa
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
kiran acharya
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
Munni28
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
Sahithi Naraparaju
 
Compiler design and lexical analyser
Compiler design and lexical analyserCompiler design and lexical analyser
Compiler design and lexical analyser
abhishek gupta
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_output
Anil Dutt
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
Rai University
 
Role-of-lexical-analysis
Role-of-lexical-analysisRole-of-lexical-analysis
Role-of-lexical-analysis
Dattatray Gandhmal
 
A Role of Lexical Analyzer
A Role of Lexical AnalyzerA Role of Lexical Analyzer
A Role of Lexical Analyzer
Archana Gopinath
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
Lex and Yacc ppt
Lex and Yacc pptLex and Yacc ppt
Lex and Yacc ppt
pssraikar
 
Lexical Analyzer Implementation
Lexical Analyzer ImplementationLexical Analyzer Implementation
Lexical Analyzer Implementation
Akhil Kaushik
 
3. Lexical analysis
3. Lexical analysis3. Lexical analysis
3. Lexical analysis
Saeed Parsa
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
Munni28
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
Sahithi Naraparaju
 
Compiler design and lexical analyser
Compiler design and lexical analyserCompiler design and lexical analyser
Compiler design and lexical analyser
abhishek gupta
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_output
Anil Dutt
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
Rai University
 

Viewers also liked (9)

LISP: Errors In Lisp
LISP: Errors In LispLISP: Errors In Lisp
LISP: Errors In Lisp
LISP Content
 
LISP: Control Structures In Lisp
LISP: Control Structures In LispLISP: Control Structures In Lisp
LISP: Control Structures In Lisp
LISP Content
 
LISP: Object Sytstem Lisp
LISP: Object Sytstem LispLISP: Object Sytstem Lisp
LISP: Object Sytstem Lisp
LISP Content
 
LISP:Declarations In Lisp
LISP:Declarations In LispLISP:Declarations In Lisp
LISP:Declarations In Lisp
LISP Content
 
LISP: Loops In Lisp
LISP: Loops In LispLISP: Loops In Lisp
LISP: Loops In Lisp
LISP Content
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
LISP Content
 
LISP: Macros in lisp
LISP: Macros in lispLISP: Macros in lisp
LISP: Macros in lisp
LISP Content
 
Hipogonadizm
HipogonadizmHipogonadizm
Hipogonadizm
Perviz Haciyev
 
Lisp Programming Languge
Lisp Programming LangugeLisp Programming Languge
Lisp Programming Languge
Yaser Jaradeh
 
LISP: Errors In Lisp
LISP: Errors In LispLISP: Errors In Lisp
LISP: Errors In Lisp
LISP Content
 
LISP: Control Structures In Lisp
LISP: Control Structures In LispLISP: Control Structures In Lisp
LISP: Control Structures In Lisp
LISP Content
 
LISP: Object Sytstem Lisp
LISP: Object Sytstem LispLISP: Object Sytstem Lisp
LISP: Object Sytstem Lisp
LISP Content
 
LISP:Declarations In Lisp
LISP:Declarations In LispLISP:Declarations In Lisp
LISP:Declarations In Lisp
LISP Content
 
LISP: Loops In Lisp
LISP: Loops In LispLISP: Loops In Lisp
LISP: Loops In Lisp
LISP Content
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
LISP Content
 
LISP: Macros in lisp
LISP: Macros in lispLISP: Macros in lisp
LISP: Macros in lisp
LISP Content
 
Lisp Programming Languge
Lisp Programming LangugeLisp Programming Languge
Lisp Programming Languge
Yaser Jaradeh
 
Ad

Similar to LISP: Input And Output (20)

LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
DataminingTools Inc
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
LISP Content
 
Python programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operationsPython programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operations
Megha V
 
AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptx
prakashvs7
 
Compilers Design
Compilers DesignCompilers Design
Compilers Design
Akshaya Arunan
 
Introduction of bison
Introduction of bisonIntroduction of bison
Introduction of bison
vip_du
 
GRADE 11 Chapter 5 - Python Fundamentals.pptx
GRADE 11 Chapter 5 - Python Fundamentals.pptxGRADE 11 Chapter 5 - Python Fundamentals.pptx
GRADE 11 Chapter 5 - Python Fundamentals.pptx
DeepaRavi21
 
python fudmentalsYYour score increaseases
python fudmentalsYYour score increaseasespython fudmentalsYYour score increaseases
python fudmentalsYYour score increaseases
ssuser61d324
 
CH-3 FEATURES OF PYTHON, data types token
CH-3 FEATURES OF PYTHON, data types tokenCH-3 FEATURES OF PYTHON, data types token
CH-3 FEATURES OF PYTHON, data types token
suchetavij1
 
Unit_I-Introduction python programming (1).pptx
Unit_I-Introduction python programming (1).pptxUnit_I-Introduction python programming (1).pptx
Unit_I-Introduction python programming (1).pptx
arunbalaji707
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
Muthuselvam RS
 
Current C++ code- parse-h -- This file contains the function prototype (1).pdf
Current C++ code- parse-h -- This file contains the function prototype (1).pdfCurrent C++ code- parse-h -- This file contains the function prototype (1).pdf
Current C++ code- parse-h -- This file contains the function prototype (1).pdf
shyamsunder1211
 
Getting started with c++.pptx
Getting started with c++.pptxGetting started with c++.pptx
Getting started with c++.pptx
Akash Baruah
 
Tokens in php (php: Hypertext Preprocessor).pptx
Tokens in  php (php: Hypertext Preprocessor).pptxTokens in  php (php: Hypertext Preprocessor).pptx
Tokens in php (php: Hypertext Preprocessor).pptx
BINJAD1
 
atc 3rd module compiler and automata.ppt
atc 3rd module compiler and automata.pptatc 3rd module compiler and automata.ppt
atc 3rd module compiler and automata.ppt
ranjan317165
 
python_strings.pdf
python_strings.pdfpython_strings.pdf
python_strings.pdf
rajendraprasadbabub1
 
Introduction to R for beginners
Introduction to R for beginnersIntroduction to R for beginners
Introduction to R for beginners
Abishek Purushothaman
 
Python programming unit 2 -Slides-3.ppt
Python programming  unit 2 -Slides-3.pptPython programming  unit 2 -Slides-3.ppt
Python programming unit 2 -Slides-3.ppt
geethar79
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Anujashejwal
 
Lexical Analyser PPTs for Third Lease Computer Sc. and Engineering
Lexical Analyser PPTs for Third Lease Computer Sc. and EngineeringLexical Analyser PPTs for Third Lease Computer Sc. and Engineering
Lexical Analyser PPTs for Third Lease Computer Sc. and Engineering
DrRajurkarArchanaMil
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
LISP Content
 
Python programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operationsPython programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operations
Megha V
 
AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptx
prakashvs7
 
Introduction of bison
Introduction of bisonIntroduction of bison
Introduction of bison
vip_du
 
GRADE 11 Chapter 5 - Python Fundamentals.pptx
GRADE 11 Chapter 5 - Python Fundamentals.pptxGRADE 11 Chapter 5 - Python Fundamentals.pptx
GRADE 11 Chapter 5 - Python Fundamentals.pptx
DeepaRavi21
 
python fudmentalsYYour score increaseases
python fudmentalsYYour score increaseasespython fudmentalsYYour score increaseases
python fudmentalsYYour score increaseases
ssuser61d324
 
CH-3 FEATURES OF PYTHON, data types token
CH-3 FEATURES OF PYTHON, data types tokenCH-3 FEATURES OF PYTHON, data types token
CH-3 FEATURES OF PYTHON, data types token
suchetavij1
 
Unit_I-Introduction python programming (1).pptx
Unit_I-Introduction python programming (1).pptxUnit_I-Introduction python programming (1).pptx
Unit_I-Introduction python programming (1).pptx
arunbalaji707
 
Current C++ code- parse-h -- This file contains the function prototype (1).pdf
Current C++ code- parse-h -- This file contains the function prototype (1).pdfCurrent C++ code- parse-h -- This file contains the function prototype (1).pdf
Current C++ code- parse-h -- This file contains the function prototype (1).pdf
shyamsunder1211
 
Getting started with c++.pptx
Getting started with c++.pptxGetting started with c++.pptx
Getting started with c++.pptx
Akash Baruah
 
Tokens in php (php: Hypertext Preprocessor).pptx
Tokens in  php (php: Hypertext Preprocessor).pptxTokens in  php (php: Hypertext Preprocessor).pptx
Tokens in php (php: Hypertext Preprocessor).pptx
BINJAD1
 
atc 3rd module compiler and automata.ppt
atc 3rd module compiler and automata.pptatc 3rd module compiler and automata.ppt
atc 3rd module compiler and automata.ppt
ranjan317165
 
Python programming unit 2 -Slides-3.ppt
Python programming  unit 2 -Slides-3.pptPython programming  unit 2 -Slides-3.ppt
Python programming unit 2 -Slides-3.ppt
geethar79
 
Lexical Analyser PPTs for Third Lease Computer Sc. and Engineering
Lexical Analyser PPTs for Third Lease Computer Sc. and EngineeringLexical Analyser PPTs for Third Lease Computer Sc. and Engineering
Lexical Analyser PPTs for Third Lease Computer Sc. and Engineering
DrRajurkarArchanaMil
 
Ad

Recently uploaded (20)

Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Mike Mingos
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Mike Mingos
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 

LISP: Input And Output

  • 1. Lisp Input and Output
  • 2. overviewRead function.Parsing of numbers and symbolsMacro charactersInput functionsOutput functionsQuerying the user
  • 3. Printed representationLisp presents a representation of most objects in printed representation which is used for input/output purposes.Functions such as print takes a lisp object and send the characters of its printed representation to a stream.The collection of routines that does this is called (Lisp)printer.
  • 4. What read function acceptsLisp reader accepts characters, interpret them as a printed representation of the lisp object, and construct and return such an object.The reader can also be used as a lexical analyzer for a more general user-written parser.The reader is organized as a recursive descent parser.
  • 5. The reader operates by reading a character from the input stream and treating it in one of the three ways:Whitespace characters are served as separators but otherwise ignored.
  • 6. Constituent and escape characters are accumulated to make a token, which is then interpreted as number or symbol.
  • 7. Macro characters trigger the invocation of the functions that can perform arbitrary parsing actions, including recursive invocation of the reader.Every character that appears in the input stream must be one of the following types:Illegal, whitespace, constituents ( [,],{,},?,and !)single escape, multiple escape or macro.
  • 8. Parsing of numbers and symbolsWhen an extended token is read, it is interpreted as a number or symbol.Whitespace, macro or escape character will always be treated as alphabetic within an extended token.
  • 9. Lisp syntax for numbersNumber::=integer|ratio|floating-point numberInteger::=[sign] {digit}+ [decimal-point]Ratio::= [sign] {digit}+ / {digit}+Floating-point-number::= [sign] {digit}* decimal-point {digit}+ [exponent]| [sign] {digit}+ [decimal-number {digit}*] exponentSign::= +|-Decimal-point::= .Digit::= 0|1|2|3|4|5|6|7|8|9Exponent::= exponent-marker [sign] {digit}+Exponent-marker::= e|s|f|d|l|E|S|F|D|L
  • 10. Token must satisfy the following requirements:It consists entirely of digits, signs (+ or -), ratio markers (/), decimal points(.), extension characters(^ or _), and number markers.It consists at least one digit.It begins with a digit, sign, decimal point, or extension character.It does not end with a sign.Ex: 1b5000, 777777q, 1.7J, ^-43^, 3.1.2.6 etc.
  • 11. symbolsThe following are always treated as symbols:*read-base*The value of read base controls the interpretation of tokens by read as being integers or ratios.Its value is the radix in which the integers or ratios are to be read.The value must be any integer from 2 to 36,and it is normally 10. for ex if the *read-base* is set as 16(hexadecimal radix), variables with names such as a,b,f , bad and face will be treated by the reader as numbers./ /5 + 1+ 1- foo+ ab.cd - ^ ^/-
  • 12. *read-supress*if this value is set as nil, the Lisp reader operates normally, when it is not null the most interesting operation of the reader are suppressed.*read-eval* its default value is always t, if *read-eval* is false. Reader macro signals an error.
  • 13. Macro charactersWhen a macro character is encountered, then the function associated with that macro is invoked and may produce an object to be returned.Macro characters are normally defined as follows: The left parenthesis initiates reading a pair of list. The function read is called recursively to read successive objects until a right parenthesis is found to be next in the input stream. A list of objects read are returned.
  • 14. ‘ single-quote provides an abbreviation to make it easier to put constants in the programs.; is used to write comments.“ double-quote character represents the printed representation of a string.A back-quote is followed by a template, a picture of a data structure to be built.# is dispatching macro-character. It reads an optional digit string and then one more character, and uses that character to select a function to run as a macro-character function.
  • 15. Standard dispatching macro character syntax #\x reads in a character object that represents a character x.#\name1 reads in as the character object whose name is name1. The name1 should have the syntax of the symbol.# ’ is an abbreviation for (function foo)A series of representations of objects enclosed by #( and )is read as a simple vector of those objects.If unsigned decimal integer appears between the # and (, it specifies explicitly the length of the vector.
  • 16. #:foo requires foo to have a syntax of an unqualified symbol name.It denotes an uninterened symbol whose name is foo.Every time an uninterended symbol is created when this symbol is encountered.#,foo is read as the object resulting from the evaluation of the lisp object represented by foo, which may be the printed representation of any lisp object.#B reads rational in binary(radix 2) ex:#B110113#o reads rational in octal(radix 8) ex: #o777511#X reads rational in hexadecimal(radix 16) ex: #xFoo3840
  • 17. #nA constructs an n-dimensional arrayEx: #2A ((0 1 5) (foo 2(hot dog))) represents a 2 cross 3 matrix: 0 1 5 f00 2 (hot dog)#s (name slot1 value1 slot2 value2….) denotes a structure.#+ syntax provides a read time conditionality facility; the syntax is #+feature form#- form is equivalent to #+(not feature) form.If feature is true, then this syntax represents a lisp object whose printed representation is form.If the feature is false, then this syntax is effectively white space.
  • 18. The following names are standards across all implementations:Newline, spaceRubout  delete characterPage the form-feed or page-separator characterTab the tabulate character Return carriage return characterLinefeed the line-feed character
  • 19. Read tableRead table is the data structure used to control the reader.It has information about the syntax of each character.*read-table* is the current read tableTo program the reader for a different syntax, begin with the copy of the standard common lisp read table and then customize the individual characters within the copy.Copy-readtable &optional from-readtable to read-table
  • 20. readtable case readtable is a function used to control the readers interpretation of the case.It provides access to a slot in the read table.The possible values of the slots are::upcase replaceable characters are converted to upper case:downcase replaceable characters are converted into lower case:preserve the cases of all characters remain unchanged:invert all replicable characters of same case are converted to opposite case
  • 21. Input functionsCharacters in inputs take optional arguments called:Input-streamarguments is the argument from which to obtain the input from.
  • 22. eof-error-p argument controls if the input is from a file, and end of file is reached.
  • 23. If eof-error-p is true , an error will be signaled at the end of the file. If it is false, then no error is signaled, instead it returns eof-value.
  • 24. if end-of-file is encountered and eof-error-p argument is not nil, the kind of error that is signaled may depend on the value of recursive-p.read &optional input-stream eof-error-p eof-value recursive-preads in the printed representation of the lisp object from the input stream, builds a corresponding lisp object, and returns the object.read-delimited-list char &optional input-stream recursive-pthis reads objects from the stream until the next character after an object representation is a char.read-line &optional input-stream eof-error-p eof-value recursive-pread-line a line of text terminated by a new-line.It returns the line as a character string. read-char &optional input-stream eof-error-p eof-value recursive-p read-char input one character from the input stream and returns it as character object.
  • 25. Unread-char character &optional input-stream unread-char puts the character onto the front of the input-stream. listen &optional input-stream The predicate listen is true if there is a character immediately available from the input stream, and false if not. clear-input &optional input-streamClears any buffered input associated with the input stream. Read-byte binary-input-stream &optional eof-error-p eof-value read-byte tread one byte from the binary input stream and returns it in the form of an integer.
  • 26. Output functions that operate on stream of functionsThese functions take an optional argument output-stream(defaults to variable *standard-output*) on where to send the output. write object &key :stream :escape :radix :base :circle :pretty :level :length :case :gensym :array: readable: right-margin :miser-width :lines and :pprint-dispatchthe printed representation of the object is written to the output stream specified by :stream, which defaults to the value *standard-output* The other keyword arguments specify values used to control the generation of the printed representation.
  • 27. Prin1 object &optional output-streamprin1 outputs the printed representation of object to output-stream.Print object &optional output-streamprinted representation of the object is preceded by newline and followed by a space.PPrin1 object &optional output-streamtrailing space is omitted and the object is printed with the *print-pretty* flag non-nil to produce “pretty” output.Princ object &optional output-stream Is similar to prin1 except that the output has no escape characters.
  • 28. Write-char character &optional output-streamoutputs the character to the output stream and returns the characterWrite-string string &optional output-stream &key :start :endWrite-line string &optional output-stream &key :start :endwrites the character of the specified substring to the output-stream.The :start and :end delimit a substring of string in usual manner. write-lined does the same thing but then outputs a new-line afterwards.
  • 29. finish-output &optional output-stream Attempts to ensure that all the output sent to the output stream has reached the destination, only then returns nil.force-output &optional output-streaminitiates the emptying of any internal buffers and returns nil without waiting for completion.clear-output &optional output-streamAttempts to abort any outstanding poutput operation in progress in order to allow as less output as possible.Output to binary streams:Write-byte integer binary-output-stream write-byte returns one byte, the value of the integer.
  • 30. Formatted outputThe function format is used for producing nicely formatted text.format destination control-string &rest argumentsFormat outputs the characters of control stringA format directive consists of a tilde(~) , optional prefix parameters separated by commas, optional colon( : ) and ( @ ) sign modifiers, and a single character indicating what kind of directive this is.
  • 31. ~D, An arg, should be an integer is printed in decimal radix.Few examples for format function:(format nil “foo”) “foo”(setq x 5)(format nil “The answer is ~D.”, x)”The answer is 5.”(format nil “The answer is ~3D.”, x) “The answer is 5.”
  • 32. Querying the userThe following functions provide a convenient interface for asking the questions of the user.y-or-n-p &optional format-string &rest argumentsThis predicate is used for asking the user a question whose answer is either yes or no.It types a message if supplied.All input and output is performed using the stream in the global variable *query-io*
  • 33. Ex:(y-or-n-p “Produce Listing file?”) opens a pop-up asking “Produce Listing file?”with two options “Yes” and ‘no”. Returns T onyes else returns NIL.(y-or-n-p “Cannot connect to network host ~S. Retry?” host)Y-or-n-p must be used when the user waiting to be questioned before preceding further.
  翻译: