2016-05-21 21:23 GMT+03:00 Bram Moolenaar <[email protected]>:
>
>
> > From a functionality perspective, there should be a way to take the
> > function from dict1.f1 (which is bound to dict2) and apply it to dict1
>
> You can always do that with function().
>
> > Perhaps an attempt to re-bind a (already bound) function should be explicit.
> > e.g.
> > ```vim
> > let dict1 = {"test": "dict1"}
> > function dict1.f1() {
> > return self.test " returns 'dict1'
> > }
>
> When specifying a function like this, it's always bound to the
> dictionary it's specified for.
It is not. Automatic binding occurs *only* in handle_subscript, this
variant just defines a new anonymous function and saves a funcref (not
partial) to it in a dictionary without any bindings to any
dictionaries. To change this it is needed to modify ex_function().
>
>
>
> > " 1) - explicit binding (scope change) using function(func, dict)
> > let dict2 = {"test": "dict2"}
> > let dict2.f2 = function(dict1.f1, dict2) " explicit binding to dict2
> > call dict2.f2() " returns 'dict2' because dict2.f2 is explicitly bound to
> > 'dict2'
> >
> > " 2) - desire to change scope is not expressed explicitly
> > let dict2.f2 = function(dict1.f1)
> > call dict2.f2() " returns 'dict1', i.e. scope is preserved
> > ```
> >
> > if above does not work from backwards compatibility point of view then
> > perhaps `function()` needs another (optional) parameter used to
> > explicitly specify if scope must be preserved or can be changed. If
> > such parameter is not specified then keep current behaviour.
>
> That is an extra flag to change behavior. Generally this makes things
> more complicated, since there are more values possible. I would only do
> this when it can't be avoided.
>
>
> --
> Team-building exercises come in many forms but they all trace their roots back
> to the prison system. In your typical team-building exercise the employees
> are subjected to a variety of unpleasant situations until they become either a
> cohesive team or a ring of car jackers.
> (Scott Adams - The Dilbert principle)
>
> /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
> /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\ an exciting new programming language -- http://www.Zimbu.org ///
> \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
>
> —
> You are receiving this because you commented.
> Reply to this email directly or view it on GitHub
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.