Commit 1785bfd4 authored by Thierry Geraud's avatar Thierry Geraud
Browse files

2007-02-15 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>

	Add some slides that present the SCOOP 2 paradigm.
	
	* doc/latex/paradigm/slides.tex: New.
	* doc/latex/paradigm/figures: New.
	* doc/latex/paradigm/figures/zoomin.fig: New.
	* doc/latex/paradigm/figures/vt2.fig: New.
	* doc/latex/paradigm/figures/harder0x.fig: New.
	* doc/latex/paradigm/figures/simplescoop1.fig: New.
	* doc/latex/paradigm/figures/concepts.fig: New.
	* doc/latex/paradigm/figures/alt.fig: New.
	* doc/latex/paradigm/figures/simplegp.fig: New.
	* doc/latex/paradigm/figures/evolution.fig: New.
	* doc/latex/paradigm/figures/simpledeco.fig: New.
	* doc/latex/paradigm/figures/simpleoo.fig: New.
	* doc/latex/paradigm/figures/glance.fig: New.
	* doc/latex/paradigm/figures/getset.fig: New.
	* doc/latex/paradigm/figures/simple0x.fig: New.
	* doc/latex/paradigm/figures/simpleoovt.fig: New.
	* doc/latex/paradigm/figures/corn.fig: New.
	* doc/latex/paradigm/figures/simplevt.fig: New.
	* doc/latex/paradigm/figures/selectors.fig: New.
	* doc/latex/paradigm/figures/scoop1a.fig: New.
	* doc/latex/paradigm/figures/harddeco.fig: New.
	* doc/latex/paradigm/figures/design.fig: New.
	* doc/latex/paradigm/figures/vt1.fig: New.
	* doc/latex/paradigm/wewant.tex: New.
	* doc/latex/paradigm/myhyperref.sty: New.
	* doc/latex/paradigm/atour.tex: New.
	* doc/latex/paradigm/numberslides.sty: New.
	* doc/latex/paradigm/newalg.sty: New.
	* doc/latex/paradigm/Makefile: New.
	* doc/latex/paradigm/sequel.tex: New.

	Update the tiny examples.

	* doc/tiny/local/scoop.hh
	(true_, false_): Turn from bexpr_ to static Boolean values.
	(stc_equip_namespace): Remove the namespace arg.
	(tag, delegatee_type): Rename as...
	(behavior, delegatee): ...these.
	(any): New in scooped namespaced.
	(top): Remove category so it can be "not found" by default.
	(concept_): Remove; just use "any" instead.
	(impl): Split some parts into...
	(get_impl, set_impl): ...these new classes.
	(stc_is, stc_is_not): New macros.
	(stc_Header, stc_End): New macros.
	* doc/tiny/a_la_scoop_1/main.cc: Add commentary.
	* doc/tiny/a_la_scoop_1/main.cc: Add commentary.
	* doc/tiny/a_la_scoop_2/main.cc: Update.
	* doc/tiny/a_la_scoop_2/desugar.cc: Update.
	* doc/tiny/a_la_scoop_1_plus/main.cc: Update.
	* doc/tiny/more_scoop_2/identity.hh: Update.
	* doc/tiny/more_scoop_2/main.cc: Update.
	* doc/tiny/local/scoop.hh: Update.
	* doc/tiny/local/undefs.hh: Update.

	Move some code into independent files.
	
	* doc/tiny/more_scoop_2/reverse_iterator.hh: New.
	* doc/tiny/more_scoop_2/concepts.hh: New.

	* stc/properties.hh (std::is_a): New helper.
	(stc_super, stc_pseudosuper, stc_typeof): Simplify the definitions
	of these macros, using their ``underscored'' version.
	(stc_typeof_in_namespace, stc_typeof_in_namespace_): New macro.
	* tests/properties.cc: Typos in comments.



