%\documentclass[a4paper,titlepage]{slides}
\documentclass[a4paper,landscape,titlepage]{slides}

\usepackage[latin1]{inputenc}
%\usepackage[T1]{fontenc}
\usepackage[german]{babel}
%\usepackage{portland}
\usepackage{lscape}
%\usepackage[dvips]{color}
\usepackage{array}
\usepackage{dcolumn}
\usepackage{epsfig}
\input{epsf}
\usepackage{fancyvrb}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[normalem]{ulem}

\newcommand{\slidetitle}[1]{\vspace{4ex}{\large\centerline{#1}}\vspace{1ex}}
%\newcommand{\epsline}[1]{\vspace{1ex}\centerline{\epsffile{#1.eps}}}
\newcommand{\epsline}[2]{\vspace{1ex}\centerline{\epsfig{file=#1.eps}}}
%\wepsbox{file,width}
\newcommand{\wepsbox}[2]{\includegraphics[width=#2]{#1.eps}}
%\wepsline{file,width}
\newcommand{\wepsline}[2]{\vspace{1ex}\centerline{\epsfig{file=#1.eps,width=#2}}}
\newcommand{\white}[1]{\textcolor{white}{#1}}
\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\rep}[1]{{\Large$\downarrow$}\makebox[0pt][l]{#1}}
\newcommand{\comment}[1]{}
%\pass{arrow}{components}
\newcommand{\pass}[2]{\(\left.\mbox{\fbox{\begin{tabular}{l}#2\end{tabular}}}\right#1\)}
\newenvironment{portrait}{}{}
\newenvironment{myitemize}{\begin{list}{$\bullet$}{\setlength{\itemsep}{0ex}\setlength{\topsep}{0ex}}}{\end{list}}

\newcolumntype{.}{D{.}{.}{2}}

\setlength\paperwidth{32cm} %16:9 aspect ratio
\setlength\paperheight{18cm}
\setlength\textheight{\paperheight}
\addtolength\textheight{-1cm}
  \setlength\topmargin{\paperheight}
  \addtolength\topmargin{-2in}
  \addtolength\topmargin{-\headheight}
  \addtolength\topmargin{-\headsep}
  \addtolength\topmargin{-\textheight}
  \addtolength\topmargin{-\footskip}     % this might be wrong!
  \addtolength\topmargin{-.5\topmargin}
  \addtolength\topmargin{-1.6ex}
%\addtolength\evensidemargin{-2cm}
\addtolength\oddsidemargin{-1cm}
\addtolength\textwidth{4cm}

%\setlength\textheight{\paperheight}
%\addtolength\textheight{-1cm}
%  \setlength\topmargin{\paperheight}
%  \addtolength\topmargin{-2in}
%  \addtolength\topmargin{-\headheight}
%  \addtolength\topmargin{-\headsep}
%  \addtolength\topmargin{-\textheight}
%  \addtolength\topmargin{-\footskip}     % this might be wrong!
%  \addtolength\topmargin{-.5\topmargin}
%%\addtolength\evensidemargin{-2cm}
%%\addtolength\oddsidemargin{-2cm}
%%\addtolength\textwidth{4cm}

\title{Spezielle Features von\\Forth und Postscript}
\author{
  M. Anton Ertl\\TU Wien
}
\date{}
\begin{document}
%\begin{landscape}
\maketitle
%\end{landscape}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \slidetitle{Debugging}

  \begin{itemize}
  \item Stepping Debugger\\
    \code{dbg \emph{word}}\\
    Funktioniert nur mit \code{gforth-itc}
  \item Tracer (\code{printf} debugging)\\
    \verb|~~|
  \item Backtrace
  \end{itemize}
\end{slide}
    

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \slidetitle{IDE features}

  \begin{myitemize}
  \item \code{locate \emph{word}}\\
    \code{n b g l}\\
    \code{edit \emph{word}}
  \item \code{help \emph{word}}\\
    \code{n b g l}\\
  \item \code{where \emph{word}}\\
    \code{( u ) ww}\\
    \code{nw bw}
  \item nach einem Backtrace\\
    \code{( u ) tt}
    \code{nt bt}
  \item Decompiler\\
    \code{see \emph{word}}
  \end{myitemize}
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Interpretation, Compilation, und Ausführung}

\begin{verbatim}
\ Compilation
: hello ( -- )
  ." hello, world" ;

\ Interpretation
.( hello, world)

\ Interpretation und Ausführung
hello
\end{verbatim}

Interpretation geht

\begin{itemize}
\item in Forth, Postscript, Lisp, Prolog, ...

\item nicht in Fortran, C, C++, Java, ...
\end{itemize}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Keine Trennung zwischen Compilationszeit und Laufzeit}

... durch die Sprache, nur im Kopf des Programmierers.\\
Kein Executable, bei vielen Systemen ein Image.

\begin{itemize}

\item Initialisierung von Datenstrukturen

\item Macros: Ausführung während der Compilation

\item Run-time code generation: Optimierung oder Vereinfachung

\end{itemize}

C++ hat eigene Programmiersprache für Macros (Templates)
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Initialisierung}

\begin{verbatim}
/* C */ int a[] = {235,1857};

/* C, alternative */
int a[2];  a[0]=foo(2); a[1]=bar(3);

\ Forth
create a 2 foo , 3 bar ,
\end{verbatim}

\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Macros}
\begin{verbatim}
: endif POSTPONE then ; immediate
: foo ... if ... endif ... ;

: (map) ( a n -- a a')   cells over + swap ;
: map<   postpone (map)  postpone ?do postpone i postpone @ ; immediate
: >map   1 cells postpone literal  postpone +loop ; immediate
: step  0  array 1000 map< + >map drop ;
\end{verbatim}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Codeerzeugung: \texttt{LITERAL COMPILE,}}
\begin{verbatim}
: foo [ 5 cells ] literal ;
: ]cells ] cells POSTPONE literal ;
: foo [ 5 ]cells ;

: twice ( xt -- )
  dup compile, compile, ;
: 2+ [ ' 1+ twice ] ;
: 4* [ ' 2* twice ] ;
\end{verbatim}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Codeerzeugung: Gray}
\begin{verbatim}
: compile-test \ set -- )
 postpone literal
 test-vector @ compile, ;

: generate-alternative1 \ -- )
 operand1 get-first compile-test
 postpone if
 operand1 generate
 postpone else
 operand2 generate
 postpone endif ;
\end{verbatim}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Quines}

Programme, die sich selbst drucken, möglichst kurz.

\begin{verbatim}
                 source type
\end{verbatim}

Varianten, wenn man verschiedene Features von Forth nicht benutzt:\\
\texttt{http://www.complang.tuwien.ac.at/forth/quines.html}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Namensbindung}

\begin{itemize}

\item Was passiert bei Wiederdefinition eines Namens?

\item Algol (C, Java, ...): Compilationsfehler

\item Lisp, Postscript: Dynamic Name Binding\\
      Neue Definition ersetzt alte

\item Forth: Static name binding\\
      Alte Definition existiert weiter\\
      Alte Verwendungen beziehen sich auf alte Definition\\
      Neue Verwendungen beziehen sich auf neue Definition

\end{itemize}

\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Namensbindung: Kollision}

\begin{itemize}

\item Häufiger Fall: Programm definiert Name $x$, library wird um
$x$ erweitert

\item Algol: Fehler zur Compilezeit

\item Lisp: Fehler zur Laufzeit (Falsche Funktion wird ausgeführt)

\item Forth: Warnung zur Compilezeit, Programm funktioniert

\end{itemize}

\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Namensbindung: Probleme und Lösungen}

\begin{itemize}

\item Kollisionen: Konventionen (C), Namespaces (C++)
\begin{verbatim}
#define _POSIX_C_SOURCE 199506L
#include <unistd.h>
\end{verbatim}

\item Kollisionen: Dictionaries (Postscript)

\item Vorwärtsdeklarationen: \code{defer} (Forth)

\end{itemize}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Lokale Kontrollstrukturen}
\begin{verbatim}
... IF ... THEN
... IF ... ELSE ... THEN
BEGIN ... WHILE ... REPEAT
BEGIN ... UNTIL
CASE ... OF ... ENDOF ... OF ... ENDOF ... ENDCASE
?DO ... LOOP
\end{verbatim}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Kontrollstrukturen: Fundament}

\centerline{
\begin{tabular}{r|r|r}
		  & Vorwärts     & Rückwärts \\\hline
Unbedingter Sprung& \code{AHEAD ( -- orig )} & \code{AGAIN ( dest -- )}\\
Bedingter Sprung  & \code{IF ( -- orig )}    & \code{UNTIL ( dest -- )}\\
Sprungziel        & \code{THEN ( orig -- )}  & \code{BEGIN ( -- dest )}\\
\end{tabular}}
\begin{verbatim}
            : foo 
              BEGIN ( C: dest )
                ... IF ( C: dest orig )
                  ... THEN ( C: dest )
                ... UNTIL ( C: ) ;
\end{verbatim}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Kontrollstrukturen: Erweiterungen}
\begin{verbatim}
: ELSE ( compilation: orig1 -- orig2 ; run-time: -- ) \ core
    POSTPONE ahead
    1 cs-roll
    POSTPONE then ; immediate restrict

: WHILE ( compilation: dest -- orig dest ; run-time: f -- ) \ core
    POSTPONE if
    1 cs-roll ; immediate restrict

: REPEAT ( compilation: orig dest -- ; run-time: -- ) \ core
    POSTPONE again
    POSTPONE then ; immediate restrict
\end{verbatim}
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Kontrollstrukturen: Erweiterungen}
\begin{verbatim}
: foo
  ... if ( C: orig1 )
    ...
  else ( C: orig2 )
    ... begin ( C: orig2 dest )
      ... while ( C: orig2 orig3 dest )
      ... repeat ( C: orig2 )
  then ;
\end{verbatim}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Kontrollstrukturen: unkonventionell}
\begin{verbatim}
: foo
  begin ( C: dest )
    ... while ( C: orig1 dest )
    ... while ( C: orig1 orig2 dest )
    ... repeat ( C: orig1 )
  ... else ( C: orig3 )
    ... then ;
\end{verbatim}

\begin{itemize}

\item Mit \code{cs-roll} beliebige Kontrollstrukturen

\item Lesbarkeit?

\end{itemize}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Typen}

\centerline{Wer weiß den Typ eines Datums?}
\vspace{1ex}
\centerline{
\begin{tabular}{rr|c|c}
  &&\multicolumn{2}{c}{Laufzeitsystem}\\
  &&nein&ja\\\hline
  \raisebox{-1ex}{Compiler}&nein&Forth&Postscript, Python, Lisp\\
  &ja&C, Pascal&C++, Java\\
\end{tabular}}

\begin{itemize}
\item Typwissen des Programmierers (z.B. sortiertes Array)

\item Uniformität (Lisp) vs. Differenzierung (Java)
\end{itemize}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Typen: Überprüfung}

\begin{verbatim}
                             'a' * 5
\end{verbatim}

\begin{myitemize}

\item Wie geht man in Forth damit um?  Testen!

\item Mit etwas Erfahrung findet man Typfehler schnell.

\item Intensiveres Testen $\Rightarrow$ man findet auch andere Fehler.

\end{myitemize}
\begin{quote}
As programmers learned C with Classes or C++, they lost the ability to
quickly find the ``silly errors'' that creep into C programs through
the lack of checking. Further, they failed to take the precautions
against such silly errors that good C programmers take as a matter of
course. After all, ``such errors don't happen in C with Classes.''
Thus, as the frequency of run-time errors caused by uncaught argument
type errors goes down, their seriousness and the time needed to find
them goes up.  \emph{Bjarne Stroustroup}
\end{quote}

\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Typen: Overloading}
\begin{verbatim}
int n;      n*3           n @ 3 *
float r;    r*3.0         r f@ 3.0e f*
int n;      n<3           n @ 3 <
unsigned u; u<3           u @ 3 u<
\end{verbatim}
\end{slide}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Typen: Vorteile und Nachteile von Forth}

\begin{itemize}
\item[$+$] Mehr Uniformität: Bessere Wiederverwendbarkeit

\item[$+$] Erweiterungen möglich, die Typsystemerweiterung brauchen (OOP)

\item[$+$] Weniger Komplexität z.B. bei Containern

\item[$-$] Kein Typwissen für Garbage Collection, Marshalling etc.

\item[$-$] Bei weitgreifenden Änderungen wäre statische Überprüfung praktisch
\end{itemize}
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Speicherverwaltung}

\begin{itemize}
\item Statische Allokation\\
  \code{create allot}

\item Dynamische Allokation mit expliziter Deallokation\\
  \code{allocate free}

\item Dynamische Allokation mit automatischer Deallokation

\end{itemize}
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Speicherverwaltung und APIs}

\begin{verbatim}
read-line ( c-addr u1 wfileid -- u2 flag wior )
\end{verbatim}

Reads a line from wfileid into the buffer at c-addr u1.  Gforth
supports all three common line terminators: LF, CR and CRLF. A
non-zero wior indicates an error.  A false flag indicates that
'read-line' has been invoked at the end of the file.  u2 indicates
the line length (without terminator): u2$<$u1 indicates that the line
is u2 chars long; u2=u1 indicates that the line is at least u1 chars
long, the u1 chars of the buffer have been filled with chars from the
line, and the next slice of the line with be read with the next
'read-line'.  If the line is u1 chars long, the first 'read-line'
returns u2=u1 and the next read-line returns u2=0.

\begin{verbatim}
slurp-fid ( fid -- c-addr u )
\end{verbatim}
  
c-addr u is the content of the file fid
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Objekt-Orientierte Erweiterung: Features}
\begin{itemize}
\item Dynamic Dispatch (Virtuelle Funktionen)
\item Instance Variables
\item Einfachvererbung
\item Statische Bindung (C++: \code{A::m})
\item Basisklasse \code{object}
\item \code{new}
\end{itemize}
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Objekt-Orientierte Erweiterung: Verwendung (1)}
\begin{verbatim}
object class
  cell var text
  cell var len
  cell var x
  cell var y
  method init
  method draw
