IMPORTANT NOTICE: Devheroes public code hosting will shut down at 1st of March 2023. Due to some difficulties, we have to shut down the instance. Since codeberg.org is pretty mature and welcoming, We highly recommend you to move your code there. Please be advised that on 1st of March, your data will be removed. Thanks for your time with us, and may the source be with you.
@ -90,9 +90,12 @@ For example, `(fg42/merge-flags (list f1 f2 f3) f4 -f2)' will return `(f1 f3 f4)
@@ -90,9 +90,12 @@ For example, `(fg42/merge-flags (list f1 f2 f3) f4 -f2)' will return `(f1 f3 f4)
@ -556,7 +556,8 @@ A collection of handy functions that operate on ~sequences~.
@@ -556,7 +556,8 @@ A collection of handy functions that operate on ~sequences~.
#+END_SRC
- ~seq-min~, ~seq-max~
* Episode 9 - Introduction to Macros
* DONE Episode 9 - Introduction to Macros
CLOSED: [2022-09-11 Sun 11:08]
** What is a macro?
- A macro is defined much like a function
- It works on compile time
@ -598,7 +599,32 @@ A collection of handy functions that operate on ~sequences~.
@@ -598,7 +599,32 @@ A collection of handy functions that operate on ~sequences~.
- [[https://twitter.com/lxsameer][@lxsameer]] on Twitter
* Episode 10 - More on Macros
** Quasiquotes aka back quote
** Quasiquote aka backquote (`)
- Backquote constructs allow us to quote an expression, but selectively evaluate sub-expressions
- Similar to a template engine for lisp expressions
- It can be used on its own but it will shine in macro definitions
- On the simplest form it is identical to ~quote~
- Special markers ~,~ and ~,@~ can be used to mark expressions for evaluation
- ~,~ will replace the return value of the evaluation with the expression
- ~,@~ will replace and splice the return value of the evaluation
*** Examples
#+BEGIN_SRC emacs-lisp
`3
`(1 2 3 4)
`(1 2 3 ,(+ 5 6))
`(1 2 3 ,(list 4 5 6))
`(1 2 3 ,@(list 4 5 6))
`(setq ,(intern (upcase "some_var")) 3)
#+END_SRC
** ~declare~ form
- It's a special macro which can be used to add meta properties to a function or macro
+ ~doc-string~
+ ~indent~
** Real Examples
Let's discuss ~defflag~ and ~when-flag~ macros in [[file:../core/fg42/flags.el]]