6
$\begingroup$
Control@{h[3], 0, 1}

It is puzzling. (The motive for h[i] is to build a list of controls.)

$\endgroup$

1 Answer 1

6
$\begingroup$

It seems that Control is just a wrapper for Manipulate`Control, and that function expects a Symbol as its first argument:

Control[]; (*preload*)

ClearAttributes[Manipulate`Control, {Protected, ReadProtected}]

Block[{$Context = "Manipulate`Dump`"},
 Definition[Manipulate`Control] // Print;
]
Manipulate`Control[var_, Manipulate`Dump`opts___Rule, ControlType -> type_, 
  opts2___Rule] := Manipulate`Control[var, type, Manipulate`Dump`opts, opts2]

Manipulate`Control[var_Symbol, Manipulate`Dump`opts : OptionsPattern[]] := 
 Manipulate`Control[var, Automatic, Manipulate`Dump`opts]

Manipulate`Control[{var_Symbol, args___}, Manipulate`Dump`opts : OptionsPattern[]] :=
  Manipulate`Control[{var, args}, Automatic, Manipulate`Dump`opts]

. . .

All but the first definition use _Symbol which requires that the Head of the expression be Symbol, and the first definition just calls one of the others.

This seems like an oversight as one can easily configure a slider with h[3]:

Dynamic[h[3]]
Slider[Dynamic[h[3]], {0, 1}]
$\endgroup$
6
  • $\begingroup$ Thank you @Mr.Wizard . The code you wrote is somewhat too complicated for me but I understand the comment following it. Manipulate too allows h[3]. But what is Manipulate`Control? $\endgroup$
    – User18
    Commented Mar 1, 2016 at 16:33
  • 1
    $\begingroup$ @User18 Manipulate`Control seems to be the internal function that Control is transformed into the course of evaluation and Front End formatting. I am attempting to follow internal definitions to arrive at this conclusion. The point is that if I am correct and Control relies upon Manipulate`Control, and the latter only works with Symbols, then the observed behavior is expected if disappointing. $\endgroup$
    – Mr.Wizard
    Commented Mar 1, 2016 at 17:05
  • $\begingroup$ That's most helpful. It is strange that in the MMA Documentation I cannot find information about it, nor the usage of the ` sign acting not as a number mark. Then where should I look them up? $\endgroup$
    – User18
    Commented Mar 2, 2016 at 2:58
  • 1
    $\begingroup$ @User18 Manipulate`Control is an internal, behind-the-scenes function and I would not expect to find documentation for it. The use of the backtick here is for Context; this Control is in the context Manipulate` . The regular Control is in the System` context. See: reference.wolfram.com/language/tutorial/Contexts.html $\endgroup$
    – Mr.Wizard
    Commented Mar 2, 2016 at 11:34
  • $\begingroup$ [email protected] Having learned about contexts I now understand the code you posted. Thanks a lot! Ah, it seems we both had a little problem with typing code when the code contained the code wrapper. $\endgroup$
    – User18
    Commented Mar 2, 2016 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.