end-class button

:noname ( o -- ) >r
 r@ x @ r@ y @ at-xy  r@ text @ r> len @ type ;
 button defines draw
:noname ( addr u o -- ) >r
 0 r@ x ! 0 r@ y ! r@ len ! r> text ! ;
 button defines init
\end{verbatim}
\end{slide}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Objekt-Orientierte Erweiterung: Verwendung (2)}
\begin{verbatim}
button class
end-class bold-button

: bold   27 emit ." [1m" ;
: normal 27 emit ." [0m" ;

:noname bold [ button :: draw ] normal ; bold-button defines draw

button new Constant foo
s" thin foo" foo init
page
foo draw
bold-button new Constant bar
s" fat bar" bar init
1 bar y !
bar draw
\end{verbatim}
\end{slide}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Objekt-Orientierte Erweiterung: Source Code}

\begin{verbatim}
: method ( m v -- m' v ) Create  over , swap cell+ swap
  DOES> ( ... o -- ... ) @ over @ + @ execute ;
: var ( m v size -- m v' ) Create  over , +
  DOES> ( o -- addr ) @ + ;
: class ( class -- class methods vars ) dup 2@ ;
: end-class  ( class methods vars -- )
  Create  here >r , dup , 2 cells ?DO ['] noop , 1 cells +LOOP
  cell+ dup cell+ r> rot @ 2 cells /string move ;
: defines ( xt class -- ) ' >body @ + ! ;
: new ( class -- o )  here over @ allot swap over ! ;
: :: ( class "name" -- ) ' >body @ + @ compile, ;
Create object  1 cells , 2 cells ,
\end{verbatim}
Erklärung: \code{https://bernd-paysan.de/mini-oof.html}
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Objekt-Orientierte Erweiterung: Erklärung}
  \begin{minipage}[b]{12cm}
\begin{verbatim}
object class
  cell var text
  cell var len
  cell var x
  cell var y
  method init
  method draw
end-class button
button new Constant foo
  
button class
end-class bold-button
bold-button new Constant bar
\end{verbatim}
  \end{minipage}%
  \wepsbox{mini-oof}{14cm}\hfil
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \slidetitle{Forth-Philosophie}

  \begin{itemize}
  \item eigentlich Chuck Moore's Philosophie
  \item \emph{Keep it simple!}
  \item \emph{Do not speculate!}\\
    keine Verallgemeinerung\\
    keine Wiederverwendung\\
    Erweiterungen/Hooks erst, wenn nötig
  \item \emph{Do it yourself!}\\
    keine Libraries
  \item \emph{Do not bury your tools!}
  \end{itemize}
\end{slide}
    

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \slidetitle{Implementierung}
  \wepsbox{new-direct}{13cm}
  \begin{myitemize}
  \item \code{see \emph{word}}
  \item \code{simple-see \emph{word}}
  \item \code{see-code \emph{word}}
  \end{myitemize}
\end{slide}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Postscript}

\begin{itemize}
\item Syntax
  \begin{myitemize}
      \item \verb|( ) < > [ ] { } / %| sind Delimiter
      \item \verb|<< >>| sind Lexeme
      \item \verb|( )| umgeben Strings; Klammern ausbalancieren, oder \verb|\) \(|
  \end{myitemize}
\item Typen
  \begin{myitemize}
  \item Typen zur Laufzeit bekannt
  \item Operatoren auf verschiedene Typen anwendbar
  \item Typprüfung zur Laufzeit
  \item Begrenzt nicht-statische Stacktiefe beim Aufbau von Arrays
  \end{myitemize}
\end{itemize}
\end{slide}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Postscript: Typen}
\centerline{
\begin{tabular}{c|>{\tt}c}
Typ		&{\rm Beispiel-Literal}             \\\hline
integer		&1				    \\
real		&1.0				    \\
boolean		&true				    \\
name		&/name				    \\
mark		&[				    \\
null		&null				    \\
operator	&/add load			    \\
fontID		&				    \\
save		&				    \\\hline
array		&[1 2]				    \\
string		&(string)			    \\
dictionary	&<< index1 wert1 index2 wert2 ... >>\\
File		&                                   \\
\end{tabular}}
\begin{itemize}
\item Referenz-Semantik (shallow copying)
\end{itemize}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Literale und ausführbare Objekte}
\hspace{1ex}
\centerline{
\begin{tabular}{c|>{\tt}c|>{\tt}c}
Typ&{\rm Beispiel-Executable}&{\rm Beispiel-Literal}\\\hline
Name		&name			&/name\\
Operator	&//add			&/add load\\
Array		&\{dup mul\}	&[ 1 2 ]\\
\end{tabular}
}
\begin{myitemize}
\item Attribut von Objekten zusätzlich zum Typ

\item Ausführung: Literale Objekte werden auf den Stack gelegt.

\item Ausführung: bei ausführbaren Objekte typabhängiger Effekt

\item Unterschied zwischen direkter und indirekter Ausführung

\item Bei Betrachtung als Daten (z.B. Vergleich) sind Attribute egal.

\item Weiteres Attribut: Access

\end{myitemize}

\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Prozeduren und Arrays}

