Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Sweet Macros O’ Mine @ythecombinator #dev-schoolls
Slide 2
Slide 2 text
[Small Bites] Matheus
Slide 3
Slide 3 text
No content
Slide 4
Slide 4 text
No content
Slide 5
Slide 5 text
No content
Slide 6
Slide 6 text
• Instance and type methods • Computed instance and computed type properties • Initializers • Subscripts • Conformance to a protocol
Slide 7
Slide 7 text
No content
Slide 8
Slide 8 text
Macros
Slide 9
Slide 9 text
Small things that can syntactically parse and transform code around them.
Slide 10
Slide 10 text
No content
Slide 11
Slide 11 text
.h file .m file .swift file
Slide 12
Slide 12 text
1.opens up a text file; 2.does a search-and-replace process; 3.saves.
Slide 13
Slide 13 text
No content
Slide 14
Slide 14 text
functions that WORK OVER ASTs.
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
Sweet Macros O’ Mine
Slide 17
Slide 17 text
No content
Slide 18
Slide 18 text
Macros for languages that have a lot of special syntax take advantage of pattern matching.
Slide 19
Slide 19 text
No content
Slide 20
Slide 20 text
ma o definiti k w d
Slide 21
Slide 21 text
a new v iable the c t block scope
Slide 22
Slide 22 text
st pa рn
Slide 23
Slide 23 text
sec d pa рn
Slide 24
Slide 24 text
vok g
Slide 25
Slide 25 text
No content
Slide 26
Slide 26 text
No content
Slide 27
Slide 27 text
No content
Slide 28
Slide 28 text
No content
Slide 29
Slide 29 text
No content
Slide 30
Slide 30 text
No content
Slide 31
Slide 31 text
All macros in sweet.js are fully hygienic, which means that identifiers always reference the correct thing.
Slide 32
Slide 32 text
And so?
Slide 33
Slide 33 text
https://github.com/oleiman/sweet-contracts
Slide 34
Slide 34 text
https://github.com/srikumarks/cspjs
Slide 35
Slide 35 text
https://github.com/natefaubion/sparkler
Slide 36
Slide 36 text
https://github.com/siren-lang/siren
Slide 37
Slide 37 text
https://github.com/sweet-js/sweet.js/wiki/ Example-macros
Slide 38
Slide 38 text
Are macros sexy?
Slide 39
Slide 39 text
No content
Slide 40
Slide 40 text
No content
Slide 41
Slide 41 text
What if we stopped creating compile-to-JS languages and started recreating JS?
Slide 42
Slide 42 text
THANKS. @ythecombinator #dev-schoolls
Slide 43
Slide 43 text
THANKS. @ythecombinator #dev-schoolls