> > One thing I'm not yet sure about is the declaration.  Currently it works
> > like this:
> >
> >         this.name: string
> >         this.gender: Gender
> >
> > Notice that there is no "var" keyword.  It's not needed to recognize the
> > declaration.  I can't think of a good reason to add "var" here, other
> > than that a declaration would be expected to always have "var".  Well, I
> > don't have that expectation.
> 
> This following currently defines a field and is, without context,
> indistinguishable from any other assignment.  Is that intended?

With "var" it's indistinguishable from another declaration, I don't
think it matters much that it looks like an assignment otherwise.

> this.name = "Somebody"
> 
> As methods still require :def I think it would be more consistent to not
> special case field declarations and still require the :var.

True, for methods ":def" is used like elsewhere.  I'm not sure if using
":var" for variables should be considered more consistent.

> For class members most languages use the "static" keyword.  It's a bit
> > of a weird word, but I suppose most people are used to it, and I can't
> > find a popular language that has a good alternative.
> >
> > If we leave out "var" for object members, I suppose we should also leave
> > it out for class members.  We then get:
> >
> >         static oneClassMember: number
> >         static twoClassMember: string
> >
> > I think this looks fine.  Any objections?
> 
> It seems from the documentation that static fields can be referenced as
> bare identifiers?  This feels a bit unexpected to me given that instance
> fields are always qualified.

Static fields (class members) are totally different from object members.
I have always found it confusing, in many languages it's hard to tell
them apart, especially if the declaration is further away.  Always using
"this" for object members helps a lot for this.  I would not know what
to use for class members.  The only thing I have seen is using the class
name, which can be long (and gets tricky when using inheritance).
I believe most languages access class members directly, without a
prefix.

We have already dropped the "s:" prefix for using script-local
variables.  Using class members is a bit similar to that. 

-- 
We learn from our mistakes.  Politicians don't make mistakes.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221225150208.1227A1C0AA3%40moolenaar.net.

Raspunde prin e-mail lui