Re: Re: What do you think about a C# 6 like nameof() expression for

2019-06-15 Thread Isiah Meadows
I've got a few code bases where I do a lot of stuff like `func(person, "person")`, and it'd be pretty useful to avoid the duplication. I'd prefer something more direct like `nameof binding`, `nameof binding.key`, and `nameof binding[key]`, where it returns the expression at that parameter

Re: Re: What do you think about a C# 6 like nameof() expression for

2019-06-15 Thread Ron Buckton
> What should occur where the code is It would be "y" in all 3 places. > ... is a proposal for _more_ than only getting the _name_ of an _declared_ > and _initialized_ variable? It is a proposal for getting the name of a _declared_ variable. Whether it is _initialized_ does not matter. >

Re: Re: What do you think about a C# 6 like nameof() expression for

2019-06-15 Thread guest271314
What should occur where the code is ``` const x = nameof y await new Promise(resolve => setTimeout(resolve, 10)); // should x be "y" here? await new Promise(resolve => setTimeout(resolve, 20)); // should x be "y" here? await Promise.all([new Promise(resolve => setTimeout(resolve,

Re: Re: What do you think about a C# 6 like nameof() expression for

2019-06-15 Thread guest271314
> Sorry, I meant to say “not entirely correct”. You have not yet confirmed if in fact the expected output is referencing a variable declared using ```const``` on the current line _before_ initialization _on the next line_. That example appears to deviate from the purpose and usage of

Re: Re: What do you think about a C# 6 like nameof() expression for

2019-06-15 Thread guest271314
``` const f = () => y; let y = 1; ``` is different (dissimilar) code than the original reference example code. > I don’t disagree that there are “alternative approaches” to ‘nameof’ for many cases, but they all incur overhead. Given that a ```ReferenceError``` is thrown when attempting to

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-15 Thread Ron Buckton
> At that point in the example code the identifer ```y``` does not exist. That is not entirely incorrect. The identifier `y` exists, but its binding has not been initialized, otherwise you couldn’t refer to y in this case: ``` const f = () => y; let y = 1; ``` > That fact can be utilized for

Re: Re: What do you think about a C# 6 like nameof() expression for

2019-06-15 Thread guest271314
> It doesn’t matter what the *value* of ‘y’ is, just what the lexical name of `y` is. `nameof` wouldn’t refer to `y` as an expression, its just pointing to the identifier. Was not referring to the _value_ of ```y```. At that point in the example code the identifer ```y``` does not exist. That is,

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-15 Thread Ron Buckton
It doesn’t matter what the value of ‘y’ is, just what the lexical name of `y` is. `nameof` wouldn’t refer to `y` as an expression, its just pointing to the identifier. From: guest271314 Sent: Friday, June 14, 2019 10:03 PM To: Ron Buckton Cc: es-discuss@mozilla.org Subject: Re: Re: What do