On Sunday, 25 December 2022 at 02:34:35 UTC+11 Doug Kearns wrote:

> On Mon, 19 Dec 2022 at 00:33, Bram Moolenaar <[email protected]> wrote:
>
>>
>> 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?
>
> this.name = "Somebody"
>

Is that right?  if that's a declaration as well, shouldn't that include the 
type?
I thought that the declaration would be like this;

this.name : *string *= "Somebody" 

Or is auto-type detection at play here too? 

 

> As methods still require :def I think it would be more consistent to not 
> special case field declarations and still require the :var.
>
> 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.
>

Just sharing another idea - perhaps also require "*static.*" as the class 
scope prefix, and enforce it - for all the same reasons that "*this.*" 
would be enforced as the object scope prefix. 
Alternatively, perhaps we could use the actual class name as the enforced 
prefix for static class scoped variables.   Either option would avoid 
confusion with inner function variables.

Either way, it seems consistency is important here.

The following is all over the place;

        var static    oneClassMember: number
        var static    twoClassMember: string
        this.threeObjectMember: number
        this.fourObjectMember: string

I think that the following also looks inconsistent;

        static   oneClassMember: number
        static   twoClassMember: string
        this.threeObjectMember: number
        this.fourObjectMember: string

I think the following is better, more consistent, and this would be my 
preference;

        static.oneClassMember: number
        static.twoClassMember: string
        this.threeObjectMember: number
        this.fourObjectMember: string

I don't mind var, but I don't see a real need for it either, because the 
declarations will have the type name included.  Anyway, if going to use 
var, please keep it consistent, eg like this;

        var static.oneClassMember: number
        var static.twoClassMember: string
        var this.threeObjectMember: number
        var this.fourObjectMember: string







-- 
-- 
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/9cfcfddd-065a-4bbd-8891-eb9adb2c1b71n%40googlegroups.com.

Raspunde prin e-mail lui