Re: best/proper way to declare constants ?

2021-08-05 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 05, 2021 at 03:09:13PM +, someone via Digitalmars-d-learn wrote: > On Thursday, 5 August 2021 at 10:28:00 UTC, Steven Schveighoffer wrote: > > > H.S. Teoh, I know you know better than this ;) None of this is > > necessary, you just need `rtValue` for both runtime and CTFE (and > >

Generating C Headers From D Code

2021-08-05 Thread Jack Stouffer via Digitalmars-d-learn
I need to generate plain C99 .h files from a D module's extern(C) declarations, so that I can link a DMD generated .o file with a C code base. Are there any automated tools which do this? I know the compiler has C++ header generation, and there's tons of tools which exist for importing C

Re: best/proper way to declare constants ?

2021-08-05 Thread jfondren via Digitalmars-d-learn
On Thursday, 5 August 2021 at 16:06:58 UTC, someone wrote: So if we are talking AA-arrays at compile-time only there should be nothing wrong with the following code ... right ? ... private enum pudtLocations = [ r"BUE"d : structureLocation(r"arg"d, r"Buenos Aires"d, r"ART"d), r"GRU"d :

Re: Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-05 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 5 August 2021 at 10:43:01 UTC, wjoe wrote: Could you elaborate on ```version(assert)``` a bit more, please ? Like I compiled with ```-release, -g``` and without the 2 options but the ```assert``` branch was always taken. Could it be that ```-unittest``` has something to do

Re: best/proper way to declare constants ?

2021-08-05 Thread someone via Digitalmars-d-learn
On Thursday, 5 August 2021 at 10:28:00 UTC, Steven Schveighoffer wrote: H.S. Teoh, I know you know better than this ;) None of this is necessary, you just need `rtValue` for both runtime and CTFE (and compile time parameters)! Now, the original question is about *associative arrays*, which

Re: __traits() to get parameter details only ? ... hasMember looks up everything within

2021-08-05 Thread Ali Çehreli via Digitalmars-d-learn
On 8/4/21 7:21 PM, someone wrote: > somewhere I read > Ali saying there's nothing wrong implementing properties the old-way via > functions because @property has nothing special about it but I can't > state where I read what I am stating so take it with a grain of salt. As I understand it,

Re: best/proper way to declare constants ?

2021-08-05 Thread someone via Digitalmars-d-learn
On Thursday, 5 August 2021 at 15:26:33 UTC, H. S. Teoh wrote: On Thu, Aug 05, 2021 at 03:09:13PM +, someone via Digitalmars-d-learn wrote: On Thursday, 5 August 2021 at 10:28:00 UTC, Steven Schveighoffer wrote: > H.S. Teoh, I know you know better than this ;) None of this > is necessary,

Re: Please verify: Traceinfo gone

2021-08-05 Thread frame via Digitalmars-d-learn
On Tuesday, 27 July 2021 at 05:14:22 UTC, frame wrote: On Sunday, 25 July 2021 at 11:17:26 UTC, frame wrote: No further response to this, so I made a ticket: https://issues.dlang.org/show_bug.cgi?id=22181

Re: Name Mangling & its representation of D types

2021-08-05 Thread NonNull via Digitalmars-d-learn
On Wednesday, 4 August 2021 at 02:01:54 UTC, Mathias LANG wrote: Yes, because D is a nominal type system, using the FQN of the symbol is enough. [...] Mangling is altered by `extern(LANG)` (where LANG is one of `C`, `C++`, `Objective-C`, `System`, `D`), or `pragma(mangle)`. All useful

Re: __traits() to get parameter details only ? ... hasMember looks up everything within

2021-08-05 Thread someone via Digitalmars-d-learn
On Thursday, 5 August 2021 at 15:23:24 UTC, Ali Çehreli wrote: As I understand it, @property is discouraged by the community. That's what I say here: http://ddili.org/ders/d.en/property.html#ix_property.@property I knew I have read it somewhere ... thanks for the clarification Ali !

Re: Generating C Headers From D Code

2021-08-05 Thread Tejas via Digitalmars-d-learn
On Thursday, 5 August 2021 at 17:02:33 UTC, Tejas wrote: On Thursday, 5 August 2021 at 16:28:35 UTC, Jack Stouffer wrote: [...] I also can't find anything... until someone else comes with a better answer, maybe you can do this: Use the ```-H``` compiler flag to generate ```.di``` files.

Re: Generating C Headers From D Code

2021-08-05 Thread Tejas via Digitalmars-d-learn
On Thursday, 5 August 2021 at 16:28:35 UTC, Jack Stouffer wrote: I need to generate plain C99 .h files from a D module's extern(C) declarations, so that I can link a DMD generated .o file with a C code base. Are there any automated tools which do this? I know the compiler has C++ header

