SlideShare a Scribd company logo
Implementing R7RS on R6RS Scheme 
Takashi Kato 
@tk_riple 
AAutuotro:r : 1 91.91.11.11.414
AAutuotro:r : 1 91.91.11.11.414 
Introduction 
It's been a year since R7RS was standardised. 
Numbers of libraries must be created by now.
Keyword Github Google Code 
R6RS 59 18 
R7RS 12 8 
AAutuotro:r : 1 91.91.11.11.414 
Repositories 
Keyword Github Google Code 
R6RS 59 18 
R7RS 12 8 
*Searched in August 2014 
*The numbers are not accurate 
*Searched in August 2014 
*The numbers are not accurate
AAutuotro:r : 1 91.91.11.11.414 
We can expect... 
The number would grow in the near future 
R6RS libraries are also useful 
It would be nice to be able to use both libraries
AAutuotro:r : 1 91.91.11.11.414 
So we want to... 
● Use R6RS libraries in R7RS libraries 
● Use procedural macros in R7RS libraries 
● Use R7RS libraries in R6RS libraries 
● Use syntax-case in R7RS libraries 
… so on 
IImmpplleemmeenntt RR77RRSS oonn RR66RRSS!!
define-library vs library 
export phasing 
include 
include-ci 
cond-expand 
AAutuotro:r : 1 91.91.11.11.414 
What needs to be done... 
RReessoollvviinngg i innccoommppaattiibbiilliittiieess 
define-library vs library 
export phasing 
include 
include-ci 
cond-expand 
#u8() vs #vu8() #u8() vs #vu8() 
|symbol escape| vs symbolx20;escape |symbol escape| vs symbolx20;escape
AAutuotro:r : 1 91.91.11.11.414 
define-library vs library 
R7RS 
● define-library 
● Very flexible 
– import, export, begin, 
cond-expand and include 
related clauses. 
– These can be appear in 
any order and any number 
of times. 
● No phasing 
– R7RS has only syntax-rules 
R6RS 
● library 
● Rather fixed form 
– export and import with 
respective order 
● Phasing
AAutuotro:r : 1 91.91.11.11.414 
Lexical notations 
R7RS 
#u8( 1 2 3) 
| f oo bar | 
| f oo x20; bar | 
. f oo 
@f oo 
f oo x20; bar 
R6RS 
#vu8( 1 2 3) 
f oo x20; bar 
| f oo bar | 
. f oo 
@f oo
Handling lexical notations... 
● needs to be done by readers 
– Basically no other way :) 
● is easy but how should implementations write a 
datum in proper notations? 
– Using #! directives, like #! r 6r s? 
– Oops, R7RS doesn't have #! r 7r s 
● So using it would be implementation dependent 
AAutuotro:r : 1 91.91.11.11.414
Handling define-library forms... 
● is the problem 
– R7RS has extra keywords; include, include-ci, etc. 
– But it doesn't have phasing keyword 
● can be done in 2 ways; 
– Expander should expand it to l i br ar y form 
– Compiler should handle it 
AAutuotro:r : 1 91.91.11.11.414
Transforming R7RS library form... 
● May require resolving proper phase 
– Only for implementations adopted explicit phasing 
● Requires tracking include or include-ci 
– It is important to know where the source location is 
– What if a macro contains include expression? 
– What if include symbol is shadowed? 
AAutuotro:r : 1 91.91.11.11.414
AAutuotro:r : 1 91.91.11.11.414 
Recall: Phasing 
( l i br ar y ( f oo) 
( expor t f oo) 
( i mpor t ( f or ( r nr s) r un expand) ) 
( def i ne- synt ax f oo 
( l ambda ( x) 
( def i ne- synt ax name 
( synt ax- rul es ( ) 
( ( _ k) 
( dat um- >synt ax k ( s t ri ng- >symbol "bar" ) ) ) ) ) 
( synt ax- case x ( ) 
( ( k) 
( wi t h- synt ax ( ( def ( name #' k) ) ) 
#' ( def i ne def ' bar ) ) ) ) ) ) )
AAutuotro:r : 1 91.91.11.11.414 
Resolving phasing 
(foo) in R7RS 
( def i ne- l i br ar y ( f oo) 
( i mpor t …) 
( expor t …) 
( begi n 
( def i ne- synt ax f oo 
…) ) 
) 
After the transformation 
( l i br ar y ( f oo) 
( expor t …) 
( i mpor t ( f or …) …) 
( def i ne- synt ax f oo 
…) 
)
How should this be resolved? 
File hierarchy 
/ 
+ foo.sld 
+ impl/ 
+ bar.scm 
+ buzz.scm 
+ buzz.scm 
AAutuotro:r : 1 91.91.11.11.414 
; ; f oo. sl d 
( def i ne- l i br ar y ( f oo) 
( i mpor t ( scheme base) ) 
( expor t bar ) 
( i ncl ude " i mpl / bar . scm" ) ) 
; ; i mpl / bar . scm 
( i ncl ude " buzz. scm" ) 
; ; i mpl / buzz. scm 
( def i ne bar ' bar ) 
; ; buzz. scm 
( def i ne bar ' boo)
AAutuotro:r : 1 91.91.11.11.414 
Well... 
R7RS doesn't specify how to resolve the file paths... 
However, 
It would be nice if it's resolved as C preprocessor does. 
So symbol bar should be bound to f oo.
How should this be resolved? 
; ; f i l e- a. scm 
( def i ne- synt ax i ncl ude- i t 
( synt ax- r ul es ( ) 
( ( _ f i l e) 
( i ncl ude f i l e) ) ) ) 
; ; f i l e- b. scm 
( i ncl ude- i t " buzz. scm" ) 
AAutuotro:r : 1 91.91.11.11.414 
From where 'buzz.scm' 
should be resolved? 
From 'file-b.scm' should 
make more sense to users.
AAutuotro:r : 1 91.91.11.11.414 
To do that... 
● Expander should know where include expressions 
are evaluated. 
● Plus, result of macro expansion 
Thus expander needs to do not only transforming 
define-libray to library but also expand macros...
Implementing on Sagittarius 
● define-library as the built-in syntax 
– Avoid implementing macro expander twice 
– The compiler can use the compile time environment 
● include and include-ci are resolved 2 ways 
– As a library keyword, it's simply sliced 
● Paths are resolved from where the library is located 
– As a syntax, compiler considers bindings 
● Paths are resolved from where the current file is. 
AAutuotro:r : 1 91.91.11.11.414
Handling lexical notations (2) 
● The reader can read both R6RS and R7RS notations 
– Also providing strict modes 
● Writing R7RS bytevectors requires #!r7rs directive 
– The default mode writes in R6RS style 
AAutuotro:r : 1 91.91.11.11.414
AAutuotro:r : 1 91.91.11.11.414 
Interoperation 
; ; Expor t i ng pr ocedur al macr o f r om R6RS l i br ar y 
( l i br ar y ( ai f ) 
( expor t ai f ) 
( i mpor t ( r nr s) ) 
( def i ne- synt ax ai f 
( l ambda ( x) 
( synt ax- case x ( ) 
( ( ai f c t ) 
#' ( ai f c t ( i f #f #t ) ) ) 
( ( k c t e) 
( wi t h- synt ax ( ( i t ( dat um- >synt ax #' k ' i t ) ) ) 
#' ( l et ( ( i t c) ) 
( i f i t t e) ) ) ) ) ) ) )
AAutuotro:r : 1 91.91.11.11.414 
Interoperation 
; ; usi ng pr ocedur al macr o i n R7RS l i br ar y 
( def i ne- l i br ar y ( f oo) 
( i mpor t ( scheme base) ( ai f ) ) 
( expor t a) 
( begi n 
( def i ne a 
( l et ( ( l i s ' ( ( a . 0) ( b . 1) ( c . 2) ) ) ) 
( ai f ( assq ' a l i s) 
( cdr i t ) ) ) ) ) ) 
; ; bel ow can be bot h R6RS/ R7RS scr i pt 
( i mpor t ( f oo) ) 
a
AAutuotro:r : 1 91.91.11.11.414 
Conclusion 
● Making R7RS Scheme system on top of R6RS is not 
an easy task 
– Not so difficult either 
● Availability of both R6RS and R7RS can be a big 
advantage and good for future Scheme users
AAutuotro:r : 1 91.91.11.11.414 
Questions?

More Related Content

PDF
What Does R7RS Change Programming in Scheme?
PDF
Virtual Machine for Regular Expressions
PDF
An evaluation of LLVM compiler for SVE with fairly complicated loops
PDF
Arm tools and roadmap for SVE compiler support
PDF
Code gpu with cuda - CUDA introduction
PDF
Compilation of COSMO for GPU using LLVM
PDF
Assembly language part I
PPTX
Dive into ROP - a quick introduction to Return Oriented Programming
What Does R7RS Change Programming in Scheme?
Virtual Machine for Regular Expressions
An evaluation of LLVM compiler for SVE with fairly complicated loops
Arm tools and roadmap for SVE compiler support
Code gpu with cuda - CUDA introduction
Compilation of COSMO for GPU using LLVM
Assembly language part I
Dive into ROP - a quick introduction to Return Oriented Programming

What's hot (20)

PPTX
Winter training,Readymade Projects,Buy Projects,Corporate Training
PPT
PPTX
An introduction to ROP
PDF
Debug Line Issues After Relaxation.
PDF
FPGAを用いた処理のロボット向けコンポーネントの設計生産性評価
PDF
Cray XT Porting, Scaling, and Optimization Best Practices
PPTX
Return oriented programming (ROP)
PDF
ROP 輕鬆談
PPTX
The Next Linux Superpower: eBPF Primer
PDF
The Practice of Alluxio in Ctrip Bigdata Platform
PPT
OpenMP
PDF
Course lecture - An introduction to the Return Oriented Programming
PDF
ARM 64bit has come!
PDF
Sacándole jugo a git
PDF
自律移動ロボット向けハード・ソフト協調のためのコンポーネント設計支援ツール
PDF
cReComp : Automated Design Tool for ROS-Compliant FPGA Component
PPTX
Stack in 8085 microprocessor
PPTX
Understanding eBPF in a Hurry!
PPTX
Multi-threading your way out
PDF
FPGAの処理をソフトウェアコンポーネント化する設計ツールcReCompの高機能化の検討
Winter training,Readymade Projects,Buy Projects,Corporate Training
An introduction to ROP
Debug Line Issues After Relaxation.
FPGAを用いた処理のロボット向けコンポーネントの設計生産性評価
Cray XT Porting, Scaling, and Optimization Best Practices
Return oriented programming (ROP)
ROP 輕鬆談
The Next Linux Superpower: eBPF Primer
The Practice of Alluxio in Ctrip Bigdata Platform
OpenMP
Course lecture - An introduction to the Return Oriented Programming
ARM 64bit has come!
Sacándole jugo a git
自律移動ロボット向けハード・ソフト協調のためのコンポーネント設計支援ツール
cReComp : Automated Design Tool for ROS-Compliant FPGA Component
Stack in 8085 microprocessor
Understanding eBPF in a Hurry!
Multi-threading your way out
FPGAの処理をソフトウェアコンポーネント化する設計ツールcReCompの高機能化の検討
Ad

Viewers also liked (13)

PPTX
Matriz FODA Mail Boxes etc.
PPTX
ppt kritisi dan evaluasi radiograf colon in loop
PPTX
Short Functional Text
PDF
IKO System cross-border prospecting webinar September 2016
PPTX
International Market Entry Strategies
PPTX
ppt kritisi dan evaluasi radiograf Oesofagus Maag Duodenum
DOCX
Nama icon dan fungsi ms word yang sering digunakan
PPTX
Causas e origens da Filosofia
PDF
Karakter dizileri
PDF
Fungsi Icon-Icon Komputer
DOCX
Simbol dan fungsi ikon pada ms.excel
PDF
5 teknik pembukaan presentasi by mustofa thovids (slide presentation expert)
PDF
RPP SMK Gambar Teknik Kelas X
Matriz FODA Mail Boxes etc.
ppt kritisi dan evaluasi radiograf colon in loop
Short Functional Text
IKO System cross-border prospecting webinar September 2016
International Market Entry Strategies
ppt kritisi dan evaluasi radiograf Oesofagus Maag Duodenum
Nama icon dan fungsi ms word yang sering digunakan
Causas e origens da Filosofia
Karakter dizileri
Fungsi Icon-Icon Komputer
Simbol dan fungsi ikon pada ms.excel
5 teknik pembukaan presentasi by mustofa thovids (slide presentation expert)
RPP SMK Gambar Teknik Kelas X
Ad

Similar to Implementing R7RS on R6RS Scheme (20)

PDF
tybsc cs game programming Introduction-to-GPUs.pdf
PDF
(8) cpp stack automatic_memory_and_static_memory
PDF
AllBits presentation - Lower Level SW Security
PDF
Exploring the x64
PDF
04basic Concepts
PPTX
Paper_Scalable database logging for multicores
PDF
HackLU 2018 Make ARM Shellcode Great Again
PDF
20141106 asfws unicode_hacks
PDF
Zebra SRv6 CLI on Linux Dataplane (ENOG#49)
PDF
Debugging Ruby Systems
PDF
#CNX14 - Using Ruby for Reliability, Consistency, and Speed
PDF
JDD 2016 - Tomasz Borek - DB for next project? Why, Postgres, of course
PPTX
Arm chap 3 last
PDF
Performance tweaks and tools for Linux (Joe Damato)
PDF
Range reader/writer locking for the Linux kernel
PDF
Pragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
PPTX
test
PDF
MLflow with R
PPTX
Processor types
PDF
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
tybsc cs game programming Introduction-to-GPUs.pdf
(8) cpp stack automatic_memory_and_static_memory
AllBits presentation - Lower Level SW Security
Exploring the x64
04basic Concepts
Paper_Scalable database logging for multicores
HackLU 2018 Make ARM Shellcode Great Again
20141106 asfws unicode_hacks
Zebra SRv6 CLI on Linux Dataplane (ENOG#49)
Debugging Ruby Systems
#CNX14 - Using Ruby for Reliability, Consistency, and Speed
JDD 2016 - Tomasz Borek - DB for next project? Why, Postgres, of course
Arm chap 3 last
Performance tweaks and tools for Linux (Joe Damato)
Range reader/writer locking for the Linux kernel
Pragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
test
MLflow with R
Processor types
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)

Recently uploaded (20)

PDF
Nekopoi APK 2025 free lastest update
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
System and Network Administration Chapter 2
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
ai tools demonstartion for schools and inter college
PPTX
Introduction to Artificial Intelligence
PPTX
L1 - Introduction to python Backend.pptx
PDF
System and Network Administraation Chapter 3
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
medical staffing services at VALiNTRY
Nekopoi APK 2025 free lastest update
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Understanding Forklifts - TECH EHS Solution
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
System and Network Administration Chapter 2
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Softaken Excel to vCard Converter Software.pdf
ai tools demonstartion for schools and inter college
Introduction to Artificial Intelligence
L1 - Introduction to python Backend.pptx
System and Network Administraation Chapter 3
How to Migrate SBCGlobal Email to Yahoo Easily
PTS Company Brochure 2025 (1).pdf.......
VVF-Customer-Presentation2025-Ver1.9.pptx
medical staffing services at VALiNTRY

Implementing R7RS on R6RS Scheme

  • 1. Implementing R7RS on R6RS Scheme Takashi Kato @tk_riple AAutuotro:r : 1 91.91.11.11.414
  • 2. AAutuotro:r : 1 91.91.11.11.414 Introduction It's been a year since R7RS was standardised. Numbers of libraries must be created by now.
  • 3. Keyword Github Google Code R6RS 59 18 R7RS 12 8 AAutuotro:r : 1 91.91.11.11.414 Repositories Keyword Github Google Code R6RS 59 18 R7RS 12 8 *Searched in August 2014 *The numbers are not accurate *Searched in August 2014 *The numbers are not accurate
  • 4. AAutuotro:r : 1 91.91.11.11.414 We can expect... The number would grow in the near future R6RS libraries are also useful It would be nice to be able to use both libraries
  • 5. AAutuotro:r : 1 91.91.11.11.414 So we want to... ● Use R6RS libraries in R7RS libraries ● Use procedural macros in R7RS libraries ● Use R7RS libraries in R6RS libraries ● Use syntax-case in R7RS libraries … so on IImmpplleemmeenntt RR77RRSS oonn RR66RRSS!!
  • 6. define-library vs library export phasing include include-ci cond-expand AAutuotro:r : 1 91.91.11.11.414 What needs to be done... RReessoollvviinngg i innccoommppaattiibbiilliittiieess define-library vs library export phasing include include-ci cond-expand #u8() vs #vu8() #u8() vs #vu8() |symbol escape| vs symbolx20;escape |symbol escape| vs symbolx20;escape
  • 7. AAutuotro:r : 1 91.91.11.11.414 define-library vs library R7RS ● define-library ● Very flexible – import, export, begin, cond-expand and include related clauses. – These can be appear in any order and any number of times. ● No phasing – R7RS has only syntax-rules R6RS ● library ● Rather fixed form – export and import with respective order ● Phasing
  • 8. AAutuotro:r : 1 91.91.11.11.414 Lexical notations R7RS #u8( 1 2 3) | f oo bar | | f oo x20; bar | . f oo @f oo f oo x20; bar R6RS #vu8( 1 2 3) f oo x20; bar | f oo bar | . f oo @f oo
  • 9. Handling lexical notations... ● needs to be done by readers – Basically no other way :) ● is easy but how should implementations write a datum in proper notations? – Using #! directives, like #! r 6r s? – Oops, R7RS doesn't have #! r 7r s ● So using it would be implementation dependent AAutuotro:r : 1 91.91.11.11.414
  • 10. Handling define-library forms... ● is the problem – R7RS has extra keywords; include, include-ci, etc. – But it doesn't have phasing keyword ● can be done in 2 ways; – Expander should expand it to l i br ar y form – Compiler should handle it AAutuotro:r : 1 91.91.11.11.414
  • 11. Transforming R7RS library form... ● May require resolving proper phase – Only for implementations adopted explicit phasing ● Requires tracking include or include-ci – It is important to know where the source location is – What if a macro contains include expression? – What if include symbol is shadowed? AAutuotro:r : 1 91.91.11.11.414
  • 12. AAutuotro:r : 1 91.91.11.11.414 Recall: Phasing ( l i br ar y ( f oo) ( expor t f oo) ( i mpor t ( f or ( r nr s) r un expand) ) ( def i ne- synt ax f oo ( l ambda ( x) ( def i ne- synt ax name ( synt ax- rul es ( ) ( ( _ k) ( dat um- >synt ax k ( s t ri ng- >symbol "bar" ) ) ) ) ) ( synt ax- case x ( ) ( ( k) ( wi t h- synt ax ( ( def ( name #' k) ) ) #' ( def i ne def ' bar ) ) ) ) ) ) )
  • 13. AAutuotro:r : 1 91.91.11.11.414 Resolving phasing (foo) in R7RS ( def i ne- l i br ar y ( f oo) ( i mpor t …) ( expor t …) ( begi n ( def i ne- synt ax f oo …) ) ) After the transformation ( l i br ar y ( f oo) ( expor t …) ( i mpor t ( f or …) …) ( def i ne- synt ax f oo …) )
  • 14. How should this be resolved? File hierarchy / + foo.sld + impl/ + bar.scm + buzz.scm + buzz.scm AAutuotro:r : 1 91.91.11.11.414 ; ; f oo. sl d ( def i ne- l i br ar y ( f oo) ( i mpor t ( scheme base) ) ( expor t bar ) ( i ncl ude " i mpl / bar . scm" ) ) ; ; i mpl / bar . scm ( i ncl ude " buzz. scm" ) ; ; i mpl / buzz. scm ( def i ne bar ' bar ) ; ; buzz. scm ( def i ne bar ' boo)
  • 15. AAutuotro:r : 1 91.91.11.11.414 Well... R7RS doesn't specify how to resolve the file paths... However, It would be nice if it's resolved as C preprocessor does. So symbol bar should be bound to f oo.
  • 16. How should this be resolved? ; ; f i l e- a. scm ( def i ne- synt ax i ncl ude- i t ( synt ax- r ul es ( ) ( ( _ f i l e) ( i ncl ude f i l e) ) ) ) ; ; f i l e- b. scm ( i ncl ude- i t " buzz. scm" ) AAutuotro:r : 1 91.91.11.11.414 From where 'buzz.scm' should be resolved? From 'file-b.scm' should make more sense to users.
  • 17. AAutuotro:r : 1 91.91.11.11.414 To do that... ● Expander should know where include expressions are evaluated. ● Plus, result of macro expansion Thus expander needs to do not only transforming define-libray to library but also expand macros...
  • 18. Implementing on Sagittarius ● define-library as the built-in syntax – Avoid implementing macro expander twice – The compiler can use the compile time environment ● include and include-ci are resolved 2 ways – As a library keyword, it's simply sliced ● Paths are resolved from where the library is located – As a syntax, compiler considers bindings ● Paths are resolved from where the current file is. AAutuotro:r : 1 91.91.11.11.414
  • 19. Handling lexical notations (2) ● The reader can read both R6RS and R7RS notations – Also providing strict modes ● Writing R7RS bytevectors requires #!r7rs directive – The default mode writes in R6RS style AAutuotro:r : 1 91.91.11.11.414
  • 20. AAutuotro:r : 1 91.91.11.11.414 Interoperation ; ; Expor t i ng pr ocedur al macr o f r om R6RS l i br ar y ( l i br ar y ( ai f ) ( expor t ai f ) ( i mpor t ( r nr s) ) ( def i ne- synt ax ai f ( l ambda ( x) ( synt ax- case x ( ) ( ( ai f c t ) #' ( ai f c t ( i f #f #t ) ) ) ( ( k c t e) ( wi t h- synt ax ( ( i t ( dat um- >synt ax #' k ' i t ) ) ) #' ( l et ( ( i t c) ) ( i f i t t e) ) ) ) ) ) ) )
  • 21. AAutuotro:r : 1 91.91.11.11.414 Interoperation ; ; usi ng pr ocedur al macr o i n R7RS l i br ar y ( def i ne- l i br ar y ( f oo) ( i mpor t ( scheme base) ( ai f ) ) ( expor t a) ( begi n ( def i ne a ( l et ( ( l i s ' ( ( a . 0) ( b . 1) ( c . 2) ) ) ) ( ai f ( assq ' a l i s) ( cdr i t ) ) ) ) ) ) ; ; bel ow can be bot h R6RS/ R7RS scr i pt ( i mpor t ( f oo) ) a
  • 22. AAutuotro:r : 1 91.91.11.11.414 Conclusion ● Making R7RS Scheme system on top of R6RS is not an easy task – Not so difficult either ● Availability of both R6RS and R7RS can be a big advantage and good for future Scheme users
  • 23. AAutuotro:r : 1 91.91.11.11.414 Questions?