On Wed, 13 Dec 2006 12:26:26 -0800, Iftikhar Burhanuddin <[EMAIL PROTECTED]> wrote:
> >> > sage: SupersingularModule(11). >> > >> > Should this be legal? And should be implemented without actually >> > creating >> > the oject with *just* syntatic checking? What say folks? >> >> How on earth would one implement that? There's no guarantee that the > > We need to think about how to implement this carefully. And currently I > cannot *think* as I'm mechanically grading student finals :) > > Let's not thrash the idea because it is difficult to implement! First > lets > answer this Q: is there any value-addition to user-friendliness due to > this feature? IMO ... yes! What say? (1) I'm against allowing 5.factor() to work. (2) I'm against syntactic parsing to do tab completion. However, I'm open to the possibility of having the tab complete function work on any syntatically correct expression (for which eval works). At least, I would consider implementing it and trying it out before rejecting the idea out of hand. In the notebook the relevant function is completions in sage/server/support.py: def completions(s, globs, format=False, width=90): """ Return a list of completions in the context of globs. """ Right now s is assumed to be an identifier (possibly with dots, e.g., foo or foo.bar.spam). But this is an easy assumption to get around. E.g., if you replace the completions function by the function below, then the following works: sage: sage.server.support.completions('SupersingularModule(11)', globals()) ['SupersingularModule(Integer(11)).Hom', 'SupersingularModule(Integer(11)).T', 'SupersingularModule(Integer(11)).ambient', 'SupersingularModule(Integer(11)).ambient_module', 'SupersingularModule(Integer(11)).anemic_hecke_algebra', 'SupersingularModule(Integer(11)).atkin_lehner_operator', 'SupersingularModule(Integer(11)).base', ... Of course, tab completing on SupersingularModule(11).hecke_operator(99999999) would take a while... but one can always cancel it (in the SAGE notebook at least). More general version: def completions(s, globs, format=False, width=90): """ Return a list of completions in the context of globs. """ n = len(s) if n == 0: return '(empty string)' if not '.' in s and not '(' in s: v = [x for x in globs.keys() if x[:n] == s] else: if not ')' in s: i = s.rfind('.') method = s[i+1:] obj = s[:i] n = len(method) else: obj = s method = '' try: O = eval(obj, globs) D = dir(O) try: D += O.trait_names() except (AttributeError, TypeError): pass if method == '': v = [obj + '.'+x for x in D if x and x[0] != '_'] else: v = [obj + '.'+x for x in D if x[:n] == method] except Exception, msg: print msg v = [] v = list(set(v)) # make uniq v.sort() if format: if len(v) == 0: return "no completions of %s"%s else: return tabulate(v, width) return v --------------- So I'm open to more flexible tab completion... William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---