\begin{itemize}
\item Prozeduren sind ausführbare Arrays

\item Syntaktisch unterschiedlich

\item \verb|{ 1 2 add }|

\item \verb|[ 1 2 add ]|

\item Elemente einer Prozedur werden \emph{direkt} ausgeführt\\
      Prozeduren werden auf den Stack gelegt: \verb|{ { 1 2 add } }|
\end{itemize}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Kontrollstrukturen}

Operatoren mit Prozedur als Parameter
\begin{verbatim}
a 0 lt { 1 == } if
a 0 lt { 1 == } { 2 == } ifelse
5 1 10 { == } for
5 2 10 { == } for
[ 1 7 3 ] { == } forall
<< /c 1 /a 2 /b 3 >> { == == } forall
4 { (abc) = } repeat
5 { dup 0 lt { exit } if dup = 1 sub } loop pop
\end{verbatim}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Namen und Dictionaries}

\begin{itemize}
\item \verb|/squared {dup mul} def|

\item Über \code{squared} wird Prozedur indirekt ausgeführt\\
      $\Rightarrow$ die Elemente werden (direkt) ausgeführt
      

\item Definition im aktuellen Dictionary
\item Dictionary entspricht wordlist in Forth
\item Dictionary stack entspricht search order
\end{itemize}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Namensbindung}
\begin{itemize}
\item Namensbindung zur Laufzeit\\
      \verb|/foo {bar} def  /bar {1} def|

