Re: Expanding CTFE code during compilation

2022-07-23 Thread Azi Hassan via Digitalmars-d-learn
On Saturday, 23 July 2022 at 00:56:39 UTC, Steven Schveighoffer wrote: On 7/22/22 3:22 PM, Azi Hassan wrote: Oh, interesting syntax. I was thinking something along the lines of ```D template printEnum(...) {     version(debug) {     ... // everything we already did     } else {   

Re: Expanding CTFE code during compilation

2022-07-22 Thread Azi Hassan via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 14:11:52 UTC, Dennis wrote: On Wednesday, 20 July 2022 at 00:33:06 UTC, Azi Hassan wrote: Where did you find it though ? I checked dmd --help and man dmd before making this thread, but to no avail. It was implemented as an internal debugging tool, not a documente

Re: Expanding CTFE code during compilation

2022-07-22 Thread Azi Hassan via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 01:15:44 UTC, Steven Schveighoffer wrote: On 7/19/22 8:57 PM, Steven Schveighoffer wrote: There's a slight bloat in the compiler symbol table when  but other than that it should be effective. Obviously I didn't finish that thought... "when `-debug` isn't used on

Re: Expanding CTFE code during compilation

2022-07-19 Thread Azi Hassan via Digitalmars-d-learn
On Tuesday, 19 July 2022 at 22:41:43 UTC, Steven Schveighoffer wrote: On 7/19/22 5:43 PM, Azi Hassan wrote: Just in case this is a consequence of the XY problem, the reason why I'm looking for this is to make sure that the code I wrote did evaluate to what I'm expecting it to. Right now I do

Re: Expanding CTFE code during compilation

2022-07-19 Thread Azi Hassan via Digitalmars-d-learn
On Tuesday, 19 July 2022 at 22:27:56 UTC, Dennis wrote: On Tuesday, 19 July 2022 at 21:43:01 UTC, Azi Hassan wrote: I'm wondering if the offers has the option of executing the parts that can be evaluated at compile time and then replacing them with the result of this evaluation. Try the `-vcg

Expanding CTFE code during compilation

2022-07-19 Thread Azi Hassan via Digitalmars-d-learn
Hello, Apologies in advance if this has been asked before. I can't find the right words to express what I'm looking for, but essentially, I'm wondering if the offers has the option of executing the parts that can be evaluated at compile time and then replacing them with the result of this eva

Re: enforce (i > 0) for i = int.min does not throw

2018-01-31 Thread Azi Hassan via Digitalmars-d-learn
On Saturday, 27 January 2018 at 14:13:49 UTC, kdevel wrote: I would expect this code enforce3.d --- import std.exception; void main () { int i = int.min; enforce (i > 0); } --- to throw an "Enforcement failed" exception, but it doesn't: $ dmd enforce3.d $ ./enforce3 [nothing] I wonder

Re: Struct initialization syntax

2018-01-20 Thread Azi Hassan via Digitalmars-d-learn
On Thursday, 18 January 2018 at 03:50:15 UTC, arturg wrote: On Wednesday, 17 January 2018 at 17:37:07 UTC, H. S. Teoh wrote: On Wed, Jan 17, 2018 at 05:31:03PM +, Azi Hassan via Digitalmars-d-learn wrote: The D tour for structs uses a syntax similar to that of C++ in order to initialize a

Struct initialization syntax

2018-01-17 Thread Azi Hassan via Digitalmars-d-learn
The D tour for structs uses a syntax similar to that of C++ in order to initialize a Person struct : Person p(30, 180). Is this syntax supported in D ? Running that part of the code neither works on the playground nor on my machine (dmd v2.076.0).

Re: AssocArray to string is ok,but how to get the AssocArray from string? Thanks

