id
stringlengths
16
145
text
stringlengths
1
179k
title
stringclasses
1 value
C++_Classes_Templates/Constexprlikekeyword_34_0.txt
That means I do not have to wait till run time to evaluate if the Fibonacci function will work. It is like a simple test at a compile-time. I am asking if I can do thing kind of thing in C#.
C++_Classes_Templates/172624_28_0.txt
[ **Ericool** (522) ](/user/Ericool/)
C++_Classes_Templates/1157_348_0.txt
0 replies
C++_Classes_Templates/1157_72_0.txt
* [ Oldest ](/dotnet/csharplang/discussions/1157?sort=old) * [ Newest ](/dotnet/csharplang/discussions/1157?sort=new) * [ Top ](/dotnet/csharplang/discussions/1157?sort=top)
C++_Classes_Templates/15079_672_0.txt
Sorry, something went wrong.
C++_Classes_Templates/1157_338_0.txt
Collaborator
C++_Classes_Templates/15079_103_0.txt
> but I love math
C++_Classes_Templates/Constexprlikekeyword_133_0.txt
When answering a question please:
C++_Classes_Templates/1157_194_0.txt
All reactions
C++_Classes_Templates/15079_204_0.txt
Author
C++_Classes_Templates/15079_73_0.txt
After some thoughts and quite a bit of discussions here about the cons and pros of this feature which goes up to _performance_ benefits, I do think it has a value but probably a lot less value **when** we consider how it works in C++ and the set of problems it solves there (which aren't the same problems that exist in ...
C++_Classes_Templates/Constexprlikekeyword_7_0.txt
* * *
C++_Classes_Templates/Constexprlikekeyword_27_0.txt
See more:
C++_Classes_Templates/15079_128_0.txt
---
C++_Classes_Templates/15079_754_0.txt
Author
C++_Classes_Templates/15079_626_0.txt
---
C++_Classes_Templates/Constexprlikekeyword_42_0.txt
Comments
C++_Classes_Templates/15079_313_0.txt
Sorry, something went wrong.
C++_Classes_Templates/15079_527_0.txt
I disagree. Compile should not be limited to only values that can be const. that would be an artificial limitation that is not necessary and significantly reduces its usefulness.
C++_Classes_Templates/1157_58_0.txt
I recently learned (in [ #1155 ](https://github.com/dotnet/csharplang/discussions/1155) ) that C# will create a copy of structs if you use ` in ` since it can't trust that the code it calls on them really does not mutate the struct.
C++_Classes_Templates/15079_309_0.txt
Can compiler be written smart enough to know that some entity is constant without explicitly writing "constexpr"? Is it possible to make a rule/algorithm/check that returns true or false if some entity in program is constant?
C++_Classes_Templates/gcc_bugs_3_2.txt
ype=xml&id=52032) * \- [ Clone This Bug ](enter_bug.cgi?cloned_bug_id=52032) * \- Top of page * * [ Home ](./) * | [ New ](enter_bug.cgi?product=gcc) * | [ Browse ](describecomponents.cgi) * | [ Search ](query.cgi) * | [ [?] ](page.cgi?id=quicksearch.html "Quicksearch Help") * |...
C++_Classes_Templates/1157_218_0.txt
` String.Length ` is an instance method and is pure (or constexpr). What makes it pure? it only returns a readonly member. What makes it constexpr? The type string can be a constant e.g. a literal. Of course if you call ` String.Length ` off of a non-constant e.g. a variable, it's no longer constexpr, but it's still pu...
C++_Classes_Templates/1157_433_0.txt
0 replies
C++_Classes_Templates/1157_507_0.txt
* 👍 3
C++_Classes_Templates/172624_73_0.txt
chromatic_scale keyed_chromatic_scale( note n ) { chromatic_scale cs = standard_chromatic_scale ; // <http://en.cppreference.com/w/cpp/algorithm/rotate> std::rotate( std::begin(cs), std::begin(cs) + n, std::end(cs) ) ; return cs ; }
C++_Classes_Templates/15079_136_0.txt
[ @AdamSpeight2008 ](https://github.com/AdamSpeight2008) oh sorry, I thought you're asking why we need it. :)
C++_Classes_Templates/15079_439_0.txt
All reactions
C++_Classes_Templates/15079_219_0.txt
---
C++_Classes_Templates/15079_92_0.txt
###
C++_Classes_Templates/1157_400_0.txt
Beta Was this translation helpful? Give feedback.
C++_Classes_Templates/15079_640_0.txt
---
C++_Classes_Templates/15079_345_0.txt
* 👍 2 reactions
C++_Classes_Templates/15079_384_0.txt
On Fri, Nov 11, 2016 at 9:06 AM, Eyal Solnik [ notifications@github.com ](mailto:notifications@github.com) wrote:
C++_Classes_Templates/1157_475_0.txt
[ ![](https://avatars.githubusercontent.com/u/196899?s=64&v=4) DavidArno ](/DavidArno) Dec 4, 2017
C++_Classes_Templates/15079_211_0.txt
> Should everything, which can be computed determinisitcally, be computed > during compilation?
C++_Classes_Templates/15079_552_0.txt
> Is evaluating Pow(2,3) easier? Or do you suggest only a few functions should > be supported? Like Math.* and maybe some String.* methods? And how is it > decided what methods get to be in the allowed-set? Then again we're going in > circles as the next logical conclusion would be some kind of "provable pure > method"...
C++_Classes_Templates/1157_290_0.txt
# {{title}}
C++_Classes_Templates/15079_158_0.txt
All reactions
C++_Classes_Templates/15079_566_0.txt
edited
C++_Classes_Templates/Constexprlikekeyword_158_0.txt
Web01 2.8:2024-04-02:1
C++_Classes_Templates/Constexprlikekeyword_134_0.txt
1. Read the question carefully. 2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar. 3. If a question is poorly phrased then either ask for clarification, ignore it, or **edit the question** and fix the problem. Insults are not welcome. 4. Don't tell someone to read the ...
C++_Classes_Templates/172624_42_0.txt
![](/img/link.png) Sep 2, 2015 at 8:27pm UTC
C++_Classes_Templates/15079_213_0.txt
> 1. maybe rename the question to contain the tag [umbrella](but that is not > important 😉) >
C++_Classes_Templates/172624_2_0.txt
### **[ C++ ](/) **
C++_Classes_Templates/15079_378_0.txt
var x = 10; var Fib10 = Fibonacci(x); //This call would get reduced into: var Fib10 = 55; }
C++_Classes_Templates/172624_108_0.txt
std::cout << str ; // same as above
C++_Classes_Templates/Constexprlikekeyword_58_0.txt
![](https://www.codeproject.com/script/Ratings/Images/star-fill-md.png)
C++_Classes_Templates/15079_584_0.txt
A simple set of capabilities in this topic area provides real value, it doesn't need to be some far-reaching feature with "global" scope.
C++_Classes_Templates/172624_23_0.txt
However, strongly favour the c-style array with a college education: ` std::array<> ` [ http://en.cppreference.com/w/cpp/container/array ](http://en.cppreference.com/w/cpp/container/array)
C++_Classes_Templates/1157_28_0.txt
We read every piece of feedback, and take your input very seriously.
C++_Classes_Templates/1157_157_0.txt
Something went wrong.
C++_Classes_Templates/1157_297_0.txt
Could you elaborate? Much like ` readonly struct ` or ` in ` , both ` constexpr ` and ` pure ` would conceivably be part of the method/type/field contract. It would be entirely possible for a non-C# language to create a method/type/field that lies about that contract, but that is not normally expected (just like it isn...
C++_Classes_Templates/172624_48_0.txt
what you should do instead is :
C++_Classes_Templates/15079_734_0.txt
Sorry, something went wrong.
C++_Classes_Templates/15079_277_0.txt
All reactions
C++_Classes_Templates/15079_305_0.txt
Copy link
C++_Classes_Templates/15079_430_0.txt
[ ![@TonyValenti](https://avatars.githubusercontent.com/u/13609558?s=80&u=5599dc2a0097562e75f1a30b4956a0fcdc543a1d&v=4) ](/TonyValenti)
C++_Classes_Templates/1157_197_0.txt
# {{title}}
C++_Classes_Templates/C++_Classes_2_3.txt
er initializer lists ](/w/cpp/language/constructor "cpp/language/constructor") [ Default member initializer ](/w/cpp/language/data_members#Member_initialization "cpp/language/data members") (C++11) [ ` friend ` specifier ](/w/cpp/language/friend "cpp/language/friend") [ ` explicit ` specifier ](/w/cpp/language/ex...
C++_Classes_Templates/Constexprlikekeyword_3_0.txt
#### Sign in
C++_Classes_Templates/1157_521_0.txt
Beta Was this translation helpful? Give feedback.
C++_Classes_Templates/15079_426_0.txt
❤️ 1 asdfgasdfsafgsdfa reacted with heart emoji
C++_Classes_Templates/1157_104_0.txt
[ @yaakov-h ](https://github.com/yaakov-h)
C++_Classes_Templates/15079_258_0.txt
###
C++_Classes_Templates/15079_288_0.txt
Sorry, something went wrong.
C++_Classes_Templates/1157_325_0.txt
> Could you elaborate?
C++_Classes_Templates/15079_730_0.txt
~~~~
C++_Classes_Templates/1157_542_0.txt
Unordered list
C++_Classes_Templates/172624_45_0.txt
1 2
C++_Classes_Templates/15079_575_0.txt
By introducing capability to flag the cases we care about, we limit that. One way would be something like
C++_Classes_Templates/15079_570_0.txt
> [ @TonyValenti ](https://github.com/TonyValenti) I disagree. Compile should > not be limited to only values that can be const. > that would be an artificial limitation that is not necessary and > significantly reduces its usefulness.
C++_Classes_Templates/15079_107_0.txt
Sorry, something went wrong.
C++_Classes_Templates/1157_14_0.txt
Resources
C++_Classes_Templates/1157_518_0.txt
Similarly, if a non-readonly struct is passed via an ` in ` parameter, a defensive copy would not be created if the function only invokes readonly methods on it. This allows us more flexibility and is a finer-grained approach to immutability; we're currently stuck in an all-or-nothing situation where structs are either...
C++_Classes_Templates/15079_395_0.txt
###
C++_Classes_Templates/15079_295_0.txt
Let's suppose that JIT external constants can be marked as:
C++_Classes_Templates/15079_525_0.txt
###
C++_Classes_Templates/1157_294_0.txt
[ ![](https://avatars.githubusercontent.com/u/10487869?s=64&v=4) tannergooding ](/tannergooding) Nov 30, 2017
C++_Classes_Templates/1157_39_0.txt
You signed in with another tab or window. [ Reload ]() to refresh your session. You signed out in another tab or window. [ Reload ]() to refresh your session. You switched accounts on another tab or window. [ Reload ]() to refresh your session. Dismiss alert
C++_Classes_Templates/1157_544_0.txt
* * *
C++_Classes_Templates/15079_401_0.txt
[ ![@gordanr](https://avatars.githubusercontent.com/u/12728791?s=80&v=4) ](/gordanr)
C++_Classes_Templates/15079_685_0.txt
[ ![@Pzixel](https://avatars.githubusercontent.com/u/11201122?s=80&u=b167b53f65d631417db340758e82197e6984d4c8&v=4) ](/Pzixel)
C++_Classes_Templates/15079_489_0.txt
Copy link
C++_Classes_Templates/1157_122_0.txt
0 replies
C++_Classes_Templates/Constexprlikekeyword_21_0.txt
![](https://www.codeproject.com/script/Ratings/Images/star-empty-md.png)
C++_Classes_Templates/1157_59_0.txt
So I have a proposal: make C# respect ~~` System.ComponentModel.PureAttribute ` ~~ ` System.Diagnostics.Contracts.PureAttribute ` (or similar), and add this attribute itself if methods do not mutate state (I.e. write to variables, with the exception of constructors, or call other non-pure methods). The advantage here i...
C++_Classes_Templates/1157_302_0.txt
0 replies
C++_Classes_Templates/15079_293_0.txt
[ @eyalsk ](https://github.com/eyalsk) That would be the responsability of the runtime, therefore they have to be marked as that.
C++_Classes_Templates/1157_190_0.txt
Probably not. I've just always assumed pure functions have to be static without giving much thought to why.
C++_Classes_Templates/Constexprlikekeyword_9_0.txt
[ ![Home](https://www.codeproject.com/App_Themes/CodeProject/Img/logo250x135.gif) ](/)
C++_Classes_Templates/Constexprlikekeyword_0_0.txt
![Click here to Skip to main content](https://www.codeproject.com/images/t.gif)
C++_Classes_Templates/1157_103_0.txt
[ ![](https://avatars.githubusercontent.com/u/10102290?s=64&v=4) HaloFour ](/HaloFour) Nov 29, 2017
C++_Classes_Templates/15079_111_0.txt
###
C++_Classes_Templates/C++_Classes_7_3.txt
or "cpp/language/constructor") [ Default member initializer ](/w/cpp/language/data_members#Member_initialization "cpp/language/data members") (C++11) [ ` friend ` specifier ](/w/cpp/language/friend "cpp/language/friend") [ ` explicit ` specifier ](/w/cpp/language/explicit "cpp/language/explicit") [ Converting c...
C++_Classes_Templates/15079_167_0.txt
All reactions
C++_Classes_Templates/15079_14_0.txt
Resources
C++_Classes_Templates/1157_222_0.txt
What rules we need to define to allow this as a pure function? [ dotnet/roslyn#7561 (comment) ](https://github.com/dotnet/roslyn/issues/7561#issuecomment-166742053)
C++_Classes_Templates/15079_325_0.txt
Author
C++_Classes_Templates/15079_58_0.txt
Labels