Andy Massimino wrote:
> On 8/3/19 4:29 PM, Bram Moolenaar wrote:
> > I wrote:
> >
> >> Patch 8.1.1803
> >> Problem: All builtin functions are global.
> >> Solution: Add the method call operator ->. Implemented for a limited
> >> number
> >> of functions.
> >> Files: runtime/doc/eval.txt, src/eval.c, src/structs.h,
> >> src/userfunc.c,
> >> src/globals.h, src/evalfunc.c, src/proto/evalfunc.pro,
> >> src/testdir/test_method.vim, src/testdir/Make_all.mak
> >
> > For now this makes a few existing functions available as methods, e.g.
> >
> > mylist->filter(filterexpr)->map(mapexpr)->sort()->join()
> >
> > It's a lot easier to read than:
> >
> > join(sort(map(filter(mylist, filterexpr), mapexpr)))
> >
> > When we add new methods for List, Dict, etc. we can now make them local
> > to those objects, instead of adding them globally.
> >
> > I decided to use "->" because of the similarity with C pointer usage.
> > It would be nice to use ".", but I'm quite sure that won't be backwards
> > compatible, especially when using a Dict.
>
> I agree, backwards compatibility should not be broken.
>
> But I wonder if "." is fine with scriptversion 2. If the dict has a
> field named "len" then it will be used as before, otherwise the len()
> function will be called. This means users can also override the
> methods if they choose, but no existing scripts would be broken.
Maybe it's possible to use "." in some situations, but consistency is
also important. It's also clear that ->name( is a method call.
Still need to decide what is the best way to define user methods.
--
Computers are useless. They can only give you answers.
-- Pablo Picasso
/// 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 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/201908041304.x74D4mfv030693%40masaka.moolenaar.net.