{"title":"Attribute grammars in Erlang","authors":"U. Norell, Alex Gerdes","doi":"10.1145/2804295.2804296","DOIUrl":null,"url":null,"abstract":"Many functions take a value of a particular (recursive) data structure as input and compute an output value by traversing the structure and collect, combine, or update values in that data structure. Some examples are: collecting all hyperlink tags in a HTML tree, calculating the depth of a binary tree, or adding a prefix to every free variable name in an abstract syntax tree. When defining such functions we need to write code that takes care of traversing a data structure. This code is often repeated for functions that operate on the same data structure, and is often not essential for the operation we want to perform. This type of repetitive code is often referred to as boilerplate code. Abstraction is a way to remove this boilerplate code, for example by defining higher-order functions. Higher-order functions can be used to separate the boilerplate code from the essential parts. Common examples of higher order functions are map and fold.","PeriodicalId":266108,"journal":{"name":"Proceedings of the 14th ACM SIGPLAN Workshop on Erlang","volume":"66 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2015-08-30","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"3","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 14th ACM SIGPLAN Workshop on Erlang","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/2804295.2804296","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 3
Abstract
Many functions take a value of a particular (recursive) data structure as input and compute an output value by traversing the structure and collect, combine, or update values in that data structure. Some examples are: collecting all hyperlink tags in a HTML tree, calculating the depth of a binary tree, or adding a prefix to every free variable name in an abstract syntax tree. When defining such functions we need to write code that takes care of traversing a data structure. This code is often repeated for functions that operate on the same data structure, and is often not essential for the operation we want to perform. This type of repetitive code is often referred to as boilerplate code. Abstraction is a way to remove this boilerplate code, for example by defining higher-order functions. Higher-order functions can be used to separate the boilerplate code from the essential parts. Common examples of higher order functions are map and fold.