We’re rewarding the question askers & reputations are being recalculated! Read more.
2 added 386 characters in body
source | link

You could use HoldForm instead of Hold, for example

bar := {1, 1, 1};
foo[var_] := {ToString@HoldForm[var], var}
SetAttributes[foo, HoldAll]
foo[bar]

(* output: {"bar", {1, 1, 1}} *)

Edit

To distinguish between proper variable names and something like ape + bear you could do something like

foo[var_] := {var, Quiet@Check[SymbolName[Unevaluated[var]], False]}
SetAttributes[foo, HoldAll]

bar := {1, 1, 1};
ape = {2, 3, 4};

foo[bar]

(* ==> {{1, 1, 1}, "bar"} *)

foo[bar + ape]

(* ==> {{3, 4, 5}, False} *)

You could use HoldForm instead of Hold, for example

bar := {1, 1, 1};
foo[var_] := {ToString@HoldForm[var], var}
SetAttributes[foo, HoldAll]
foo[bar]

(* output: {"bar", {1, 1, 1}} *)

You could use HoldForm instead of Hold, for example

bar := {1, 1, 1};
foo[var_] := {ToString@HoldForm[var], var}
SetAttributes[foo, HoldAll]
foo[bar]

(* output: {"bar", {1, 1, 1}} *)

Edit

To distinguish between proper variable names and something like ape + bear you could do something like

foo[var_] := {var, Quiet@Check[SymbolName[Unevaluated[var]], False]}
SetAttributes[foo, HoldAll]

bar := {1, 1, 1};
ape = {2, 3, 4};

foo[bar]

(* ==> {{1, 1, 1}, "bar"} *)

foo[bar + ape]

(* ==> {{3, 4, 5}, False} *)
1
source | link

You could use HoldForm instead of Hold, for example

bar := {1, 1, 1};
foo[var_] := {ToString@HoldForm[var], var}
SetAttributes[foo, HoldAll]
foo[bar]

(* output: {"bar", {1, 1, 1}} *)