[icfp] size of elab fucntions

This commit is contained in:
ben 2016-03-16 02:14:03 -04:00
parent 56cf0b3ffc
commit 0250b7b109
2 changed files with 56 additions and 17 deletions

View File

@ -1,15 +1,52 @@
\newcommand{\twoline}[2]{\parbox[s]{1.44cm}{\flushright\hfill #1\newline#2}} \newcommand{\twoline}[2]{\parbox[s]{1.44cm}{\flushright\hfill #1\newline#2}}
\begin{tabular}{l r r r} \begin{tabular}{l r r r}
Module & LOC & $\interp$ & $\trans$ \\\hline Module & LOC & $\interp$ (LOC) & $\elab$ (LOC) \\\hline
\mod{db} & 263 & 2 (78) & 2 (101) \\ \mod{db} & 263 & 2 (78) & 2 (101) \\
\mod{format} & 66 & 1 (33) & 1 \,~(21) \\ \mod{format} & 66 & 1 (33) & 1 \,~(21) \\
\mod{function} & 31 & 1 ~~(8) & 1 \,~(11) \\ \mod{function} & 117 & 1 (11) & 2 \,~(51) \\
\mod{math} & 90 & 1 ~~(3) & 5 \,~(46) \\ \mod{math} & 90 & 1 ~~(3) & 5 \,~(46) \\
\mod{regexp} & 122 & 6 (60) & 5 \,~(33) \\ \mod{regexp} & 137 & 6 (60) & 5 \,~(33) \\
\mod{vector} & 228 & 1 (19) & 13 (163) \\\hline \mod{vector} & 228 & 1 (19) & 13 (163) \\\hline
{\bf Total} & 800 & 12 (201) & 27 (375) \\ {\bf Total} & 901 & 12 (204) & 27 (415) \\
\end{tabular} \end{tabular}
%% AVG %% AVG
% loc : 228.5 % loc : 228.5
% int : 33.5 % int : 33.5
% trn : 62.5 % trn : 62.5
%% elab frontends
%% mean 10, median 7
%db
%- query 35
%- connect 7
%
%fromat
%- fmt 16
%- pf 5
%
%curry
%- c 12
%- m 40
%
%math
%- 1 1 1 1
%- e 8
%
%rx
%- 1 1 1 1
%- m 16
%
%v
%- len 5
%- ref 10
%- set 10
%- map 19
%- map! 15
%- app 29
%- ls 14
%- im 8
%- fll 13
%- t 2
%- tr 2
%- d 2
%- dr 2

View File

@ -11,7 +11,7 @@
@; TODO this is all so boring right now, need to revise heavily @; TODO this is all so boring right now, need to revise heavily
@Figure-ref{fig:stats} gives a few statistics regarding our implementation. @Figure-ref{fig:stats} gives a few statistics regarding our implementation.
The purpose of this section is to explain why the numbers are low. The purpose of this section is to explain why the line counts are low.
@; Ode to macros, implementation a symphony @; Ode to macros, implementation a symphony
@figure["fig:stats" @figure["fig:stats"
@ -19,16 +19,16 @@ The purpose of this section is to explain why the numbers are low.
@exact|{\input{fig-stats}}| @exact|{\input{fig-stats}}|
] ]
In total, our six applications comprise 800 lines of code (LOC). In total, the code for our six applications described in @Secref{sec:usage}
comprise 901 lines of code (LOC).
Another 145 lines implement common functionality, putting the grand total Another 145 lines implement common functionality, putting the grand total
just under 1000 LOC. just over 1000 LOC.
Except for @exact|{\mod{db}}| and @exact|{\mod{regexp}}|, each of the Except for @exact|{\mod{db}}| and @exact|{\mod{regexp}}|, each of the
core modules defines a single function in @exact|{$\interp$}|. core modules defines a single interpretation function (in @exact|{$\interp$}|).
In @exact|{\mod{db}}| the two functions are the schema predicate and @tt{SQL} In @exact|{\mod{db}}|, the two functions are the schema predicate and @tt{SQL}
query parser (we omit the trivial interpreter for connections). query parser.
@; TODO no parentheses? In @exact|{\mod{regexp}}|, we have six group-parsing functions
On the other hand, @exact|{\mod{regexp}}| implements six group-parsing functions
to match the six string-like input types to match the six string-like input types
@;@note{Strings, Regex literals, Posix Regex literls, and byte-string variations of each.} @;@note{Strings, Regex literals, Posix Regex literls, and byte-string variations of each.}
accepted by Racket's @racket[regexp-match]. accepted by Racket's @racket[regexp-match].
@ -39,11 +39,13 @@ The smallest interpreter is the composition of Racket's @racket[number?] predica
The largest is the query parser (35 LOC), though the analyses for The largest is the query parser (35 LOC), though the analyses for
format strings and regular expressions are approximately the same size. format strings and regular expressions are approximately the same size.
The @exact{$\trans$} functions are aliases for standard library procedures. The elaboration functions are aliases for standard library procedures.
@; TODO much better to show off short code. But let's draft it first. Typically, these functions match a syntactic pattern, check for value errors,
In many cases we are able to re-use code between similar functions. and elaborate to a specialized Typed Racket procedure call.
For instance, the arithmetic operators @racket[+ - * /] are implemented by All these tasks can be expressed concisely; the average size of a function in
a single fold. @exact{$\elab$} is 10 lines and the median is 7 lines.
Much of the brevity is due to amortizing helper functions, so we include helpers'
line counts in the figure.
@; ----------------------------------------------------------------------------- @; -----------------------------------------------------------------------------