This is an addition to what others have said - not a complete answer by itself:
A "feature" of using the resistor is that it can dissipate the stored energy more rapidly than the diode.
Diode loss initially = Vf_diode x Iinitial whereas
Resistor initial loss = I^2_initial x R.
For more than about 1 Volt drop the resistor energy dissipation rate starts higher and above a few volts its higher or much higher overall.
In some case this matters - eg relay release times are "slugged" by a diode and may be adversely extended. A compromise is a resistor in series with a diode so dissipation is higher/faster, Vmax can be designed and back current is blocked in the on state.
I was thinking using the resistor instead of diode would bring a longer exponential decay so it would be problem if the switching speed is much higher than LR time constant. Don't you think a large R would increase the time constant?
No. This is not a "normal" situation.
In an inductor, at turn off I_existing WILL continue to flow.
If there is NO series path then 1/2Li^2 energy will convert to 1/2CV^2
where C is available capacitance - added or stray.
If only stray capacitance is present it is often small .
For small C V must be very large - you can get kiloVolts of spike from a low voltage supply worst case.
The time constant for an LR combination is tc = (L/R).
ie as R goes up tc goes DOWN.
This is because Iexisting MUST flow so
V = Iexisting x R.
For large R you get large V and larger power as
V^2/R or I^2R.
ie increasing the value of a shunting resistor
will dissipate more power per time period
(and more peak power)
and take less time for Vspike to decay
but voltage increases with R
and energy dissipation rate with R squared.