# How to destructure local variables?

Why can't I use this

Where[{iw, ih} = ImageDimensions[i], ...]


Where[dim = ImageDimensions[i], iw = dim[[1]], ih = dim[[2]], ...]

• Excuse me, why the down-vote? This is a good question that might expose a limitation of the core language, perhaps you don't care for language design?
– M.R.
Mar 4 '15 at 1:05
• It has very little value in my opinion. But I reversed my down-vote. Mar 4 '15 at 1:10
• possible duplicate of A smarter nested With? Mar 4 '15 at 1:57

Presumably you are referring to Where from the "GeneralUtilities" package.

You can see the definition for yourself:

Attributes[Where] = {HoldAll}

Where[expr_] := expr

Where[x_List, expr_] := With[x, expr]

Where[x_, expr_] := With[{x}, expr]

Where[x_, rest__, expr_] := Where[x, Where[rest, expr]]

Where[s : Verbatim[Set][x_List, y_], rest___, expr_] :=
With[{x2 = Quiet[Replace[Hold[x], z_Symbol :> z_, {2}]]},
Replace[y, {HoldPattern @@ x2 :> Where[rest, expr], _ -> \$Failed}]]
`

If it is not written as you would like use this for inspiration and write your own. :-)

• Ah, that casts some real light on the question. I still think the question is badly posed. Mar 4 '15 at 1:17