Re: best/proper way to declare constants ?

2021-08-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/5/21 11:09 AM, someone wrote: On Thursday, 5 August 2021 at 10:28:00 UTC, Steven Schveighoffer wrote: H.S. Teoh, I know you know better than this ;) None of this is necessary, you just need `rtValue` for both runtime and CTFE (and compile time parameters)! Now, the original question is

Re: best/proper way to declare constants ?

2021-08-05 Thread someone via Digitalmars-d-learn
On Thursday, 5 August 2021 at 16:24:21 UTC, jfondren wrote: On Thursday, 5 August 2021 at 16:06:58 UTC, someone wrote: So if we are talking AA-arrays at compile-time only there should be nothing wrong with the following code ... right ? ... private enum pudtLocations = [ r"BUE"d :

Re: best/proper way to declare constants ?

2021-08-05 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 05, 2021 at 04:53:38PM +, someone via Digitalmars-d-learn wrote: [...] > I already assumed that loading the data from file is a goner. > > So this leaves me with two choices: > > - keep the code as it is incurring higher-than expected > compilation-time: this is solely used in a

Re: best/proper way to declare constants ?

2021-08-05 Thread someone via Digitalmars-d-learn
On Thursday, 5 August 2021 at 17:12:13 UTC, H. S. Teoh wrote: [...] I'd say if the performance hit isn't noticeably bad right now, don't worry too much about it. You can always replace it later. One thing I really like about D is how easily refactorable D code tends to be. If you structure

Re: best/proper way to declare constants ?

2021-08-05 Thread norm via Digitalmars-d-learn
On Thursday, 5 August 2021 at 01:14:26 UTC, H. S. Teoh wrote: On Thu, Aug 05, 2021 at 12:47:06AM +, someone via Digitalmars-d-learn wrote: [...] 1) If the constant is a POD (int, float, etc.), use: enum myValue = ...; 2) If the constant is a string or some other array:

Re: best/proper way to declare constants ?

2021-08-05 Thread Ali Çehreli via Digitalmars-d-learn
On 8/5/21 5:11 PM, someone wrote: > Although I have very little experience with D, I second this: > refactoring, even huge refactors, proved to be far more straightforward > than I expected. May I humbly suggest names like Location instead of structureLocation to make refactoring even more

Re: best/proper way to declare constants ?

2021-08-05 Thread someone via Digitalmars-d-learn
On Friday, 6 August 2021 at 04:57:02 UTC, Ali Çehreli wrote: On 8/5/21 5:11 PM, someone wrote: > Although I have very little experience with D, I second this: > refactoring, even huge refactors, proved to be far more straightforward > than I expected. May I humbly suggest names like Location

Re: best/proper way to declare constants ?

2021-08-05 Thread someone via Digitalmars-d-learn
On Thursday, 5 August 2021 at 20:50:38 UTC, Steven Schveighoffer wrote: I mean eventually AAs that are reasonably available at compile time, even though the structure is determined by the runtime, should be available at compile time. This allows them to be as usable with static immutable as

Re: Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-05 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 5 August 2021 at 09:18:08 UTC, wjoe wrote: If it's to be determined whether or not the code is being compiled in debug or release mode, i.e. e.g. the dmd ```-release``` You should never use the -release flag. It should be renamed to "-enable-security-holes" since that's what it

Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-05 Thread wjoe via Digitalmars-d-learn
If it's to be determined whether or not the code is being compiled in debug or release mode, i.e. e.g. the dmd ```-release``` or ```-g``` options, which version identifier is supposed to be used ? There's no ```release``` identifier and ```-debug``` switch and ```debug()``` condition are

Re: Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-05 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 5 August 2021 at 09:18:08 UTC, wjoe wrote: If it's to be determined whether or not the code is being compiled in debug or release mode, i.e. e.g. the dmd ```-release``` or ```-g``` options, which version identifier is supposed to be used ? There's no ```release``` identifier and

Re: best/proper way to declare constants ?

2021-08-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/4/21 11:20 PM, H. S. Teoh wrote: On Thu, Aug 05, 2021 at 01:39:42AM +, someone via Digitalmars-d-learn wrote: [...] What happens in the following case ? public immutable enum gudtLocations = [ r"BUE"d : structureLocation(r"arg"d, r"Buenos Aires"d, r"ART"d), r"GRU"d :

Re: Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-05 Thread wjoe via Digitalmars-d-learn
On Thursday, 5 August 2021 at 10:08:12 UTC, Mike Parker wrote: On Thursday, 5 August 2021 at 09:18:08 UTC, wjoe wrote: Given that we have `version(assert)` and `version(D_NoBoundsChecks)`, it probably makes sense to also have equivalents to test if contracts are enabled, or if bounds checking