Download presentation
Presentation is loading. Please wait.
Published byMiles McGee Modified over 9 years ago
1
Compile Time Abstraction Techniques for the D Programming Language Benjamin Shropshire
2
Abstraction What Why When How
3
Benjamin Shropshire3 What & Why What:Isolation of lower level complexity –Distillation of Intent –Removal of redundancy Why:Saving Time –Programming time –Maintenance time –User time
4
Benjamin Shropshire4 When to use Abstractions? Let the computer do what it is good at. Abstract where abstraction is a good fit
5
Benjamin Shropshire5 When to Not use Abstractions? If the abstraction doesn't fit, don't force it. Beware of premature optimizations. –Code speed –Coding speed –Test optimizations.
6
Compile time processing Nesting Templates Chained Recursion Nested Tuples
7
Benjamin Shropshire7 Nesting Templates Define two lists using two templates
8
Benjamin Shropshire8 Nesting Templates Multiple Tuples Useful naming
9
Benjamin Shropshire9 Chained Recursion Starting point Introduce alias to nested templates Nested templates that do something and then also use mixin
10
Benjamin Shropshire10 Chained Recursion Object Oriented style design Domain Specific Languages Closer to what is wanted
11
Benjamin Shropshire11 Nested Tuples Alias tuples inside of strut
12
Benjamin Shropshire12 Nested Tuples Use structs – Alias in templates don’t work – foreach works well on types
13
All Together Now Compile Time Parsing Compile Time Parser Generation
14
Benjamin Shropshire14 Compile Time Parsing Reading Data Building tree
15
Benjamin Shropshire15 Compile Time Parsing Attempt to parse D Attempt to parse B Build tuple of D’s Record unused input
16
Benjamin Shropshire16 Compile Time Parsing Found BCA Found BC failed on A, so parsing only B Found B failed on C, so parsing only B Failed on B, so failing
17
Benjamin Shropshire17 Compile Time Parsing
18
Benjamin Shropshire18 Compile Time Parser Generation Parse grammar Select production to instance Try each disjunction –Try each part Recurs to other productions Record checkpoints Backtrack through checkpoints on failure
19
Benjamin Shropshire19 Compile Time Parser Generation
20
Benjamin Shropshire20 Compile Time Abstraction Techniques for the D Programming Language Benjamin Shropshire Dr. Robert Hiromoto Michael Hewitt Dr. David Buehler Dr. Geoffrey Shropshire Eric Hewitt Special Thanks to:
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.