Re: Garbage Collection Issue

2020-06-01 Thread a11e99z via Digitalmars-d-learn
On Sunday, 31 May 2020 at 16:57:06 UTC, Steven Schveighoffer wrote: I can't imagine much of druntime working at all without TLS. Indeed, it is a requirement these days. TLS is evil for async/await when any thread can execute any fiber (case where fiber tied to thread is wrong/dead version

Re: want to know precise GC benchmarks

2019-10-02 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 2 October 2019 at 06:41:28 UTC, Rainer Schuetze wrote: thanks for the detailed answer

Re: want to know precise GC benchmarks

2019-10-01 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 1 October 2019 at 16:12:18 UTC, a11e99z wrote: does anybody some kind of benchmark to test conservative and precise GC? precise GC is better or not? is STW improving? and another question about GC and app parameters: program.exe “–DRT-gcopt=gc:precise parallel:4”

want to know precise GC benchmarks

2019-10-01 Thread a11e99z via Digitalmars-d-learn
does anybody some kind of benchmark to test conservative and precise GC? precise GC is better or not? is STW improving?

Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-25 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 25 September 2019 at 12:04:16 UTC, Ron Tarrant wrote: On Wednesday, 25 September 2019 at 11:50:58 UTC, a11e99z wrote: On Wednesday, 25 September 2019 at 11:46:04 UTC, Ron Tarrant wrote: Hi y'all, What I'm looking for is a system for bundling dlang apps and their dependencies

Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-25 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 25 September 2019 at 11:46:04 UTC, Ron Tarrant wrote: Hi y'all, I've been Googling how to do this, but coming up with nothing definitive. Are there any articles for how to do this for: Windows? Linux? other UNIX-alike OSs? UPX? https://en.wikipedia.org/wiki/UPX

Re: How to force an array literal into a read-only data segment?

2019-09-12 Thread a11e99z via Digitalmars-d-learn
On Thursday, 12 September 2019 at 07:04:19 UTC, Max Samukha wrote: How to achieve the same for an array literal? The closest I could come: enum immutable(int[3]) _tmp = [1, 2, 3]; __gshared a = _tmp.ptr; Is it possible to force the array into rodata?

Re: LDC asm for int128

2019-09-10 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 10 September 2019 at 06:18:05 UTC, Newbie2019 wrote: I want to translate this c code into d (build with ldc), so I can use -flto and inline with other code. uint64_t _wymum(uint64_t A, uint64_t B){ __uint128_t r = A ; r *= B; return (r>>64)^r; } Do i need

Re: It there a way to get this to compile?

