Justin M. Keyes wrote:
> Am So., 11. Aug. 2019 um 00:11 Uhr schrieb Bram Moolenaar <
Br...@moolenaar.net>:
> > Currently user functions can be used both without a context and as a
> > method, it is not possible to restrict them to be used as one or the
> > other. Very often this doesn't matter, the method is the same as the
> > function, passing the base as the first argument. But questions arise:
[...]
> What problem is being solved by adding these various OOP cosmetics to
> Vimscript, other than ticking a "I have this feature" checkbox?
That is not at all we are doing. Function chaining has nothing to do
with OOP.
> Historically, something that I strongly appreciated about Vim was its
> (now obviously accidental) culture of backwards-compatibility in the
> *plugin community*. This happened (accidentally) because Vimscript
> evolved so slowly, it was usually worth the effort for plugins to
> support 10-year-old versions of Vim. Contrast to Emacs, where I found
> most plugins required the latest version.
That is not true, over time new functionality was added and quite often
plugins soon popped up which used this functionality, thus depended on
that new version. And old plugins keep working, that is what backwards
compatibility is about. If you see an old plugin break because of new
functionality, then please report it soon, that's not what we want.
> With meaningless syntax-sugar being added into Vimscript, that
> accident will become much less frequent. Plugin authors can add
> wrappers for e.g. missing *library* functions. But they cannot add
> wrappers for syntax sugar. They could adopt a "subset" (like C++...
> does that sound familiar?) of VimL, but the general effect will be
> pollution of community knowledge as the discussion becomes more
> complicated, with code samples only working in recent Vim versions
> simply because someone writes foo->bar() instead of bar(foo).
And don't see what wrappers are needed for new syntax. Just keep using
the old syntax.
Every plugin writer will have to aim for a certain minimal Vim version.
If the plugin uses the new popup window feature, then older versions
will just not work. This is nothing new. Except perhaps I'm now adding
functionality requested by plugin writers about a year ago, thus it's
likely plugins will appear that use these new features. There is
nothing wrong with that.
Today's version of Vim is new and not widely spread, but in a few years
it is, and then we'll be glad there is a better way to write Vim script.
> Why in the world is foo->bar() worth sacrificing even a small amount
> of backwards compatibility,
If you think this breaks backwards compatibility, please give an
example.
> or worth complicating tutorials/documentation/discussions even a small
> amount? It is pure vanity. The same applies for these other
> meaningless OOP cosmetics (including "dict functions" which are harder
> to debug).
I found myself writing Vim code this way, because it's very natural.
All modern languages use and recommend this, including Java and
Typescript, which are both very popular.
> It is strange that these "fake OOP" features are being *amplified* in
> Vim now. What's the point?
Again, this has nothing to do with OOP.
> > I was first thinking of adding a property to the function command:
> > function Total(arg) method=list
> > function Total(arg) method=dict
> >
> > Many languages now support an optional type, using that we could do:
> > function Total(arg: list) method
> > function Total(arg: dict) method
>
> Type-parameterized methods are usable in languages with IDEs. But I do
> not think it makes sense to change Vimscript into a language that
> requires an IDE: that is a regression, not an improvement.
I hardly ever use an IDE for any language, including Java and
Typescript. True, someone who is familiar with a good IDE can do
certain things faster, but these IDEs are lacking a good editor...
Anyway, the real question I'm asking is if selecting a function/method
based on the type is actually useful or will just make things more
complicated?
--
hundred-and-one symptoms of being an internet addict:
39. You move into a new house and decide to Netscape before you landscape.