```
const x = nameof y
const y = 1;
```
At line 1 adjacent to ```nameof``` how does the user even know that there
is a variable that will be declared named ```y```?
What is the output of ```x``` where there is no variable named ```y```
later declared?
```
const x = nameof y
const z = 1;
```
On
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 position
Would posit that ```nameof``` should be used only _after_ a variable has
been initialized. A variable lookahead could lead to false-positives and
unexpected results.
What is the use case for ```nameof``` being used _before_ variable
initialization?
On Sun, Jun 16, 2019 at 12:03 AM Ron Buckton
wr
> 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.
> Shou
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, 3000
```
const x = nameof y
const y = 1;
```
`x` would have the value “y”. It would not matter if `y` were initialized or
had yet been reached during execution. It does not deviate from the purpose of
`let` or `const`, because you are not accessing the value of the identifier.
Also consider that thi
> 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 ```const```,
Sorry, I meant to say “not entirely correct”.
From: Ron Buckton
Sent: Saturday, June 15, 2019 3:03 PM
To: guest271314
Cc: es-discuss@mozilla.org
Subject: RE: Re: What do you think about a C# 6 like nameof() expression for
> At that point in the example code the identifer ```y``` does not exist.
```
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
> 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 an
> 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,
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 you
12 matches
Mail list logo