#18083: Stop using old_style_globals
-------------------------------------+-------------------------------------
       Reporter:  jdemeyer           |        Owner:
           Type:  enhancement        |       Status:  new
       Priority:  major              |    Milestone:  sage-6.6
      Component:  cython             |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Jeroen Demeyer     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/jdemeyer/stop_using_old_style_globals|  
9ccd889321d311903d4ab26449e6dd8154879aee
   Dependencies:  #12446, #18084     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by nbruin):

 Just an idea:

 Logically, we can't really ask an object to inject itself into "the"
 globals namespace, because the object doesn't really have access to what
 that namespace is in the relevant situation.

 Instead what one ''can'' do from the REPL is to bind an object to its
 print name, which is what injection usually does. Then one actually
 doesn't need any special machinery on objects. See:
 [http://trac.sagemath.org/ticket/17958#comment:54]

 In principle then one can spell:
 {{{
 sage: x = SR.var('x')
 sage: inject(x)
 }}}
 where `inject` could be defined in the "global scope" (by injecting its
 definition into the start-up, like `.sage`):
 {{{
 def inject(a):
     globals[str(a)]=a
 }}}
 except that we'd want to do some validation on `str(a)` before we do that.
 It can also be shortened to `inject(SR.var('x'))` to avoid repetition.

 Of course to ''type'' this is very inconvenient, so we'd need some further
 wrappers to make the syntax more palatable (the `%var` directive seems
 like a good step), but the simplicity of the implementation and the
 flexibility of the construction leads me to believe that this is the right
 way of providing injection capability.

--
Ticket URL: <http://trac.sagemath.org/ticket/18083#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to