2017-12-12 Thread Azi Hassan via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 17:32:15 UTC, Frank Like wrote: Hi,everyone, who can help me,about the "AssocArray to string is ok,but how to get the AssocArray from string? ". For example: SysTime[][string] AATimes; AATimes["a1"] =[SysTime(DateTime(2017, 1, 1, 12, 33, 33)),SysTime(DateTime(

Re: Get pointer or reference of an element in Array(struct)

2017-12-09 Thread Azi Hassan via Digitalmars-d-learn
On Saturday, 9 December 2017 at 06:46:27 UTC, Arun Chandrasekaran wrote: On Saturday, 9 December 2017 at 06:38:46 UTC, anonymous wrote: On Saturday, 9 December 2017 at 06:15:16 UTC, Arun Chandrasekaran wrote: Is there a way to get the pointer or reference of an element in Array(T)? [...]

Re: What the hell is wrong with D?

2017-09-20 Thread Azi Hassan via Digitalmars-d-learn
A general rule of thumb when it comes to operator precedence is that when in doubt, add parenthesis. On Wednesday, 20 September 2017 at 02:16:16 UTC, EntangledQuanta wrote: Your an idiot, Your Huh.

Re: Binary serialization of a struct

2017-09-16 Thread Azi Hassan via Digitalmars-d-learn
On Saturday, 16 September 2017 at 03:30:51 UTC, Joseph wrote: Are there any simple direct serialization libraries where I can mark elements of a class or struct that I want serialized with an attribute and it will take care of all the rest(including recursive structures, arrays, etc) then deser

Re: Ranges seem awkward to work with

2017-09-12 Thread Azi Hassan via Digitalmars-d-learn
On Tuesday, 12 September 2017 at 01:13:29 UTC, Hasen Judy wrote: Now, a lot of library functions seem to expect ranges as inputs and return ranges as output. Unless I'm mistaken, it was done on purpose to reduce the amount of memory allocations in the standard library so that it becomes @nogc

Re: Array Printing

2017-09-12 Thread Azi Hassan via Digitalmars-d-learn
On Tuesday, 12 September 2017 at 06:29:53 UTC, Vino.B wrote: Hi All, Request your help in printing the below array output as per the below required output Array Output: ["C:\\Temp\\TEST2\\BACKUP\\dir1", "34", "C:\\Temp\\TEST2\\BACKUP\\dir2", "36", "C:\\Temp\\TEST3\\BACKUP\\dir1", "69"] ["C

Re: Performance Issue

2017-09-06 Thread Azi Hassan via Digitalmars-d-learn
On Wednesday, 6 September 2017 at 18:21:44 UTC, Azi Hassan wrote: I tried to create a similar file structure on my Linux machine. Here's the result of ls -R TEST1: TEST1: BACKUP ... Upon further inspection it looks like I messed up the output. [31460] - Array 1 for folder 1(all files in Fol

Re: Performance Issue

2017-09-06 Thread Azi Hassan via Digitalmars-d-learn
On Wednesday, 6 September 2017 at 15:11:57 UTC, Vino.B wrote: On Wednesday, 6 September 2017 at 14:38:39 UTC, Vino.B wrote: Hi Azi, The required out is like below [31460] - Array 1 for folder 1(all files in Folder 1) of the FS C:\\Temp\\TEST1\\BACKUP [138] - Array 2 for folder 2(all fi

Re: Performance Issue

2017-09-06 Thread Azi Hassan via Digitalmars-d-learn
On Wednesday, 6 September 2017 at 08:10:35 UTC, Vino.B wrote: in the next line of the code i say to list only folders that are greater than 10 Mb but this now is listing all folder (folder whose size is less than 10 MB are getting listed, not sure why. Is the size in GB ? If so, then subdirTo

Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Azi Hassan via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 12:38:54 UTC, Ky-Anh Huynh wrote: Hi, I read line from STDIN , and strip them [code] auto line_st = line.strip(); [/code] However, I can't use result in another format routine. Assume my input line is "foobar": [code] writeln("Stripped line is %s", line_st);

Struct with float members in betterC

2017-09-05 Thread Azi Hassan via Digitalmars-d-learn
Hi, I'm trying to create the following struct in betterC but I keep getting undefined reference errors when I try to compile the code : import core.stdc.stdio; struct Foo { float x; float y; float z; }; extern(C) int main(int argc, char** argv) { /*auto foo =

Re: Performance Issue

2017-09-05 Thread Azi Hassan via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 09:44:09 UTC, Vino.B wrote: Hi, The below code is consume more memory and slower can you provide your suggestion on how to over come these issues. You can start by dropping the .array conversions after dirEntries. That way your algorithm will become lazy (as

Re: Using closure causes GC allocation

2017-09-04 Thread Azi Hassan via Digitalmars-d-learn
On Monday, 4 September 2017 at 05:45:18 UTC, Vino.B wrote: In order to resolve the issue "Using closure causes GC allocation" it was stated that we need to use delegates Alternatively you can drop the functional style and use a foreach loop that doesn't require delegates, but you'd still nee

Re: Returning multiple values from a function

2017-09-04 Thread Azi Hassan via Digitalmars-d-learn
On Monday, 4 September 2017 at 09:22:25 UTC, Vino.B wrote: Output : 1 2 ["C:\\Temp\\TEAM1\\BACKUP", "C:\\Temp\\TEAM2\\ARCHIVE"] Required Output: Test1 = 1 Test2 = 2 Path = ["C:\\Temp\\TEAM1\\BACKUP", "C:\\Temp\\TEAM2\\ARCHIVE"] From, Vino.B If you just need it to be displayed then you can add

Re: -betterC not working

2017-09-02 Thread Azi Hassan via Digitalmars-d-learn
On Friday, 1 September 2017 at 22:13:53 UTC, SrMordred wrote: On Wednesday, 30 August 2017 at 23:12:07 UTC, SrMordred wrote: On Wednesday, 30 August 2017 at 22:45:27 UTC, Adam D. Ruppe wrote: On Wednesday, 30 August 2017 at 22:18:07 UTC, SrMordred wrote: DMD64 D Compiler v2.075.1 -betterC as

Re: Help required on Array appender

2017-09-02 Thread Azi Hassan via Digitalmars-d-learn
On Saturday, 2 September 2017 at 12:54:48 UTC, Nicholas Wilson wrote: If you're wanting to use appender just make an appender and replace the ~= to calls to appender.put(data); Just making Subdata an Appender!(string[][]) (or Appender!(Tuple!(string, string)[])) is enough since it already o