> So, instead of using the "this." prefix, vim9 could specify that member 
> variable names must either use the @ prefix for public, or use the _ prefix 
> for private.   ie., all member variable names must have one of these two 
> prefixes.   I think this is worth considering, because it's simple, clear 
> and explicit.  You no longer need the following keywords;  "this", "public" 
> and "private".

[...]

One of the goals of Vim9 script was to make it more similar to popular
languages.  So that switching between Vim script and another language
isn't too difficult.

A language I have been experimenting with used "$" instead of "this.".
That works quite well, it's short and easy to recognize.  But it's
different from every other language.

I think most users will immediately understand what "this." means.
Anything else will take some time getting used to and probably lead to
mistakes.  Using the underscore prefix for "private" is already a bit
obscure, but other languages do it too, hopefully that means it's easy
to get used to.

Just using a dot prefix instead of "this." seems practical, but again is
different from any other language.  It's a bit hard to spot, with a
dirty monitor all variables appear to be members :-).

I think using "this." everywhere is simple and similar to what other
languages do.  It is a bit more verbose, but that's a small price to
pay.  It helps making members stand out from function arguments, local
variables, etc.


About public/private/read-only: Making the default public is certainly
possible.  I think most languages have it that way, even though it's not
a safe choice.

I do like the read-only access.  Quite often you want to disallow any
code outside of the class to change a member, so that you can make sure
the value is valid.  But making it private means you have add a
"getter" and call it.  Unfortunately I don't know a good keyword to use.
C# has the "readonly" keyword, but it means something else.

Nevertheless, if we give priority to keeping it simple, making members
public by default and using the underscore for private is the way to go.


-- 
Q: What is the difference between open-source and commercial software?
A: If you have a problem with commercial software you can call a phone
   number and they will tell you it might be solved in a future version.
   For open-source software there isn't a phone number to call, but you
   get the solution within a day.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/20230116142359.256D81C091A%40moolenaar.net.

Raspunde prin e-mail lui