:- local struct( book(author, title, year, publisher) ). |
which, in canonical syntax, correspond to the following:book{} book{title:'tom sawyer'} book{title:'tom sawyer', year:1876, author:twain}
There is absolutely no semantic difference between the two syntactical forms. The special struct-syntax with names has the advantage thatbook(_, _, _, _) book(_, 'tom sawyer', _, _) book(twain, 'tom sawyer', 1876, _)
When the structure has been declared as above, we can write instead:arg(3, B, Y)
Declared structures help readability, and make programs easier to modify. In order not to lose these benefits, one should always use curly-bracket and of-syntax when working with them, and never write them in canonical syntax or referring to argument positions numerically.arg(year of book, B, Y)