[Tex/LaTex] Pass a command as argument for another command

macros

Second question today: is there a way to pass a command as an argument of another method?

\newcommand\foo[1]{Foo does: `#1'}
\newcommand\bar[2]{Bar does: `#1{#2}'}

...

\bar{\foo}{xxx}

The output I want should be:

Bar does: `Foo does: `xxx''

Also, can someone explain to me what \expandafter does?

EDIT:

Sorry, for the question, after re-reading my code a few times, I noticed the origin of the mistake: the #1 in \bar was actually written \#1 instead. Nonetheless, thank you all for the quick answers.

Best Answer

The following works for me:

\documentclass{minimal}
\newcommand\Foo[1]{Foo does: `#1'}
\newcommand\BaBar[2]{BaBar does: `#1{#2}'}
\begin{document}
\BaBar{\Foo}{xxx}
\end{document}

perhaps you had an error \bar already defined? because I just copied your code and changed the name of the \bar command to avoid that error message.