Re: How to use ".stringof" to get the value of a variable and not the name of the variable (identifier) itself?

2023-10-10 Thread Dennis via Digitalmars-d-learn
On Monday, 9 October 2023 at 16:33:32 UTC, rempas wrote: However, in my example, "stringof" returns the character "i" itself and turns that into a string instead of getting its actual value (number). The result of `.stringof` is implementation defined, it can be used for debugging but don't m

Re: How to use ".stringof" to get the value of a variable and not the name of the variable (identifier) itself?

2023-10-10 Thread Hipreme via Digitalmars-d-learn
On Monday, 9 October 2023 at 18:25:15 UTC, rempas wrote: On Monday, 9 October 2023 at 17:42:48 UTC, Imperatorn wrote: You could just add your own int to string I guess? That will be a good idea! I'll do it in the future if that is the case, as it's not important, and I want to finish my job.

Re: How to use ".stringof" to get the value of a variable and not the name of the variable (identifier) itself?

2023-10-10 Thread rempas via Digitalmars-d-learn
On Monday, 9 October 2023 at 22:49:11 UTC, Salih Dincer wrote: Great masters generally warn to stay away from stringof. Please do not use it as much as possible. The following code snippet will be useful to you: ```d alias CN = __traits(allMembers, CardinalNumbers); static foreach(i; CN) {

Re: How to use ".stringof" to get the value of a variable and not the name of the variable (identifier) itself?

2023-10-10 Thread rempas via Digitalmars-d-learn
On Tuesday, 10 October 2023 at 05:32:52 UTC, Imperatorn wrote: If count < 10 then why not just ```d import std; static foreach(c; "0123456789") {  mixin(create_fn!(c)); } enum create_fn(char num) = ` auto function_`~ num ~`() => "Hello from function `~ num ~`

Re: How to use ".stringof" to get the value of a variable and not the name of the variable (identifier) itself?

2023-10-10 Thread rempas via Digitalmars-d-learn
On Tuesday, 10 October 2023 at 11:45:25 UTC, Dennis wrote: The result of `.stringof` is implementation defined, it can be used for debugging but don't make your program's semantics depend on the output of it. ... ... ...That being said, this trick can be used to convert an integer to string

Re: How to use ".stringof" to get the value of a variable and not the name of the variable (identifier) itself?

2023-10-10 Thread rempas via Digitalmars-d-learn
On Tuesday, 10 October 2023 at 11:46:38 UTC, Hipreme wrote: My engine has its own implementation of toString(long), which does not have dependency with the C runtime: https://github.com/MrcSnm/HipremeEngine/blob/master/modules/util/source/hip/util/conv.d#L180C1-L208C2 I have reimplemented the

Re: How to use ".stringof" to get the value of a variable and not the name of the variable (identifier) itself?

2023-10-10 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 10 October 2023 at 13:55:44 UTC, rempas wrote: On Tuesday, 10 October 2023 at 11:46:38 UTC, Hipreme wrote: My engine has its own implementation of toString(long), which does not have dependency with the C runtime: https://github.com/MrcSnm/HipremeEngine/blob/master/modules/util/sou

Re: Need help with 128bit integer ucent boolfilter

2023-10-10 Thread Per Nordlöw via Digitalmars-d-learn
On Friday, 6 October 2023 at 13:44:14 UTC, d007 wrote: I am search for a fast 128bit integer ucent boolfilter, used for server side duplicate request filter. Is 128bit boolfilter a doable thing? or it will not work or will be much more slow compare to 64 bit solution? Can you describe or gi

Re: Define a new custom operator in D Language.

2023-10-10 Thread Jesse Phillips via Digitalmars-d-learn
On Monday, 2 October 2023 at 18:34:13 UTC, BoQsc wrote: --- **This might lead to less gaps between math formulas and the implementation.** Or at the very least would allow to define a formula in the source code for further implementation and introduce some consistency. You could write a pa

is the array literal in a loop stack or heap allocated?

2023-10-10 Thread mw via Digitalmars-d-learn
Hi, I want to confirm: in the following loop, is the array literal `a` vs. `b` stack or heap allocated? and how many times? void main() { int[2] a; int[] b; int i; While(++i <=100) { a = [i, i+1]; // array literal b = [i, i+1]; } } Thanks.

Re: is the array literal in a loop stack or heap allocated?

2023-10-10 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 11, 2023 at 02:54:53AM +, mw via Digitalmars-d-learn wrote: > Hi, > > I want to confirm: in the following loop, is the array literal `a` vs. > `b` stack or heap allocated? and how many times? > > void main() { > > int[2] a; This is stack-allocated. Once per call to the function.

Re: is the array literal in a loop stack or heap allocated?

2023-10-10 Thread ryuukk_ via Digitalmars-d-learn
On Wednesday, 11 October 2023 at 02:54:53 UTC, mw wrote: Hi, I want to confirm: in the following loop, is the array literal `a` vs. `b` stack or heap allocated? and how many times? void main() { int[2] a; int[] b; int i; While(++i <=100) { a = [i, i+1]; // array literal b = [i, i+1];

Re: is the array literal in a loop stack or heap allocated?

2023-10-10 Thread mw via Digitalmars-d-learn
On Wednesday, 11 October 2023 at 03:15:30 UTC, H. S. Teoh wrote: On Wed, Oct 11, 2023 at 02:54:53AM +, mw via Digitalmars-d-learn wrote: Hi, I want to confirm: in the following loop, is the array literal `a` vs. `b` stack or heap allocated? and how many times? void main() { int[2] a;

Re: is the array literal in a loop stack or heap allocated?

2023-10-10 Thread Imperatorn via Digitalmars-d-learn
On Wednesday, 11 October 2023 at 02:54:53 UTC, mw wrote: Hi, I want to confirm: in the following loop, is the array literal `a` vs. `b` stack or heap allocated? and how many times? void main() { int[2] a; int[] b; int i; While(++i <=100) { a = [i, i+1]; // array literal b = [i, i+1];