Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> I like the feature, don't love the boilerplate.

It's not for you, though. The boilerplate is for a very small number of libraries and frameworks that have use for this feature. The ergonomics of using the resulting methods from these libraries and frameworks are quite good.

This is just like the CallerMemberName attribute.



> It's not for you, though.

It is "not for me" though because of the reason I said: Too much boilerplate for common usage. If it had less it would be for "me" and everyone else too, just like the nameof() is.

So it is a niche tool exactly because of the implementation. I bet a lot of people expected nameof() to be niche too, but it isn't.


No, it's a niche tool because it's a niche tool. This feature has very limited use; even more limited than CallerMemberName. It actually makes a lot of sense not to invent a lot of new syntax or compiler logic to handle something this rarely used.


agreed, if they made it to be eg. expressionof() - which to be fair might happen in the future - then it would be just as usable as nameof()




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: