Re: Run-time setting of immutable variable?

2021-09-02 Thread Ali Çehreli via Digitalmars-d-learn
On 9/2/21 9:01 AM, DLearner wrote: Suppose there is a variable that is set once per run, and is (supposed) never to be altered again. An accessor function can be a solution, which supports your other comment about data potentially mutating by other means: // Assume these are in a module // v

Re: Run-time setting of immutable variable?

2021-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/21 1:17 PM, DLearner wrote: I am looking for a mutable Arr but would like an immutable ArrPtr. Then you want const not immutable. Here is the reason: ```d void main() { int x = 5; immutable int *ptr = cast(immutable int *)&x; assert(*ptr == 5); // ok x = 6; assert(

Re: template parameters

2021-09-02 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 02, 2021 at 02:28:23PM -0700, Charles Hixson via Digitalmars-d-learn wrote: [...] > -- > Javascript is what you use to allow third part programs you don't know > anything about and doing you know not what to run on your computer. ROFL! I'm st^Wborrowing this for my quotes file. ;-)

Re: template parameters

2021-09-02 Thread Charles Hixson via Digitalmars-d-learn
Thanks.  See below for what I did. On 8/29/21 5:05 PM, Ali Çehreli via Digitalmars-d-learn wrote: On 8/29/21 3:31 PM, Charles Hixson wrote: > Thanks.  I going to have to study: > > enum supportsCall = isIntegral!(typeof(T.init.%s())); > > > for awhile to make any sense of that, but it looks like

Re: Dustmite and linking error

2021-09-02 Thread Vladimir Panteleev via Digitalmars-d-learn
On Thursday, 2 September 2021 at 11:20:18 UTC, Vladimir Panteleev wrote: One way to get a very rough estimate is to take the square of the current reduction (.reduced directory), and divide it by the square of the original source. I meant the square of the size of the respective directory. (b

Re: Run-time setting of immutable variable?

2021-09-02 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 02, 2021 at 05:17:15PM +, DLearner via Digitalmars-d-learn wrote: [...] > The following clean-compiled and produced the expected result: > ``` > ubyte[10] Arr; > > immutable void* ArrPtr; > shared static this() { > ArrPtr = cast(immutable void*)(&Arr[0]

Re: Documentation generator is not working

2021-09-02 Thread Vinod K Chandran via Digitalmars-d-learn
On Thursday, 2 September 2021 at 17:34:59 UTC, Adam D Ruppe wrote: Anything after -run goes to your program not the compiler. Args to the compiler must be before -run. Thanks for the reply. Got the point now. :)

Re: Documentation generator is not working

2021-09-02 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 2 September 2021 at 17:20:55 UTC, Vinod K Chandran wrote: "dmd -run test.d -D" Anything after -run goes to your program not the compiler. Args to the compiler must be before -run.

Re: Run-time setting of immutable variable?

2021-09-02 Thread jfondren via Digitalmars-d-learn
On Thursday, 2 September 2021 at 17:17:15 UTC, DLearner wrote: Surely there is no inconsistency - at run time the array is in a fixed place, so ArrPtr is (or at least should be) a constant, but the contents of the array can vary as the program runs. In the case of `immutable(T)* ArrPtr`, the

Re: Run-time setting of immutable variable?

2021-09-02 Thread Kagamin via Digitalmars-d-learn
If you want only address, you can keep it as size_t: ubyte[10] Arr; immutable size_t Address; static this() { Address = cast(size_t)(&Arr[0]); }

Re: Documentation generator is not working

2021-09-02 Thread Vinod K Chandran via Digitalmars-d-learn
On Thursday, 2 September 2021 at 16:26:19 UTC, jfondren wrote: What commands are you running? What you describe doing, works: ``` $ dmd -D file $ w3m -dump file.html|grep -A1 function A sample function. Let's check what we will get in documentation. abc - A simple string $ rm -fv

Re: Run-time setting of immutable variable?

2021-09-02 Thread DLearner via Digitalmars-d-learn
On Thursday, 2 September 2021 at 16:46:46 UTC, Steven Schveighoffer wrote: On 9/2/21 12:01 PM, DLearner wrote: Suppose there is a variable that is set once per run, and is (supposed) never to be altered again.  However, the value to which it is set is not known at compile time. Example below,

Re: Run-time setting of immutable variable?

2021-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/21 12:01 PM, DLearner wrote: Suppose there is a variable that is set once per run, and is (supposed) never to be altered again.  However, the value to which it is set is not known at compile time. Example below, variable is 'ArrPtr'; ``` ubyte[10] Arr; // immutable void* ArrPtr; void* A

Re: Documentation generator is not working

2021-09-02 Thread jfondren via Digitalmars-d-learn
On Thursday, 2 September 2021 at 16:20:32 UTC, Vinod K Chandran wrote: Hi all, I am playing with ddoc. I wrote this code-- ```d import std.stdio : log = writeln; void main() { log("Experimenting with dDoc"); } /// A sample function. /// Let's check what we will get in documentation. /// abc

Documentation generator is not working

2021-09-02 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I am playing with ddoc. I wrote this code-- ```d import std.stdio : log = writeln; void main() { log("Experimenting with dDoc"); } /// A sample function. /// Let's check what we will get in documentation. /// abc - A simple string void sample(string abc) {log(abc);} ``` And then, com

Re: Run-time setting of immutable variable?

2021-09-02 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 02, 2021 at 04:01:19PM +, DLearner via Digitalmars-d-learn wrote: > Suppose there is a variable that is set once per run, and is > (supposed) never to be altered again. However, the value to which it > is set is not known at compile time. This is the classic use case of `immutabl

Run-time setting of immutable variable?

2021-09-02 Thread DLearner via Digitalmars-d-learn
Suppose there is a variable that is set once per run, and is (supposed) never to be altered again. However, the value to which it is set is not known at compile time. Example below, variable is 'ArrPtr'; ``` ubyte[10] Arr; // immutable void* ArrPtr; void* ArrPtr; void main() { ArrPtr = ca

Re: Dustmite and linking error

2021-09-02 Thread Vladimir Panteleev via Digitalmars-d-learn
On Thursday, 2 September 2021 at 11:04:12 UTC, JG wrote: Hi, We hit a linking error (after upgrading to dub 1.26.0). I thought I would try to use dustmite to create a reduced error test case. One week later it is still running (depth 22). I don't suppose there is anyway of determining when it

Re: Dustmite and linking error

2021-09-02 Thread jfondren via Digitalmars-d-learn
On Thursday, 2 September 2021 at 11:04:12 UTC, JG wrote: Hi, We hit a linking error (after upgrading to dub 1.26.0). I thought I would try to use dustmite to create a reduced error test case. One week later it is still running (depth 22). I don't suppose there is anyway of determining when it

Dustmite and linking error

2021-09-02 Thread JG via Digitalmars-d-learn
Hi, We hit a linking error (after upgrading to dub 1.26.0). I thought I would try to use dustmite to create a reduced error test case. One week later it is still running (depth 22). I don't suppose there is anyway of determining when it will finish?