In the next code I would like to use three or four arguments. I tried
[add/.style args={#1 and #2 with #3}{to path={%
($(\tikztostart)!-#1!(\tikztotarget)$)--($(\tikztotarget)!-#2!(\tikztostart)$)%
\tikztonodes coordinate[pos=-.25](#3)}}]
but I'd like the with #3 part to be optional.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[add/.style args={#1 and #2}{to path={%
($(\tikztostart)!-#1!(\tikztotarget)$)--($(\tikztotarget)!-#2!(\tikztostart)$)%
\tikztonodes coordinate[pos=-.25](x)}}]
\coordinate (A) at (0,0);
\coordinate (B) at (3,2);
\draw[add=.5 and .5](A) to (B);
\foreach \point in {A,B,x}
\fill [red,opacity=.5] (\point) circle (2pt);
\end{tikzpicture}
\end{document}


\pgfkeysvalueofthis will be an opportunity to understand how it works. I saw from your answers that you like this method. – Alain Matthes Mar 12 '20 at 16:57\draw[decorate,decoration={brace,mirror,raise=5pt},blue] ..., i.e. pass multiple optional keys to the decoration, and if you don't, it will use the initial/default values. And yes, I do like this kind of usage a lot, I am even using it now for non-TikZ-related problems because you can always upgrade your macros while maintaining backwards compatibility, and IMHO the usage is easier to remember. – Mar 12 '20 at 17:35