On 23/01/23 4:53 AM, Bram Moolenaar wrote:
I expected a lively discussion about alternatives for the class
implementation, but nothing much happened. Does this mean that most
people agree with making this changed:
1. Make object members public by default. They can be read and written
from anywhere.
2. The only other possibility is making the object members private.
This is done with the existing mechnism to prefix an underscore to
the name.
This simplifies things, there is no "read-only" access mode, which is
currently the default. There is no need for a "plublic" keyword. This
is a bit limited, but it's simple. And making things simple is part of
the goals for the Vim9 script syntax.
Unless there are relevant objections, I'll make this change.
This makes me uncomfortable at first consideration; allowing random
actors, by default, to modify internal state of other plugins does not
seem to support reliability. BUT...
I have no experience with legacy vimscript, I've seen that a dict is
used as an "object". So I guess the proposed access control, with "_"
for private allows protection in vim9script.
That said, by default having r/w access within the defining file would
be nice (kinda like a java package with multiple classes in a single
file), and default access private to other files. Use public for access
outside the file. Guess I'm looking for a way that a trusted group of
classes can have full access; but I'm not sure how important that really
is (and I'm not sure how I feel about a bunch of classes in a single
file). It seems some sort "package" access mechanism could be compatibly
added if it turns out it's needed. One area where it might be
particularly useful is vim9script libraries.
But I enjoy and sometimes use python (and I occasionally do things I'd
call cheating), I'm a fan of simplicity. I ported half of a vim/python
hybrid plugin to vim9 leaving the primary class structure in python; I'm
looking forward finishing it with vim9script classes, no matter what the
rules are, and having a pure vim plugin.
-ernie
--
--
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/d4e8f8e0-c7b1-6e06-9567-3a904a62b1a0%40raelity.com.