2019-09-09 Thread a11e99z via Digitalmars-d-learn
On Monday, 9 September 2019 at 19:08:17 UTC, WhatMeWorry wrote: struct FoundationPile { Card[] up;// all cards are face up on the Foundation } FoundationPile[4] foundations; static if(true) { int r = 2; int c = 40; static foreach(i ; foundations) { immutable string

Re: Throwing from a lambda isn't supported by the compiler

2019-09-09 Thread a11e99z via Digitalmars-d-learn
On Monday, 9 September 2019 at 09:14:08 UTC, Andre Pany wrote: I noticed, that I cannot throw from the lambda expression: Error: expression expected, not throw but have to use the longer syntax () {throw new Exception();} --- void foo(void function() e){} void main() { foo( () =>

Re: C++ vs D: Default param values and struct to array casting

2019-09-06 Thread a11e99z via Digitalmars-d-learn
On Friday, 6 September 2019 at 09:14:31 UTC, Andrew Edwards wrote: C++ allows the for following: struct Demo { float a, b, c, d; Demo() { a = b = c = d = 0.0f; } Demo(float _a, float _b, float _c, float _d) { a = _a; b = _b;

Re: How stdin.readf ignore space char?

2019-09-03 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 3 September 2019 at 13:25:30 UTC, lili wrote: On Tuesday, 3 September 2019 at 13:21:16 UTC, a11e99z wrote: On Tuesday, 3 September 2019 at 12:55:29 UTC, lili wrote: string d = "3.43.3 "; double a; double b; //formattedRead(d,"%f %f", , );

Re: How stdin.readf ignore space char?

2019-09-03 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 3 September 2019 at 12:55:29 UTC, lili wrote: Hi guys: input is two line, first line is a number n and second line is n float point number, e.g. 3 1.1 2.2 3.3 how use stdin.readf get all number. u can read array this way too auto darr = readln.split.map!(x

Re: How stdin.readf ignore space char?

2019-09-03 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 3 September 2019 at 12:55:29 UTC, lili wrote: Hi guys: input is two line, first line is a number n and second line is n float point number, e.g. 3 1.1 2.2 3.3 how use stdin.readf get all number. https://dlang.org/library/std/stdio/readf.html see example

Re: Deactivate windows MessageBox dialog on exception

2019-08-28 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 12:19:54 UTC, Andre Pany wrote: Hi, I call another process using function pipeShell and Redirect.all. import std; void main() { auto p = pipeShell("a.exe", Redirect.all); p.stdin.writeln("e1"); p.stdin.writeln("10"); p.stdin.writeln("e2");

Re: Deactivate windows MessageBox dialog on exception

2019-08-28 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 12:19:54 UTC, Andre Pany wrote: and try to use https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-seterrormode SEM_FAILCRITICALERRORS for mother process and child process will inherit it

Re: Deactivate windows MessageBox dialog on exception

2019-08-28 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 12:19:54 UTC, Andre Pany wrote: Hi, I call another process using function pipeShell and Redirect.all. In case the child process(also D application) throws an exception (str to int conversion exception), the child process shows a message box on windows.

Re: Sort Associative Array by Key

2019-08-28 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 27 August 2019 at 20:35:16 UTC, bachmeier wrote: On Tuesday, 27 August 2019 at 20:14:21 UTC, Machine Code wrote: It isn't really hard: It really is hard. foo.byPair.array.sort!((a, b) => a.key < b.key).map!(a => a.value); is a lot to digest for someone learning the language.

Re: Input/Output multiple values from function

2019-08-28 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 05:17:28 UTC, Jabari Zakiya wrote: On Wednesday, 28 August 2019 at 04:39:23 UTC, Mike Parker wrote: On Wednesday, 28 August 2019 at 04:19:49 UTC, Jabari Zakiya wrote: I have a function (say func1) that takes 1 input value (an integer number) and outputs 4 values

Re: stdin/stdout and flush

2019-08-27 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 27 August 2019 at 21:01:58 UTC, Andre Pany wrote: On Tuesday, 27 August 2019 at 20:45:44 UTC, a11e99z wrote: On Tuesday, 27 August 2019 at 20:09:34 UTC, Andre Pany wrote: "b" should send data in loop too, then "a" will work ok. do u still hack CodinGame? :)

Re: stdin/stdout and flush

2019-08-27 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 27 August 2019 at 21:28:05 UTC, a11e99z wrote: On Tuesday, 27 August 2019 at 21:01:58 UTC, Andre Pany wrote: On Tuesday, 27 August 2019 at 20:45:44 UTC, a11e99z wrote: On Tuesday, 27 August 2019 at 20:09:34 UTC, Andre Pany wrote: what result u expecting? then u send from "b"

Re: stdin/stdout and flush

2019-08-27 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 27 August 2019 at 21:01:58 UTC, Andre Pany wrote: On Tuesday, 27 August 2019 at 20:45:44 UTC, a11e99z wrote: On Tuesday, 27 August 2019 at 20:09:34 UTC, Andre Pany wrote: what result u expecting? u send from "b": e1 10 e2 9 "a" read it. 1st loop finished. then u send from "b"

Re: stdin/stdout and flush

2019-08-27 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 27 August 2019 at 20:09:34 UTC, Andre Pany wrote: This applications will be called by a second application: import std; void main() { auto p = pipeShell("a", Redirect.all); p.stdin.writeln("e1"); p.stdin.writeln("10"); p.stdin.writeln("e2"); p.stdin.writeln("9");

Re: Structure of Arrays vs Array of Structures

2019-08-26 Thread a11e99z via Digitalmars-d-learn
On Monday, 26 August 2019 at 09:58:30 UTC, Per Nordlöw wrote: On Monday, 26 August 2019 at 09:54:30 UTC, Per Nordlöw wrote: I have made some significant optimizations with regards to compilation performance at https://github.com/nordlow/phobos-next/blob/master/src/soa.d What is the

Re: .fflush() in stdio.d

2019-08-26 Thread a11e99z via Digitalmars-d-learn
On Monday, 26 August 2019 at 09:14:23 UTC, Jonathan M Davis wrote: On Sunday, August 25, 2019 11:59:08 PM MDT berni via - Jonathan M Davis OFFTOPIC: (dont have ur email. dont like emails cuz too officially and too long) (and dont want create new topic. this one probably solved/finished

Re: Sort Associative Array by Key

2019-08-25 Thread a11e99z via Digitalmars-d-learn
On Sunday, 25 August 2019 at 16:54:33 UTC, Samir wrote: Is there a way to output the values of an associative array based on the lexicographic order of the keys? For example, if foo = ["VXE":8, "BZP":5, "JLC":2], I'd like to output something like: 5 2 8 auto foo = ["VXE":8, "BZP":5,

Re: [Help!] Use two different assembly symbol in D, but they are same address.

2019-08-25 Thread a11e99z via Digitalmars-d-learn
On Sunday, 25 August 2019 at 13:43:42 UTC, a11e99z wrote: On Sunday, 25 August 2019 at 13:24:57 UTC, lili wrote: On Saturday, 24 August 2019 at 12:55:57 UTC, a11e99z wrote: and try to use any compiler DMD/LDC/GDC. maybe result will be that u want.

Re: [Help!] Use two different assembly symbol in D, but they are same address.

2019-08-25 Thread a11e99z via Digitalmars-d-learn
On Sunday, 25 August 2019 at 13:24:57 UTC, lili wrote: On Saturday, 24 August 2019 at 12:55:57 UTC, a11e99z wrote: On Saturday, 24 August 2019 at 12:16:34 UTC, lili wrote: On Saturday, 24 August 2019 at 12:09:19 UTC, a11e99z wrote: On Saturday, 24 August 2019 at 11:53:01 UTC, lili wrote:

Re: Merging two associative arrays

2019-08-24 Thread a11e99z via Digitalmars-d-learn
On Saturday, 24 August 2019 at 19:35:25 UTC, berni wrote: I've got two associative arrays and want to get a new one, which is created out of both of them: This works: string[int] a = [1:"one", 7:"seven"]; string[int] b = [5:"five", 9:"nine"]; string[int] tmp = a.dup; foreach (k,v;b) tmp[k] =

Re: [Help!] Use two different assembly symbol in D, but they are same address.

2019-08-24 Thread a11e99z via Digitalmars-d-learn
On Saturday, 24 August 2019 at 12:16:34 UTC, lili wrote: On Saturday, 24 August 2019 at 12:09:19 UTC, a11e99z wrote: On Saturday, 24 August 2019 at 11:53:01 UTC, lili wrote: [...] resb 8 just reserving 8 bytes not initializing it. probably u compare some garbage. sometimes it equals,

Re: [Help!] Use two different assembly symbol in D, but they are same address.

2019-08-24 Thread a11e99z via Digitalmars-d-learn
On Saturday, 24 August 2019 at 11:53:01 UTC, lili wrote: Hi: definition _vga_x and _vga_y symbol in asm, compile use nasm -f elf64 -o boot.o boot.asm [section .bss] ... [global _vga_x] _vga_x: resb 8 [global _vga_y] _vga_y: resb 8 and nm boot.o show

Re: D1: Trying to update Juno Library to 1.076

2019-08-23 Thread a11e99z via Digitalmars-d-learn
On Friday, 23 August 2019 at 17:50:52 UTC, jicman wrote: On Friday, 23 August 2019 at 17:18:55 UTC, a11e99z wrote: On Friday, 23 August 2019 at 17:03:24 UTC, jicman wrote: On Friday, 23 August 2019 at 16:49:07 UTC, a11e99z wrote: right now problem exists with linker/libs only, compiler see

Re: D1: Trying to update Juno Library to 1.076

2019-08-23 Thread a11e99z via Digitalmars-d-learn
On Friday, 23 August 2019 at 17:03:24 UTC, jicman wrote: On Friday, 23 August 2019 at 16:49:07 UTC, a11e99z wrote: right now problem exists with linker/libs only, compiler see all used VarXXX First of all, thanks for your patient support. to the above program, and still fails with the same

Re: D1: Trying to update Juno Library to 1.076

2019-08-23 Thread a11e99z via Digitalmars-d-learn
On Friday, 23 August 2019 at 16:09:16 UTC, jicman wrote: On Friday, 23 August 2019 at 16:02:38 UTC, a11e99z wrote: On Friday, 23 August 2019 at 16:00:00 UTC, a11e99z wrote: On Friday, 23 August 2019 at 14:02:36 UTC, jicman wrote: On Thursday, 22 August 2019 at 19:59:55 UTC, jicman wrote:

Re: D1: Trying to update Juno Library to 1.076

2019-08-23 Thread a11e99z via Digitalmars-d-learn
On Friday, 23 August 2019 at 16:00:00 UTC, a11e99z wrote: On Friday, 23 August 2019 at 14:02:36 UTC, jicman wrote: On Thursday, 22 August 2019 at 19:59:55 UTC, jicman wrote: cuz I tried compile app void main() { VARIANT a, b; VarCmp( , , 0, 0).writeln; } with DMD for x86/m32 & x64/m64 and I

Re: D1: Trying to update Juno Library to 1.076

2019-08-23 Thread a11e99z via Digitalmars-d-learn
On Friday, 23 August 2019 at 14:02:36 UTC, jicman wrote: On Thursday, 22 August 2019 at 19:59:55 UTC, jicman wrote: I think I have figured out what is going on. I will comeback, if I need more help, but I have to rewrite a few more functions. But, thanks for pointing out the pragma. That

Re: D1: Trying to update Juno Library to 1.076

2019-08-22 Thread a11e99z via Digitalmars-d-learn
On Thursday, 22 August 2019 at 16:59:03 UTC, jicman wrote: On Thursday, 22 August 2019 at 16:36:45 UTC, a11e99z wrote: On Thursday, 22 August 2019 at 16:34:52 UTC, a11e99z wrote: On Thursday, 22 August 2019 at 16:34:06 UTC, a11e99z wrote: On Thursday, 22 August 2019 at 16:07:00 UTC, jicman

Re: D1: Trying to update Juno Library to 1.076

2019-08-22 Thread a11e99z via Digitalmars-d-learn
On Thursday, 22 August 2019 at 16:34:52 UTC, a11e99z wrote: On Thursday, 22 August 2019 at 16:34:06 UTC, a11e99z wrote: On Thursday, 22 August 2019 at 16:07:00 UTC, jicman wrote: On Thursday, 22 August 2019 at 15:58:56 UTC, a11e99z wrote: case of string doesn't matter for Windows. I mean

Re: D1: Trying to update Juno Library to 1.076

2019-08-22 Thread a11e99z via Digitalmars-d-learn
On Thursday, 22 August 2019 at 16:34:06 UTC, a11e99z wrote: On Thursday, 22 August 2019 at 16:07:00 UTC, jicman wrote: On Thursday, 22 August 2019 at 15:58:56 UTC, a11e99z wrote: case of string doesn't matter for Windows. I mean for command lines (not in D code)

Re: D1: Trying to update Juno Library to 1.076

2019-08-22 Thread a11e99z via Digitalmars-d-learn
On Thursday, 22 August 2019 at 16:07:00 UTC, jicman wrote: On Thursday, 22 August 2019 at 15:58:56 UTC, a11e99z wrote: try to add pragma( lib, "OleAut32.lib" ) Thanks for the support, a11e99z. :-) I have, pragma(lib, "ole32.lib"); pragma(lib, "oleaut32.lib"); on that file. But I did go

Re: D1: Trying to update Juno Library to 1.076

2019-08-22 Thread a11e99z via Digitalmars-d-learn
On Thursday, 22 August 2019 at 15:55:48 UTC, jicman wrote: Greetings! I have been working on Juno for a long time with D1 version 1.046, and love it. But now, I want to update it to 1.076, the latest and greatest D1. I have fixed, what I think, were all of the problems. However, when I

Re: What is "dmd" Internal API, can I use it just like std Library Reference?

2019-08-20 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 20 August 2019 at 12:52:31 UTC, BoQsc wrote: Hello everyone, again, I had an idea that I want some colors in the output of Command Line (For Windows) and the Terminal (For Linux) yesterday was talks about terminal colors in IRC-channel: u can use VT-codes for changing colors:

Re: Can't add a const ubyte to a dynamic array of ubyte?

2019-08-20 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 20 August 2019 at 09:49:21 UTC, Daniel Kozak wrote: On Tue, Aug 20, 2019 at 11:30 AM ads via Digitalmars-d-learn wrote: you do not allow a person to think about a problem (and it’s easy here). you carried him through a puddle now, but when he dives into Sea D, you will not be

Re: Can't add a const ubyte to a dynamic array of ubyte?

2019-08-20 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 20 August 2019 at 09:27:36 UTC, ads wrote: import std.stdio; ubyte[] extend(in uint[] arr) { ubyte[] result; foreach (n; arr) { if (n < 10) result ~= n; else {

Re: Why is this allowed? Inheritance variable shadowing

2019-08-13 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 06:39:24 UTC, a11e99z wrote: On Tuesday, 13 August 2019 at 05:57:23 UTC, Mike Parker wrote: On Tuesday, 13 August 2019 at 04:40:53 UTC, Chris Katko wrote: OT: and again how to easy to google info about error/warning just with one word "CS0108" D can use attrs

Re: Why is this allowed? Inheritance variable shadowing

2019-08-13 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 05:57:23 UTC, Mike Parker wrote: On Tuesday, 13 August 2019 at 04:40:53 UTC, Chris Katko wrote: I don't know if I'd call that shadowing. This is how it works in Java, too. There's no such thing as a vtable for member variables -- each class gets its own set and

Re: Ethan: About your wpf/C# and D integration

2019-08-12 Thread a11e99z via Digitalmars-d-learn
On Monday, 12 August 2019 at 13:08:17 UTC, Bert wrote: One of the biggest issues I have with D is properly gui development. It's just a real pain in the ass compared to wpf and C#. maybe it is better to use WinRT instead of C#/WPF? - can be used for desktop apps too - same XAML - WinRT based

Re: What the abstrac final class mean?

2019-08-12 Thread a11e99z via Digitalmars-d-learn
On Monday, 12 August 2019 at 09:16:19 UTC, Alex wrote: On Monday, 12 August 2019 at 08:54:56 UTC, lili wrote: Hi: Why need defined an abstract final class? see https://github.com/Rikarin/Trinix/blob/master/Kernel/arch/amd64/gdt.d From what I saw, all members are static. So, this is

Re: Module static constructor doesn't work?

2019-08-08 Thread a11e99z via Digitalmars-d-learn
On Thursday, 8 August 2019 at 14:55:37 UTC, Andrey Zherikov wrote: I have the following code: // main.d int main() { import std.stdio; writeln("hello"); return 0; } But if I create library from lib.d first and then link it with main.d then ctor/dtor are not called: $ dmd.exe -lib

Re: Help me decide D or C

2019-08-01 Thread a11e99z via Digitalmars-d-learn
On Thursday, 1 August 2019 at 15:17:11 UTC, a11e99z wrote: On Wednesday, 31 July 2019 at 18:38:02 UTC, Alexandre wrote: Hi everyone, I would like an honest opinion. I have a beginner level (able to do very small programs) in a few languages such as python, go, C, guile(scheme) and common

Re: Help me decide D or C

2019-08-01 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 18:38:02 UTC, Alexandre wrote: Hi everyone, I would like an honest opinion. I have a beginner level (able to do very small programs) in a few languages such as python, go, C, guile(scheme) and common lisp. I want to pick a language and go deep with it and focus

Re: Return the complete number

2019-07-24 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 24 July 2019 at 16:16:15 UTC, Greatsam4sure wrote: On Wednesday, 24 July 2019 at 15:57:06 UTC, a11e99z wrote: On Wednesday, 24 July 2019 at 15:56:13 UTC, a11e99z wrote: On Wednesday, 24 July 2019 at 15:45:08 UTC, Greatsam4sure The result is always to six significant figure. I

Re: Return the complete number

2019-07-24 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 24 July 2019 at 15:45:08 UTC, Greatsam4sure wrote: int main(){ double mum = 0; Write("enter a number: ") readf(" %s\n",); Writeln(num); } How do I return the complete number the user enter since I don't since the user can enter numbers of various length with dmd

Re: Return the complete number

2019-07-24 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 24 July 2019 at 15:56:13 UTC, a11e99z wrote: On Wednesday, 24 July 2019 at 15:45:08 UTC, Greatsam4sure wrote: int main(){ double mum = 0; Write("enter a number: ") readf(" %s\n",); Writeln(num); } How do I return the complete number the user enter since I don't since the

Re: Return the complete number

2019-07-24 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 24 July 2019 at 15:45:08 UTC, Greatsam4sure wrote: int main(){ double mum = 0; Write("enter a number: ") readf(" %s\n",); Writeln(num); } How do I return the complete number the user enter since I don't since the user can enter numbers of various length with dmd

Re: Memory allocation failed in CT

2019-07-13 Thread a11e99z via Digitalmars-d-learn
On Saturday, 13 July 2019 at 06:25:37 UTC, Andrey wrote: On Tuesday, 9 July 2019 at 19:04:53 UTC, Max Haughton wrote: Is this a 64 or 32 bit compiler? Also could you post the source code if possible? You could try "--DRT-gcopt=profile:1" druntime flag to see if the compiler is running out of

Re: SendMessageTimeoutW requires casting string to uint?

2019-07-09 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 9 July 2019 at 12:14:38 UTC, BoQsc wrote: On Tuesday, 9 July 2019 at 11:11:53 UTC, Dejan Lekic wrote: auto result = SendMessageTimeoutW( HWND_BROADCAST, WM_SETTINGCHANGE, 0, envi.toUTF16z, SMTO_ABORTIFHUNG, timeout, null

Re: Why does `static foreach` lead to something calling `~=` internally?

2019-07-07 Thread a11e99z via Digitalmars-d-learn
On Sunday, 7 July 2019 at 17:07:59 UTC, a11e99z wrote: On Sunday, 7 July 2019 at 16:51:57 UTC, 0xEAB wrote: Why does this `static foreach` lead to hidden usage of operator `~=` calls in some cases? probably same oops! this one

Re: Why does `static foreach` lead to something calling `~=` internally?

2019-07-07 Thread a11e99z via Digitalmars-d-learn
On Sunday, 7 July 2019 at 16:51:57 UTC, 0xEAB wrote: Why does this `static foreach` lead to hidden usage of operator `~=` calls in some cases? probably same https://forum.dlang.org/post/qd9ee0$2eud$1...@digitalmars.com

Re: Is there something like a consuming take?

2019-07-06 Thread a11e99z via Digitalmars-d-learn
On Saturday, 6 July 2019 at 12:10:13 UTC, berni wrote: On Saturday, 6 July 2019 at 11:48:51 UTC, a11e99z wrote: Maybe I need to explain, what I dislike with this approach: take() calls popFront n times and drop() calls popFront another n times giving a total of 2n times (depending on the

Re: For loop with separator

2019-07-06 Thread a11e99z via Digitalmars-d-learn
On Saturday, 6 July 2019 at 11:48:42 UTC, berni wrote: On Thursday, 4 July 2019 at 17:00:33 UTC, Q. Schroll wrote: The prime example is printing the comma when printing a list: There is one between any two elements, but neither is one at front or behind the last one. If it is just for

Re: Is there something like a consuming take?

2019-07-06 Thread a11e99z via Digitalmars-d-learn
On Saturday, 6 July 2019 at 11:20:50 UTC, berni wrote: I want to copy the first n items of a range to an array, I came up with this now: data = r.take(n).array; This works partly, because the values of r are not consumed. So I have to call afterwards: r = r.drop(n); Now I wonder, if it is

Re: Why are immutable array literals heap allocated?

2019-07-04 Thread a11e99z via Digitalmars-d-learn
On Thursday, 4 July 2019 at 10:56:50 UTC, Nick Treleaven wrote: immutable(int[]) f() @nogc { return [1,2]; } onlineapp.d(2): Error: array literal in `@nogc` function `onlineapp.f` may cause a GC allocation specify the size of the static array: immutable(int[ 2 /*HERE*/ ]) f() @nogc {

Re: assert in unittest has access to private member?

2019-06-30 Thread a11e99z via Digitalmars-d-learn
On Sunday, 30 June 2019 at 17:24:03 UTC, Robert M. Münch wrote: I have a case, with templates, where an assert in a unittest can access a private memember and I don't know how this can happen. Before trying to creat an equivalent case, I want to cross-check, if assert has special semantics

Re: Finding the maxElement of Two-Dimensional Array

2019-06-30 Thread a11e99z via Digitalmars-d-learn
On Sunday, 30 June 2019 at 15:22:42 UTC, Samir wrote: How come this works: int[4][2] ta = [[2, 1, 4, 3], [3, 10, 2, 5]]; writeln(ta[1].maxElement); // get error on this line try to take slice from static arrays writeln(ta[1][].maxElement); or use dynamic arrays (slices) int[][] ta = [[2, 1,

Re: Reading formatted file

2019-06-27 Thread a11e99z via Digitalmars-d-learn
On Thursday, 27 June 2019 at 13:52:43 UTC, a11e99z wrote: On Thursday, 27 June 2019 at 13:31:23 UTC, Tabamon wrote: 1) try to google "dlang read text file", most probably 1,2,3 link will help to u. 2) https://dlang.org/library/std/file/read_text.html string content = readText( fileName );

Re: Reading formatted file

2019-06-27 Thread a11e99z via Digitalmars-d-learn
On Thursday, 27 June 2019 at 13:31:23 UTC, Tabamon wrote: I am new at D, I'm making a sudoku solver in D, I wanted to add the option to read sudoku from a .txt file. 1) try to google "dlang read text file", most probably 1,2,3 link will help to u. 2)