On 3/29/12 10:20 AM, kcrisman wrote:
experience is consistent with the initial experience, at the cost of
some possible developer confusion since the default value isn't really
Integers(3)(2), but rather sage_eval(repr(Integers(3)(2))).


I hope others have some input on this one, which I think is the only
really controversial part.  Given the purpose of interacts, I find it
hard to imagine that a developer would have sent something like the
original example to someone who didn't know what they were doing.
Explicit is better than implicit, right...?  But I could imagine some
problems.  For instance, what if the Sage object didn't have a repr
that was sage_eval-able?  (A common critique of sage vis-a-vis other
systems, IIRC.)

So then how would the user enter it in the input box as a changed input? Remember, everything coming from the user is a string (that is usually sage_eval'd)

The example could be rewritten like this to be more consistent:

@interact
def _(n=2, type=Integers(3)):
    print n^2

Then Integers(3)(user input) is always run.


Proposed: The default value is sent through repr, then through the
default adapter, so prints ABCDE initially and shows 'ABCDE' in the
input box (note the quotes).  If the user modifies the input box,
hopefully they see that quotes are needed to make it a valid string, so
they modify it to be 'ABCDEF', and then the interact prints ABCDEF


Seems plausible.  Would the interact documentation make the first,
most obvious way to do strings be the shortcut below?  That would cut
down on this.

Are you asking if we will make the change to interact documentation so that the shortcut:

@interact
def _(n="ABCDE"):
    print n

is the preferred way to deal with string inputs? Sure, though sometimes we want to explicitly use input_box to set other options (like the width of the box).

Thanks,

Jason

--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to