Yes Postings are not directives Now they happen to also sport metadata but that was not always the case
On Jun 23, 2017 05:25, <[email protected]> wrote: > Thank you Martin, that makes sense. > > What is the reason for Posting not following this? My guess is that it's > because postings don't really exist as separate "objects" and are only > found with Transactions, which can have dates and meta attributes. Is this > the right interpretation? > > On Friday, 23 June 2017 03:12:23 UTC+1, Martin Blais wrote: >> >> On Thu, Jun 22, 2017 at 8:17 AM, <[email protected]> wrote: >> >>> *TL/DR: what's the purpose of new_directive() wrapper around >>> NamedTuple()?* >>> >>> I've been following Beancount for a while, and I wanted to fork the >>> project and make some modifications for my own use and maybe contribute >>> back to the project at some point. But before that I want to get a good >>> understanding of the source code. I was going through the basic data >>> structures, and I'm trying to understand the *new_directive *factory. >>> In beancount.core some classes (e.g. Posting) are created via a >>> *NamedTuple()*, while others (e.g. Transaction) are created via >>> *new_directive()*. *new_directive()* itself is a thin wrapper around >>> *NamedTuple()* anyway. >>> >>> So I would like to know what is the rationale for using one over the >>> other, or for new_directive() existence in general? >>> >> >> It's just a convenience function that avoids having to repeat the common >> attributes "meta" and "date". >> It also makes it clear all directives are guaranteed to have those >> attributes. >> >> (I tend to use functional programming principles in my programming and >> Beancount's source code is an example of that; I don't believe that >> "functional" is an attribute of the language one uses - though certainly >> some languages offers more support than others to craft functional programs >> - but rather that it is an attribute of the patterns of data mutation one >> utilizes (or avoids).) >> >> -- > You received this message because you are subscribed to the Google Groups > "Beancount" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/beancount/f4ffac68-6424-45f0-b20e-e2ad63742c2b%40googlegroups.com > <https://groups.google.com/d/msgid/beancount/f4ffac68-6424-45f0-b20e-e2ad63742c2b%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Beancount" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CAK21%2BhNXoBteOa2j7k9snsOfeKAM25eZFR2Nw%3D8xMYyEYF%2B_5Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
