#343 new [apply] command

closed-accepted
Don Porter
5
2014-08-15
2004-04-29
miguel sofer
No

A proposed new [apply] command to apply anonymous
functions, giving one possible (but different)
implementation for the goals of TIP 187 (Functions as
Values).
Attaching a patch that provides the command; a possible
manual page is at http://utdt.edu/~mig/apply.html.

Discussion

1 2 > >> (Page 1 of 2)
  • miguel sofer
    miguel sofer
    2004-04-29

     
    Attachments
  • Logged In: YES
    user_id=79902

    Issues, some of which are not serious in demo code:
    * Which is the correct namespace to execute in?
    * The errorInfo messages are misleading
    * Should the guts of TclObjInterpProc be extracted so that
    they can be called from [apply]? IncrTcl (and other
    extensions?) might also be a client of such a function, even
    if it was internal, so whatever it is ought to go in the
    stubs table.

     
  • miguel sofer
    miguel sofer
    2004-04-30

     
    Attachments
  • miguel sofer
    miguel sofer
    2004-04-30

    Logged In: YES
    user_id=148712

    Addressing only the first issue, new apply2.patch with
    manpage at http://utdt.edu/~mig/apply2.html

    This version executes the anonymous function in the global
    namespace by default, but a different (constant) namespace
    can be specified.

    The remaining two issues are still unaddressed; this is
    experimental code, those matters will definitely be fixed
    before applying.

     
  • Logged In: YES
    user_id=19214

    Following discussion on tkchat, it is possible (and
    desirable) to simplify struct Proc so that it no longer
    requires a Command, but instead directly points to its
    defining Namespace ... this will require further
    modification to the [rename] command, to preserve rename
    semantics (where renaming a command associated with a proc
    will change the proc's Namespace) ... to be attached in a
    different patch.

    Justification: a proc needs to know its own namespace
    (although except for the [variable] command, it's hard to
    know precisely why ... more analysis work needs to be done)
    but the additional requirement, that it possess an
    associated command, doesn't seem warranted.

    The included patch removes that requirement, and should
    enable eventual simplification of Miguel's [apply] patch by
    not absolutely requiring it to create a Command to associate
    with an anonymous proc.

    This simplification is beneficial with, or without, changes
    to tcl semantics permitting direct evaluation of a Lambda
    ObjType.

     
  • Patch to remove Command and replace with Namespace in struct Proc

     
    Attachments
  • Logged In: YES
    user_id=19214

    Second patch to remove Command* from Proc.

    This handles [rename] and properly refcounts Namespace refs
    held in Procs.

     
  • Update of procns.diff - handles [rename] and Namespace refcount correctly

     
    Attachments
  • miguel sofer
    miguel sofer
    2006-01-11

     
    Attachments
  • miguel sofer
    miguel sofer
    2006-01-11

    Logged In: YES
    user_id=148712

    Updated patch apply3.patch, applies to HEAD.

    Note that this is still a proof-of-concept: missing tests
    and comments, for instance.

     
1 2 > >> (Page 1 of 2)