\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#289: Revision of [lrepeat] Argument Order}
\date{October 26, 2006}
\author{Peter Spjuth, }
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#289}&\textbf{Revision of [lrepeat] Argument Order}\\\hline
Author&

Peter Spjuth \tipmail{peter.spjuth}{space.se}
\par
\tipmail{dgp}{users.sf.net}
\\
Created&Thursday, \(\text{26}^{\text{th}}\) October 2006\\
Type&Project\\
Tcl Version&\(8.5\)\\
State&Rejected\\
Vote&Done\\
Version&\tipversion$Revision: 1.5 $\\
Keywords&Tcl\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

This TIP proposes to alter the argument order of \textbf{lrepeat} to be similar to \textbf{string repeat}.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

In \cite{tip136}, lrepeat is defined as:

\begin{quote}
\textbf{lrepeat} \textit{number element1} ?\textit{element2}? ?\textit{element3}? ...
\end{quote}

whereas the old string repeat command is:

\begin{quote}
\textbf{string repeat} \textit{string number}
\end{quote}

This difference between similar commands is bound to cause confusion. Consistency is good.

\section{Specification}

Change lrepeat's argument order to:

\begin{quote}
\textbf{lrepeat} \textit{element1} ?\textit{element2}? ?\textit{element3}? ... \textbf{number}
\end{quote}

\section{Examples:}
\begingroup\small\begin{verbatim}
 lrepeat 0 100                - returns list of 100 zeros
 lrepeat [lrepeat 0 100] 100  - returns 100x100 matrix (list of lists) of zeros
 lrepeat a b c 3              - returns nine-element list {a b c a b c a b c}
 lrepeat a b c 1              - identical to [list a b c]
\end{verbatim}
\endgroup

\section{Discussion:}

DGP: The main feature that appears to get lost in this change is the ability to redirect aliases or subcommands of ensembles to \textbf{lrepeat} calls with the number of repetitions already filled in.

PS: On the other hand, you get the ability to redirect aliases or subcommands of ensembles to \textbf{lrepeat} calls with the elements already filled in.

DGP: I skimmed the old TIP 136 messages in the TCLCORE archives. One thing to note is that the existing \textbf{lrepeat} syntax in 8.5a5 was chosen in part to be consistent with the existing \textbf{struct::list repeat} syntax in the struct::list package.

DGP: I think it's fair to say that given a complete ``do-over'' more of us would opt to change \textbf{string repeat} to agree with \textbf{lrepeat} and \textbf{struct::list repeat} than the other way around.

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\begin{thebibliography}{TIP \#1}
\addcontentsline{toc}{section}{References}
\bibitem[TIP \#136]{tip136}
Simon Geard,
\emph{Large List Initialisation},
on-line at \url{http://purl.org/tcl/tip/136.html}
\end{thebibliography}
\end{document}
