Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mastering Julia

You're reading from  Mastering Julia

Product type Book
Published in Jul 2015
Publisher
ISBN-13 9781783553310
Pages 410 pages
Edition 1st Edition
Languages

Metaprogramming


Julia has been designed to tackle problems arising in science and statistics. It follows the route of traditional imperative languages. It is not a functional language, such as Haskell, OCaml, and Clojure, but since it incorporates a Scheme interpreter, it is possible to create runtime macros rather than the preprocessor style ones found in C/C++.

Macros are useful in efficiently generating boilerplate code, and we have already made use of the @printf macro, which emulates the C-style printf() function.

If a true functional approach is required, the reader is directed to the Lazy.jl package, which implements lazily evaluated lists plus a library of functions to use them and many well-designed macros. So, to get a grasp of Julia metaprogramming, you could do no better than looking at the source code in the Lazy package.

To generate macros, a language needs to have the property of homoiconicity. This means that the primary representation of program code is also a data structure...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}