\item Verwendung als lokale Variablen\\
      \verb|/foo { << /a rot >> begin ... a ... end } def|

\item Dynamisches Scoping\\
      \verb|<< /a 5 >> begin { a } end exec | liefert Fehler\\
      Viele Sprachen unterstützen statisches Scoping

\item Ähnlich Environment-Variables in Unix
\end{itemize}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Vergleich}
\begin{verbatim}
/v [ 0 1 999 {} for ] def
/step {0 v { add } forall} def
100000 {step pop} repeat


: (map) ( a n - a a')   cells over + swap ;
: map[   postpone (map)  postpone ?do postpone I postpone @ ; immediate
: ]map   1 cells postpone literal  postpone +loop ; immediate

create array 1000 cells allot   
: init  1000 0 DO I  array I cells + !  LOOP ;
init
: step  0  array 1000 map[ + ]map drop ;
: bench  100000 0 DO step LOOP ;
bench
\end{verbatim}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Document Structuring Conventions}

\begin{verbatim}
%!PS-Adobe-2.0
%%Creator: dvips(k) 5.95a Copyright 2005 Radical Eye Software
%%Title: slides.dvi
%%Pages: 4 0
%%PageOrder: Ascend
%%Orientation: Landscape
%%BoundingBox: 0 0 595 842
%%DocumentFonts: LCMSS8 CMTT8 CMSY8 CMMI8 LCMSSI8 LCMSSB8 CMSY10
%%DocumentPaperSizes: a4
%%EndComments
... ProcSets ...
... Fonts ...
... Setup ...
%%Page: (0,1,2,3,4,5,6,7) 1
... Postscript Code ...
%%Page: (8,9,10,11,12,13,14,15) 2
... unabhängig von anderen Seiten
%%Trailer
...
%%EOF
\end{verbatim}
\end{slide}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
\slidetitle{Encapsulated Postscript}

\begin{itemize}
\item Üblicherweise für Graphiken
\item Wird in andere Dokumente eingebaut
\end{itemize}

\begin{verbatim}
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 90 651 387 709
... Prolog ...
%%Page: 1 1
... Nur eine Seite, meist ohne showpage ...
\end{verbatim}
\end{slide}
\end{document}