git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@740 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent d795c277
2007-02-15 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add some slides that present the SCOOP 2 paradigm.
* doc/latex/paradigm/slides.tex: New.
* doc/latex/paradigm/figures: New.
* doc/latex/paradigm/figures/zoomin.fig: New.
* doc/latex/paradigm/figures/vt2.fig: New.
* doc/latex/paradigm/figures/harder0x.fig: New.
* doc/latex/paradigm/figures/simplescoop1.fig: New.
* doc/latex/paradigm/figures/concepts.fig: New.
* doc/latex/paradigm/figures/alt.fig: New.
* doc/latex/paradigm/figures/simplegp.fig: New.
* doc/latex/paradigm/figures/evolution.fig: New.
* doc/latex/paradigm/figures/simpledeco.fig: New.
* doc/latex/paradigm/figures/simpleoo.fig: New.
* doc/latex/paradigm/figures/glance.fig: New.
* doc/latex/paradigm/figures/getset.fig: New.
* doc/latex/paradigm/figures/simple0x.fig: New.
* doc/latex/paradigm/figures/simpleoovt.fig: New.
* doc/latex/paradigm/figures/corn.fig: New.
* doc/latex/paradigm/figures/simplevt.fig: New.
* doc/latex/paradigm/figures/selectors.fig: New.
* doc/latex/paradigm/figures/scoop1a.fig: New.
* doc/latex/paradigm/figures/harddeco.fig: New.
* doc/latex/paradigm/figures/design.fig: New.
* doc/latex/paradigm/figures/vt1.fig: New.
* doc/latex/paradigm/wewant.tex: New.
* doc/latex/paradigm/myhyperref.sty: New.
* doc/latex/paradigm/atour.tex: New.
* doc/latex/paradigm/numberslides.sty: New.
* doc/latex/paradigm/newalg.sty: New.
* doc/latex/paradigm/Makefile: New.
* doc/latex/paradigm/sequel.tex: New.
Update the tiny examples.
* doc/tiny/local/scoop.hh
(true_, false_): Turn from bexpr_ to static Boolean values.
(stc_equip_namespace): Remove the namespace arg.
(tag, delegatee_type): Rename as...
(behavior, delegatee): ...these.
(any): New in scooped namespaced.
(top): Remove category so it can be "not found" by default.
(concept_): Remove; just use "any" instead.
(impl): Split some parts into...
(get_impl, set_impl): ...these new classes.
(stc_is, stc_is_not): New macros.
(stc_Header, stc_End): New macros.
* doc/tiny/a_la_scoop_1/main.cc: Add commentary.
* doc/tiny/a_la_scoop_1/main.cc: Add commentary.
* doc/tiny/a_la_scoop_2/main.cc: Update.
* doc/tiny/a_la_scoop_2/desugar.cc: Update.
* doc/tiny/a_la_scoop_1_plus/main.cc: Update.
* doc/tiny/more_scoop_2/identity.hh: Update.
* doc/tiny/more_scoop_2/main.cc: Update.
* doc/tiny/local/scoop.hh: Update.
* doc/tiny/local/undefs.hh: Update.
Move some code into independent files.
* doc/tiny/more_scoop_2/reverse_iterator.hh: New.
* doc/tiny/more_scoop_2/concepts.hh: New.
2007-02-06 Roland Levillain <roland@lrde.epita.fr>
Fix mini-oln.
......
include share/make/share.mk
include share/make/tex.mk
TEXI2PDF_FLAGS += -I figures
include share/make/pdf-figs.mk
# The article must be named using the last name of the first author
# plus the extension, according to the ICIP Paper Submision Kit.
BASE = scoop
PDF = slides.pdf
.PHONY: final
final: $(BASE).pdf
$(BASE).pdf: slides.pdf
cp $< $@
CLEANFILES += $(PDF) $(HTML) $(BASE).pdf
all : pdf
pdf: $(PDF)
DOCUMENT_IMAGES = \
figures/design.fig \
figures/simple0x.fig \
figures/simplegp.fig \
figures/simplescoop1.fig \
figures/simpleoovt.fig \
figures/simplevt.fig \
figures/simpledeco.fig \
figures/harddeco.fig \
figures/vt1.fig \
figures/vt2.fig \
figures/corn.fig \
figures/glance.fig \
figures/zoomin.fig \
figures/alt.fig \
figures/evolution.fig \
figures/selectors.fig \
figures/harder0x.fig \
figures/simpleoo.fig
CLEANFILES += \
figures/*~ \
figures/*.eps
# Dependencies.
# figures/times.pdf: figures/times-16bit.dat figures/times-float.dat
# FIXME: Generate figures/h16b.pdf (and figures/h16b.ps) from
# figures/h16.dat.gz using grace/xmgrace.
#EXTRA_DIST = figures/h16.dat.gz figures/h16b.ps
DOCUMENT_IMAGES_PDF = $(call share_convert_to_pdf,$(DOCUMENT_IMAGES))
debug:
@echo "DOCUMENT_IMAGES_PDF = $(DOCUMENT_IMAGES_PDF)"
CLEANFILES += $(DOCUMENT_IMAGES_PDF) figures/*.{pdftex,pdftex_t}
slides.pdf: $(DOCUMENT_IMAGES_PDF)
view pdfview: pdf
xpdf $(PDF)
%============================================================
\section{A Tour of Several Paradigms}
%........................................................................
\begin{frame}
\frametitle{Intents}
FIXME: context + get the best of both OOP and GP.
\end{frame}
%------------------------------------------------------------
\subsection{Classical OOP}
%........................................................................
\begin{frame}
\frametitle{Classical Object-Oriented Programming}
\begin{itemize}
%
\item we design class hierarchies
\begin{itemize}
\item class inheritance translates the \textit{is-a} relationship
\item a concrete class usually derives from an abstract class
\end{itemize}
\smallskip
%
\item an abstract class
\begin{itemize}
\item maps an \textit{abstraction}
\item describes an \textit{interface}
\end{itemize}
\smallskip
%
\item a concrete class
\begin{itemize}
\item is a realization of its immediate abstraction
\item implements its interface and those inherited
\end{itemize}
%
\end{itemize}
\end{frame}
%........................................................................
\begin{frame}
\frametitle{Simple Class Hierarchy + Algorithm}
\begin{multicols}{2}
%
\begin{center}
\includegraphics[scale=.7]{simpleoo}
\end{center}
%
\columnbreak
%
{\scriptsize
\begin{algorithm}{count}{it : Iterator}
counter : \tunsigned \= 0 \\
it.init() \\
\begin{WHILE}{it.is\_valid()}
\tab counter \= counter + 1 \\
\tab it.next()
\end{WHILE} \\
\RETURN counter
\end{algorithm}
}
%
\end{multicols}
\end{frame}
%........................................................................
\begin{frame}[fragile]
\frametitle{Translation into C++ OOP}
\begin{multicols}{2}
%
\begin{lstlisting}[escapechar=@]
class @\blueIterator@
{
public:
virtual void init() = 0;
virtual void next() = 0;
virtual bool is_valid() const = 0;
virtual ~Iterator() {}
};
template <typename T>
class @\color{mediumblue}{array\_iterator}@ : public @\blueIterator@
{
public:
virtual void init() { ... }
virtual void next() { ... }
virtual bool is_valid() const { ... }
...
};
\end{lstlisting}
%
\columnbreak
%
\begin{lstlisting}[escapechar=@]
unsigned count(@\blueIterator@& it)
{
unsigned counter = 0;
it.init();
while (it.is_valid()) {
counter = counter + 1;
it.next();
}
return counter;
}
\end{lstlisting}
%
\end{multicols}
\end{frame}
%........................................................................
\begin{frame}
\frametitle{Conclusion About C++ OOP}
\begin{block}{C++ OOP in a Nutshell}
\begin{itemize}
\item[\bplus] Abstract classes \\
~~~ {\tiny{$\leadsto$ ~ abstractions clearly appear in programs and allow for overloading of algorithms}}
\item[\bplus] The OO Polymorphism \\
~~~ {\tiny{$\leadsto$ ~ method dispatch is a very convenient and straightforward tool}}
\item[\bminus] Poor efficiency \\
~~~ {\tiny{$\leadsto$ ~ ``virtual'' methods are penalizing when involved in intensive computation}}
\item[\bminus] No support for covariance and virtual types \\
~~~ {\tiny{$\leadsto$ ~ see later}}
\end{itemize}
\end{block}
\end{frame}
%------------------------------------------------------------
\subsection{Classical Generic Programming (GP)}
%........................................................................
\begin{frame}[fragile]
\frametitle{Documentation and Implementation}
\begin{multicols}{2}
%
\begin{center}
\includegraphics[scale=.7]{simplegp}
\end{center}
%
\columnbreak
%
{\scriptsize
\begin{itemize}
\item in code:
\begin{itemize}
\item no actual abstract classes
\item only implementation classes
\end{itemize}
\smallskip
\item limited OOP:
\begin{itemize}
\item abstractions only appear in documentation
\item inheritance is just a factoring tool
\end{itemize}
\end{itemize}
}
%
\end{multicols}
\end{frame}
%........................................................................
\begin{frame}[fragile]
\frametitle{Translation into C++ Generic Programming}
\begin{multicols}{2}
%
\begin{lstlisting}[escapechar=@]
/* documentation:
*
* Iterator
* {
* void init();
* void next();
* bool is_valid() const;
* };
*/
template <typename T>
class array_iterator
{
public:
void init() { ... }
void next() { ... }
bool is_valid() const { ... }
...
};
\end{lstlisting}
%
\columnbreak
%
\begin{lstlisting}[escapechar=@]
template <typename @\greenI@>
unsigned count(@\greenI@& it)
{
unsigned counter = 0;
it.init();
while (it.is_valid()) {
counter = counter + 1;
it.next();
}
return counter;
}
\end{lstlisting}
%
\end{multicols}
\end{frame}
%........................................................................
\begin{frame}
\frametitle{Conclusion About C++ GP}
\begin{block}{C++ GP in a Nutshell}
\begin{itemize}
\item[\bplus] Efficiency \\
~~~ {\tiny{$\leadsto$ ~ algorithms do not pay the cost of abstractions}}
\item[\bminus] Implicit abstractions \\
~~~ {\tiny{$\leadsto$ ~ abstractions are not mapped into code so program expressiveness is limited}}
\item[\bminus] No support for constrained genericity \\
~~~ {\tiny{$\leadsto$ ~ being able to overload generic algorithms is not trivial}}
\item[\bminus] Factoring code using inheritance is usually hard \\
~~~ {\tiny{$\leadsto$ ~ postponing definitions to sub-classes and
overriding do not work well without the 'virtual'
keyword}}
\end{itemize}
\end{block}
\end{frame}
%------------------------------------------------------------
\subsection{Generic Programming Evolution with C++0x}
%........................................................................
\begin{frame}[fragile]
\frametitle{Concepts and Implementation}
\begin{multicols}{2}
%
\begin{center}
\includegraphics[scale=.7]{simple0x}
\end{center}
%
\columnbreak
%
{\scriptsize
\begin{itemize}
\item in code:
\begin{itemize}
\item concepts + implementation classes
\item no need of setting explicit relations between them
% concepts and classes
\end{itemize}
\smallskip
\item consequences:
\begin{itemize}
\item stronger type-checking than in GP
\item great decoupling between concepts and classes
\item inheritance remains a factoring tool
\end{itemize}
\end{itemize}
}
%
\end{multicols}
\end{frame}
%........................................................................
\begin{frame}[fragile]
\frametitle{Translation into C++0x}
\begin{multicols}{2}
%
\begin{lstlisting}[escapechar=@]
auto concept @\blueIterator@ <typename @\greenI@>
{
void I::init();
void I::next();
bool I::is_valid() const;
};
template <typename T>
class array_iterator
{
public:
void init() { ... }
void next() { ... }
bool is_valid() const { ... }
...
};
\end{lstlisting}
%
\columnbreak
%
\begin{lstlisting}[escapechar=@]
template <typename @\greenI@>
where @\blueIterator@<@\greenI@>
unsigned count(@\greenI@& it)
{
unsigned counter = 0;
it.init();
while (it.is_valid()) {
counter = counter + 1;
it.next();
}
return counter;
}
\end{lstlisting}
%
\end{multicols}
\end{frame}
%........................................................................
\begin{frame}
\frametitle{Conclusion About C++0x}
\begin{block}{C++0x in a Nutshell}
\begin{itemize}
\item[\bplus] Efficiency, expressiveness, and type safety \\
~~~ {\tiny{$\leadsto$ ~ most drawbacks of OOP and GPP disappear!}}
\item[\bminus] Not really OO \\
~~~ {\tiny{$\leadsto$ ~ like with GP we cannot take advantage of many designs related to ``classical'' inheritance}}
\item[\bminus] Not yet part of the C++ standard \\
~~~ {\tiny{$\leadsto$ ~ so is there something to do now but waiting?}}
\end{itemize}
\end{block}
\end{frame}
%------------------------------------------------------------
\subsection{Mixing OOP and GP}
%........................................................................
\begin{frame}
\frametitle{Combining Inheritance and Genericity}
\begin{multicols}{2}
%
\begin{center}
\includegraphics[scale=.7]{simplescoop1}
\end{center}
%
\columnbreak
%
\vspace*{.2\textheight}
\begin{itemize}
\item close to OOP
\begin{itemize}
\item we have class hierarchies
\item but method lookup is solved at compile-time!
\end{itemize}
\item close to GP
\begin{itemize}
\item algorithms are fast
\item but their signatures are as strong as in C++0x!
\end{itemize}
\end{itemize}
%
\end{multicols}
\end{frame}
%........................................................................
\begin{frame}[fragile]
\frametitle{Translation into \scoop 1}
\begin{multicols}{2}
%
\begin{lstlisting}[escapechar=@]
template <typename @\greenI@>
class @\blueIterator@ : public @\color{darkgray}{Any}@<I>
{
public:
void init() { this->@\color{darkgray}{exact()}@.impl_init(); }
void next() { /* likewise */ }
bool is_valid() const { /* likewise */ }
};
template <typename T>
class @\blueArrayIterator@ : public @\blueIterator@< array_iterator<T> >
{
public:
void impl_init() { ... }
void impl_next() { ... }
bool impl_is_valid() const { ... }
...
};
\end{lstlisting}
%
\columnbreak
%
\begin{lstlisting}[escapechar=@]
template <typename @\greenI@>
unsigned count(@\blueIterator@<@\greenI@>& it)
{
unsigned counter = 0;
it.init();
while (it.is_valid()) {
counter = counter + 1;
it.next();
}
return counter;
}
\end{lstlisting}
%
\end{multicols}
\end{frame}
%........................................................................
\begin{frame}
\frametitle{Conclusion About \scoop~1}
\begin{block}{\scoop~1 in a Nutshell}
\begin{itemize}
\item[\bplus] Efficiency, expressiveness, and type safety \\
~~~ {\tiny{$\leadsto$ ~ most drawbacks of OOP and GPP disappear!}}
\item[\bplus] Really OO \\
~~~ {\tiny{$\leadsto$ ~ a mix between OOP and GP}}
\item[\bminus] Not so trivial C++ \\
~~~ {\tiny{$\leadsto$ ~ yet not so difficult neither!}}
\item[\bminus] Explicit inheritance \\
~~~ {\tiny{$\leadsto$ ~ just like in OOP...}}
\end{itemize}
\end{block}
\end{frame}
%------------------------------------------------------------
\subsection{Recap + Comparison}
%........................................................................
\begin{frame}[fragile]
\frametitle{Abstraction and Algorithm}
\hspace*{-3mm}
\begin{tabular}{|c|p{.45\textwidth}|p{.4\textwidth}|}
%
\hline
%
{\small OOP}
&
\begin{minipage}{.9\textwidth}
\begin{lstlisting}[escapechar=@]
class @\blueIterator@
{ ... };