Something like this?
I've defined a \myfrac command that outputs a/b when in inline math, \frac{a}{b} for display mode.
Code
\documentclass{article}
\newcommand{\myfrac}[2]{%
\ifinner#1/#2%
\else\frac{#1}{#2}%
\fi%
}
\begin{document}
this is inline mode $\myfrac{a}{b}$
\bigskip
and this is display mode
\[\myfrac{a}{b}\]
\end{document}
Output

This has,however, the drawback of printing a/b for \scriptstyle and \scriptscriptstyle, too.
If you don't like this behavior, define \myfrac as
\newcommand{\myfrac}[2]{%
\mathchoice%
{\frac{#1}{#2}}% \displaystyle
{#1/#2}% \textstyle
{\frac{#1}{#2}}% \scriptstyle
{\frac{#1}{#2}}% \scriptscriptstyle
}
MWE
\documentclass{article}
\newcommand{\myfrac}[2]{%
\mathchoice%
{\frac{#1}{#2}}% \displaystyle
{#1/#2}% \textstyle
{\frac{#1}{#2}}% \scriptstyle
{\frac{#1}{#2}}% \scriptscriptstyle
}
\begin{document}
this is inline mode $\myfrac{a}{b}$
\bigskip
and this is display mode
\[\myfrac{a}{b}c^{\myfrac{d}{e}}\]
\end{document}
Output

${a \over b}$to always be${a/b}$? Without exclusion? Note that you should really use$\frac{a}{b}$ and not\over`... – Werner Jan 17 '15 at 05:18\sfrac{1}{2}from thexfracpackage – MaxNoe Jan 17 '15 at 08:19\overin latex! – David Carlisle Jan 17 '15 at 10:16\overis not a latex command and its syntax is completely different to all latex commands, that is why latex defines \frac. Its syntax makes it very hard to customise the behaviour, for example if a document is marked up using\frac\fraccould easily be redefined as in the answers here to use different styles. If a document is marked up with\overthen changing the style means editing the document. Also theamsmathpackage makes\overmake a warning to strongly discourage its use. – David Carlisle Jan 17 '15 at 10:25\fracis a carefully designed "wrapper" around the "primitive" TeX directive\over. See the posting What is the difference between \over and \frac? for more information on this subject, incl. why there's no good reason for using\overdirectly in a LaTeX document. – Mico Jan 17 '15 at 12:44