(All prices are in $)
Say that at time $t=0$, $A$ goes long a forward contract with maturity $T$ on an underlying asset $X$ with forward price 100 \$, that is, $A$ agrees to buy $X$ for 100 \$ at time $T$. At initialisation, the actual value of the forward contract is equal to $0$.
Suppose, we are now at time $t$ where $0<t<T$, and we want to determine the fair value of the forward contract. Say that at time $t$, the forward price for the same underlying with same maturity is for example 110 \$. This means that $A$ has gained since the market tells that $X$ can now be bought for 110 \$ at time $T$ instead of 100\$. Therefore $A$ would actually make a profit of 10 \$ at time $T$ and discounting back to time $t$, the contract value is $10e^{-r(T-t)}$ where $r$ is the risk-free rate for period $T-t$. Generally speaking, if $F_0$ is the forward price at $t=0$, then the forward contract's value at time $t$ is $S_t-F_0e^{-r(T-t)}$. So basically the time $t$ value of the forward contract is $(F_t-F_0)e^{-r(T-t)}$ where $F_t$ is the time $t$ forward price.
Now, why is this not exactly the same than mark-to-market? If you mark-to-market at time $t$, then party $B$ (the party that shorted the contract) has to give 10 \$ to A and the new contract will be as if it were a forward with forward price 110 \$. I would expect that $B$ has to pay $10e^{-r(T-t)}$ to $A$ rather than 10 \$, because the actual loss on the forward contract is reflected on maturity and has thus to be discounted?
Say that the forward price keeps increasing over the life of the contract and that $A$ always gets a positive amount added to it's margin. For example, the forward price was 100 (day 0), 110 (day 1), 120 (day 2) and 130 (day 3 of maturity, so 130 is the spot price of $X$). If there was no concept of margin, then $A$ would have a pay-off of $130-100 = 30$. With the concept of margin, $A$ has gained 10 \$ over the last three days, but the 10 \$ gained on the margin after day 1 has in the mean time accrued at the risk-free rate so I would expect the pay-off with the margining to result in a slightly higher result then if it was not margined?
Can someone explain me where I mix up the concept?