Keyword definition pattern

In Julia, you can create an object using the default constructor, which accepts a list of positional arguments for each of the fields defined for the struct. For small objects, this should be simple and straightforward. For larger objects, it becomes confusing because it is hard to remember which argument corresponds to which field without referring to the struct's definition every time we write code to create such objects.

In 1956, George Miller, a psychologist, published research that involved figuring out how many random digits a person could remember at any time, so the Bell System could decide how many numbers to use for the format of a telephone number. He found that most people can only remember five to nine digits at any time.

If remembering digits is difficult enough, it should be even more difficult to remember fields that come with different names and types.

We will discuss how to reduce such stress when developing Julia code, and how it can be done using the @kwdef macro so that the code is easy to read and maintain.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.47.221