{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/15079","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/15079/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/15079/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/15079/events","html_url":"https://github.com/dotnet/roslyn/issues/15079","id":187907316,"number":15079,"title":"[Umbrella] How would you imagine constexpr in C#?","user":{"login":"eyalsk","id":3756641,"avatar_url":"https://avatars.githubusercontent.com/u/3756641?v=3","gravatar_id":"","url":"https://api.github.com/users/eyalsk","html_url":"https://github.com/eyalsk","followers_url":"https://api.github.com/users/eyalsk/followers","following_url":"https://api.github.com/users/eyalsk/following{/other_user}","gists_url":"https://api.github.com/users/eyalsk/gists{/gist_id}","starred_url":"https://api.github.com/users/eyalsk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eyalsk/subscriptions","organizations_url":"https://api.github.com/users/eyalsk/orgs","repos_url":"https://api.github.com/users/eyalsk/repos","events_url":"https://api.github.com/users/eyalsk/events{/privacy}","received_events_url":"https://api.github.com/users/eyalsk/received_events","type":"User","site_admin":false},"labels":[{"id":169838071,"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Language%20Design","name":"Area-Language Design","color":"5319e7","default":false},{"id":166672105,"url":"https://api.github.com/repos/dotnet/roslyn/labels/Discussion","name":"Discussion","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":42,"created_at":"2016-11-08T05:48:05Z","updated_at":"2017-01-15T18:05:23Z","closed_at":null,"body":"One of the features that I like from C++11/14 is `constexpr` that stands for [constant expression](http://en.cppreference.com/w/cpp/language/constexpr) and the reason is it allows to evaluate expressions at compile time, it's used heavily for math functions and completely eliminate the overheads from the runtime here is an [example](https://github.com/Morwenn/static_math) of a C++ library that make use of this feature.\r\n\r\n**So here are just some questions to open the discussion:**\r\n\r\n1. Do you think that something like `constexpr` has a place in C#?\r\n\r\n2. Do you think it should behave _exactly_ as it does in C++? if not what needs changing? what's your thoughts? do you have an alternative?\r\n\r\n3. Do you need something like this today for your current C# projects?\r\n\r\n**My opinion:**\r\n\r\n1. I think that it has a place simply because it allows us to decrease run-rime computation with increased compilation time, for some people this might be huge gain in terms of performance, for others it might be small but at the same time I really wonder how many people will actually utilize this feature and wonder whether it's worth it.\r\n\r\n2. I think that the C++ rules are pretty restricting and yet enabling enough freedom to write all sorts of cool functions from simple to complex ones including recursive functions to a pretty _fair_ depth.\r\n\r\n    **Note:** _Some C++ rules obviously don't make sense in C# world but when I speak about rules and behaviour of this feature I mostly speak about them from high level standpoint and I don't expect this feature to be implemented by its C++ spec if at all._\r\n\r\n3. Well, not per se but I love math so I definitely see myself writing a library using this feature. 😄 \r\n\r\nI made this post just as a place for discussion because for some reason I think about this feature a lot! yes for no reason! 😆 \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/272712218","html_url":"https://github.com/dotnet/roslyn/issues/15079#issuecomment-272712218","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/15079","id":272712218,"user":{"login":"asdfgasdfsafgsdfa","id":3814727,"avatar_url":"https://avatars.githubusercontent.com/u/3814727?v=3","gravatar_id":"","url":"https://api.github.com/users/asdfgasdfsafgsdfa","html_url":"https://github.com/asdfgasdfsafgsdfa","followers_url":"https://api.github.com/users/asdfgasdfsafgsdfa/followers","following_url":"https://api.github.com/users/asdfgasdfsafgsdfa/following{/other_user}","gists_url":"https://api.github.com/users/asdfgasdfsafgsdfa/gists{/gist_id}","starred_url":"https://api.github.com/users/asdfgasdfsafgsdfa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asdfgasdfsafgsdfa/subscriptions","organizations_url":"https://api.github.com/users/asdfgasdfsafgsdfa/orgs","repos_url":"https://api.github.com/users/asdfgasdfsafgsdfa/repos","events_url":"https://api.github.com/users/asdfgasdfsafgsdfa/events{/privacy}","received_events_url":"https://api.github.com/users/asdfgasdfsafgsdfa/received_events","type":"User","site_admin":false},"created_at":"2017-01-15T18:05:23Z","updated_at":"2017-01-15T18:05:23Z","body":"@eyalsk \r\n> In my mind the constexpr feature will require to have different implementation for methods that exists today in the framework so you can't just add const in front of Math.* or DateTime.Now and be done with it.\r\n\r\nIt is entirely possible that I missed something, but why would different implementations be required?\r\nWhat would prevent us/me/the compiler from just slapping `const` in front of something, thereby forcing it to evaluate something at compile-time?\r\n\r\nAre there some subtleties im not aware of?"}}
{"actor":{"display_login":"asdfgasdfsafgsdfa"}}