Skip to content

Commit

Permalink
add some clarification on non-standard string literals
Browse files Browse the repository at this point in the history
  • Loading branch information
Beramos committed Feb 4, 2024
1 parent 501aa03 commit 4e2bd41
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions notebooks/day2/04-metaprogramming.jl
Original file line number Diff line number Diff line change
Expand Up @@ -551,16 +551,21 @@ to placing the following object directly into the syntax tree:
# ╔═╡ ce8b16fa-7644-4c64-ad3c-cbf667b4811b
Regex("^\\s*(?:#|\$)")

# ╔═╡ 48a68105-9a30-4dd1-9f7b-eebf1c19c856
md"""
!!! note
It might be confusion that the `@`-symbol is not used for calling these macros. It is a convention that when defining a macro with the `_str` suffix, one can use the macro as a prefix to string literals. These object are called [non-standard string literals](https://docs.julialang.org/en/v1/manual/metaprogramming/#meta-non-standard-string-literals).
"""

# ╔═╡ f20221ca-82d1-4973-9f68-e46638c929f7
md"Not only is the string literal form shorter and far more convenient, but it is also more efficient:
since the regular expression is compiled, which takes time, and the `Regex` object is actually created *when the code is compiled*, the compilation occurs only once, rather than every time the code is executed.
"
since the regular expression is compiled, which takes time, and the `Regex` object is actually created *when the code is compiled*, the compilation occurs only once, rather than every time the code is executed."

# ╔═╡ 311a4666-5fc5-11eb-2cc0-ef66e5be96e3
md"check if an expression is true"

# ╔═╡ 4622422a-5fc5-11eb-20f2-9bfe466f8f30
@assert true == true
# ╔═╡ cb0907b5-a8d9-4954-85cc-2040887f5e3c
md"**Other examples of useful macros:**"

# ╔═╡ 5ba5d6b6-5fc5-11eb-256b-73a954a5db68
md"Integers and floating point numbers with arbitrary precision. This macro exists because promoting a floating point number to a `BigFloat` will keep the approximation error of `Float64`."
Expand Down Expand Up @@ -1986,9 +1991,9 @@ version = "1.4.1+1"
# ╟─d889f68e-4d15-4bab-92f6-c42bac58e60a
# ╟─fe4095e9-0c35-4459-98b0-30ba91fc90b4
# ╠═ce8b16fa-7644-4c64-ad3c-cbf667b4811b
# ╟─48a68105-9a30-4dd1-9f7b-eebf1c19c856
# ╟─f20221ca-82d1-4973-9f68-e46638c929f7
# ╟─311a4666-5fc5-11eb-2cc0-ef66e5be96e3
# ╠═4622422a-5fc5-11eb-20f2-9bfe466f8f30
# ╟─cb0907b5-a8d9-4954-85cc-2040887f5e3c
# ╟─5ba5d6b6-5fc5-11eb-256b-73a954a5db68
# ╠═a47ab60e-5fc5-11eb-368a-d76fc6ee640d
# ╠═a99546c2-5fc5-11eb-0902-71cb283543c8
Expand Down

0 comments on commit 4e2bd41

Please sign in to comment.