this post was submitted on 30 Jun 2023
10 points (100.0% liked)

C Sharp

1511 readers
11 users here now

A community about the C# programming language

Getting started

Useful resources

IDEs and code editors

Tools

Rules

Related communities

founded 1 year ago
MODERATORS
10
submitted 1 year ago* (last edited 1 year ago) by starman to c/csharp
 

Link to GitHub issue: https://github.com/dotnet/csharplang/issues/7009

Link to video explaing it: https://youtu.be/91xir2oUQPg

top 4 comments
sorted by: hot top controversial new old
[–] kogasa 10 points 1 year ago (1 children)

Love the implications of this as a compile time alternative for reflection, really hope I never run into it personally though.

[–] starman 4 points 1 year ago (1 children)

I agree, this reminds me of goto

[–] FamiliarSoftware 4 points 1 year ago

It's worse, this is literally comefrom

[–] [email protected] 6 points 1 year ago

So realistically, the interceptable method will always know which generator(s) will target it ahead of time, right? There's no reason to put an [Interceptable] attribute on the method otherwise, after all. (In the video it seems like that's not required in the current prototype, but I saw no mention of removing this in the issue discussion. Perhaps that check was just not implemented yet?)

To me this seems like a very weird version of Lisp macros, with their implementation hidden away in those generator(s) and essentially comefroms hidden away in the generated code. Though I suppose this is technically more powerful than macros because the generators are presumably allowed to look not just at the call itself but at the code around a call.

I suppose it's mostly the comefrom-iness I dislike about it. Now the code could do something entirely different, without any indication at the call site (unless you have your IDE highlight this for you or something). I feel like this language feature would make it harder to keep a mental model of what's going on in the code in my head, especially if it winds up getting used for things that actually change the behavior of the code (e.g. AOP) instead of just doing essentially "the same thing, but faster and without reflection".

I like that they're working on stuff like this, but perhaps just not exactly like this.