Re: Native PDB Error

2018-11-06 Thread Daniel Kozak via Digitalmars-d-learn
plain works too On Tue, Nov 6, 2018 at 7:15 PM WebFreak001 via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Tuesday, 29 May 2018 at 07:47:07 UTC, Begah wrote: > > I have recently reinstalled a fresh version of Windows 10. I > > installed DMD 1.9.0 and compiled my code ( th

Re: new returning the same memory....

2018-11-08 Thread Daniel Kozak via Digitalmars-d-learn
Did you try disable gc? import core.memory : GC; GC.disable; aclass a = new aclass(); I believe that your aclass go out of scope and there is no active reference to this so GC can collected it and reuse its memory On Thu, Nov 8, 2018 at 12:50 PM Codifies via Digitalmars-d-learn < digitalmars-d-le

Re: D is supposed to compile fast.

2018-11-23 Thread Daniel Kozak via Digitalmars-d-learn
On Fri, Nov 23, 2018 at 10:00 AM Chris Katko via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Any time I see people mention the benefits of D, I see "compile > times" "compile times" "compile times" over and over. > > I'm using very modest amounts of templates, for a fairly sm

Re: memoize & __traits(compiles...)

2018-11-23 Thread Daniel Kozak via Digitalmars-d-learn
__traits(compiles...) does not call your function so it is not evaluate twice only once, so there is no need to use memoize On Fri, Nov 23, 2018 at 11:35 AM John Chapman via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > I'm doing a fair amount of repeatedly checking if a funct

Re: Integrate vibe.d into Windows Service

2018-11-27 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 21 November 2018 at 09:59:19 UTC, Andre Pany wrote: Hi, I translated the CPP example of a windows service to D. https://docs.microsoft.com/en-us/windows/desktop/Services/svc-cpp [...] Today I needed this too, and after some searching I came across this package which works ok fo

Re: Why pow() won't go beyond 2^31?

2018-11-29 Thread Daniel Kozak via Digitalmars-d-learn
On Thu, Nov 29, 2018 at 8:10 AM Murilo via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > I am using the function pow() from std.math but if I try pow(2, > 32) it returns 0, it doesn't compute beyond the maximum value of > an int(2^31) and I am working with long. What should I d

Re: getopt short-options documentation

2018-11-29 Thread Daniel Kozak via Digitalmars-d-learn
Are you sure? Can you show me an example? I always forgot on this limitation and somtimes it cause really nesty things :D On Thu, Nov 29, 2018 at 6:05 PM Antonio Corbi via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Hi! > > Reading through the `getopt` documentation at one p

Re: .dup vs operation on all elements

2018-12-03 Thread Daniel Kozak via Digitalmars-d-learn
Yes it is. The dup version just make an extra copy of array for no reason. po 3. 12. 2018 21:10 odesílatel Goksan via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> napsal: > Are there any differences between these 2 methods of copying > elements? > > double[] array = [ 1, 20, 2, 30,

Re: Bug in shifting

2018-12-13 Thread Daniel Kozak via Digitalmars-d-learn
I do not understand you? What is wrong? It works ok. https://run.dlang.io/is/ZFf0FQ What do you mean by D required breaks for cases? On Fri, Dec 14, 2018 at 1:20 AM Michelle Long via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > byte x = 0xF; > ulong y = x >> 60; > > Does not

Re: Checking if CTFE is used?

2018-12-18 Thread Daniel Kozak via Digitalmars-d-learn
On Tue, Dec 18, 2018 at 1:25 PM berni via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Is there a way to check if a function is indeed executed at > compile time or not? (Other than going through the whole > executable binaries...) > > I tried > > > static this() > > { > > i

Re: class template conflict

2018-12-24 Thread Daniel Kozak via Digitalmars-d-learn
ne 23. 12. 2018 13:10 odesílatel Michelle Long via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> napsal: > class X > { > > } > > class X(int N) : X > { > > } > > Is there any real reason we can't do this? Actually yes. It would break almost all of my code. In D you can do thing like

Re: Converting an integer to a string with std.format.

2019-01-07 Thread Daniel Kozak via Digitalmars-d-learn
I would go with std.conv.to or std.conv.text :) On Sun, Jan 6, 2019 at 10:55 PM Per Nordlöw via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > When converting a single integer to a string is `formatValue` > preferred over `formattedWrite` in terms of compilation and > run-time

Re: Derive from interface

2019-03-25 Thread Daniel Kozak via Digitalmars-d-learn
It depends on what you want. But you can always use composition instead of inheritance for B. I have been using things like alias this, mixin and ufcs to achive multiple iheritence and it works ok for me. On Mon, Mar 25, 2019 at 10:40 PM Michelle Long via Digitalmars-d-learn < digitalmars-d-learn

Re: Casting to interface not allowed in @safe code?

2019-05-21 Thread Daniel Kozak via Digitalmars-d-learn
On Tue, May 21, 2019 at 7:55 AM Jim via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Hi, > > Question: How to call foo.x in @safe code ? > @safe: interface Base { void setup(); } interface FeatureX { void x(); } interface FeatureY { void y(); } class Foo: Base, Fe

Re: Why GNU coreutils/dd is creating a dummy file more efficiently than D's For loop?

2019-05-23 Thread Daniel Kozak via Digitalmars-d-learn
On Thu, May 23, 2019 at 11:10 AM BoQsc via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > This code of D creates a dummy 47,6 MB text file filled with Nul > characters in about 9 seconds > > import std.stdio, std.process; > > void main() { > > writeln("Creating a dummy f

Re: Why GNU coreutils/dd is creating a dummy file more efficiently than D's For loop?

2019-05-23 Thread Daniel Kozak via Digitalmars-d-learn
On Thu, May 23, 2019 at 11:19 PM Daniel Kozak wrote: Fixed version without decode to dchar void main() { import std.range : array, cycle, take; import std.stdio; import std.utf; immutable buf_size = 8192; immutable buf = "\x00".byCodeUnit.cycle.take(buf_size).array; auto

Re: Why GNU coreutils/dd is creating a dummy file more efficiently than D's For loop?

2019-05-23 Thread Daniel Kozak via Digitalmars-d-learn
On Thu, May 23, 2019 at 11:06 PM Daniel Kozak wrote: > On Thu, May 23, 2019 at 11:10 AM BoQsc via Digitalmars-d-learn < > digitalmars-d-learn@puremagic.com> wrote: > > https://matthias-endler.de/2017/yes/ > So this should do it void main() { import std.range : array, cycle, take; impor

Re: compiler does not detect accessing on null class object.

2019-05-27 Thread Daniel Kozak via Digitalmars-d-learn
On Monday, 27 May 2019 at 15:13:00 UTC, dangbinghoo wrote: hello, code below: - class a { string a1; } a a1; writeln(a1.a1); - compiles and produce "core dump" or "segfault", does this fit the original D design? why the compiler does not detect for accessing

Re: Where can find fix length array memory layout document

2019-06-18 Thread Daniel Kozak via Digitalmars-d-learn
import std.stdio; import std.array : staticArray; void main() { writeln([1].staticArray.sizeof); //4 writeln([2,5].staticArray.sizeof); //8 } On Tue, Jun 18, 2019 at 2:30 PM lili via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Hi guys: > Is the Dlang fix-length

Re: Where can find fix length array memory layout document

2019-06-18 Thread Daniel Kozak via Digitalmars-d-learn
On Tue, Jun 18, 2019 at 2:30 PM lili via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Hi guys: > Is the Dlang fix-length array alloc on stack? when a test > writeln([1]).sizeof //16 > writeln([2]).sizeof //16 > Why, What is the fix-length array memory layou

Re: DUB and ddoc - howto?

2019-06-28 Thread Daniel Kozak via Digitalmars-d-learn
Did you try dub build --help? -b --build=VALUE Specifies the type of build to perform. Note that setting the DFLAGS environment variable will override the build type with custom flags. Possible names:

Re: DUB and ddoc - howto?

2019-06-28 Thread Daniel Kozak via Digitalmars-d-learn
But I am using this one: https://github.com/adamdruppe/adrdox On Fri, Jun 28, 2019 at 2:45 PM Martin Tschierschke via Digitalmars-d-learn wrote: > A very simple question, is there an example how to generate > documentation with dub? > (like dmd -D) > > My internet search was not successful. > >

Re: How to build GUI-based applications in D ?

2017-08-01 Thread Daniel Kozak via Digitalmars-d-learn
https://www.youtube.com/watch?v=5eUL8Z9AFW0 https://github.com/buggins/dlangui On Tue, Aug 1, 2017 at 11:31 AM, ashit via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > what is the simplest library to create gui applications in D? > i want to create gui applications but couldn

Re: Using lazy code to process large files

2017-08-02 Thread Daniel Kozak via Digitalmars-d-learn
import std.stdio; import std.algorithm; void main() { auto input = ["... some text, another text", "some,another","...so,an"]; auto result = input.filter!(a => a.startsWith("...")) .map!(a=>a.splitter(",").map!(a=>a.stripLeft(' '))) .map!(a=>a.joiner(",")); writeln(result); } On

Re: Using lazy code to process large files

2017-08-02 Thread Daniel Kozak via Digitalmars-d-learn
using http://dlang.org/phobos/std_utf.html#byCodeUnit could help On Wed, Aug 2, 2017 at 2:59 PM, Martin Drašar via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Dne 2.8.2017 v 14:45 Steven Schveighoffer via Digitalmars-d-learn > napsal(a): > > > The problem is that you are 2 r

Re: Using lazy code to process large files

2017-08-02 Thread Daniel Kozak via Digitalmars-d-learn
something like file.byLine.map!(a=>a.byCodeUnit) On Wed, Aug 2, 2017 at 3:01 PM, Daniel Kozak wrote: > using http://dlang.org/phobos/std_utf.html#byCodeUnit could help > > On Wed, Aug 2, 2017 at 2:59 PM, Martin Drašar via Digitalmars-d-learn < > digitalmars-d-learn@puremagic.com> wrote: > >> Dne

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
this works ok for me with ldc compiler, gdc does not work on my arch machine so I can not do comparsion to your c++ versin (clang does not work with your c++ code) import std.stdio : writeln; import std.algorithm.comparison: min; import std.algorithm.iteration: sum; import core.time: MonoTime, Dur

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
Here is more D idiomatic way: import std.stdio : writeln; import std.algorithm.comparison: min; import std.algorithm.iteration: sum; import core.time: MonoTime, Duration; auto sum_subranges(T)(T input, uint range) { import std.array : array; import std.range : chunks, ElementType; im

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
my second version on ldc takes 380ms and c++ version on same compiler (clang), takes 350ms, so it seems to be almost same On Sun, Aug 13, 2017 at 9:51 AM, amfvcg via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Sunday, 13 August 2017 at 07:30:32 UTC, Daniel Kozak wrote: >

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
this one is even faster than c++: http://ideone.com/TRDsOo On Sun, Aug 13, 2017 at 10:00 AM, Daniel Kozak wrote: > my second version on ldc takes 380ms and c++ version on same compiler > (clang), takes 350ms, so it seems to be almost same > > On Sun, Aug 13, 2017 at 9:51 AM, amfvcg via Digitalma

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
And this one is awesome :P http://ideone.com/muehUw On Sun, Aug 13, 2017 at 10:27 AM, Daniel Kozak wrote: > this one is even faster than c++: > http://ideone.com/TRDsOo > > On Sun, Aug 13, 2017 at 10:00 AM, Daniel Kozak wrote: > >> my second version on ldc takes 380ms and c++ version on same co

Re: Read/Write memory barriers in D?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
maybe something like https://dlang.org/phobos/core_bitop.html#.volatileLoad and https://dlang.org/phobos/core_bitop.html#.volatileStore On Sun, Aug 13, 2017 at 1:37 PM, Igor via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > I am converting a C code that uses this macro: > > #d

Re: Read/Write memory barriers in D?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
or maybe use core.atomic.atomicLoad and store with right https://dlang.org/phobos/core_atomic.html#.MemoryOrder On Sun, Aug 13, 2017 at 1:51 PM, Daniel Kozak wrote: > maybe something like https://dlang.org/phobos/ > core_bitop.html#.volatileLoad and https://dlang.org/phobos/ > core_bitop.html#.v

Re: How to fix wrong deprecation message - dmd-2.075.1

2017-08-15 Thread Daniel Kozak via Digitalmars-d-learn
You should open an issue on https://issues.dlang.org/ until it is fixed you can use lazy variation byChar, byWchar or byUTF: void main() { import std.utf : byWchar; import std.array : array; wstring s = byWchar("abc").array; } On Wed, Aug 16, 2017 at 7:09 AM, apz28 via

Re: Compiler bug?

2017-08-15 Thread Daniel Kozak via Digitalmars-d-learn
No it is not a bug, there is no s() in B, you can fix this by adding: alias s = A.s; to class B On Wed, Aug 16, 2017 at 7:21 AM, apz28 via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > abstract class A > { > string _s; > > @property: > final string s() >

Re: Compiler bug?

2017-08-15 Thread Daniel Kozak via Digitalmars-d-learn
and some doc: http://dlang.org/spec/function.html#function-inheritance On Wed, Aug 16, 2017 at 7:45 AM, Daniel Kozak wrote: > No it is not a bug, there is no s() in B, you can fix this by adding: > > alias s = A.s; > > to class B > > On Wed, Aug 16, 2017 at 7:21 AM, apz28 via Digitalmars-d-learn

Re: How to fix wrong deprecation message - dmd-2.075.1

2017-08-16 Thread Daniel Kozak via Digitalmars-d-learn
It should not be print? AIAIK std.utf.toUTF16 is not deprecated: http://dlang.org/phobos/std_utf.html#toUTF16 OK this one is:https://github.com/dlang/phobos/blob/v2.075.1/std/utf.d#L2760 (but this one is not in doc) but this one should not be deprecated: https://github.com/dlang/phobos/blob/v2.07

In DUB, how do I conditionally compile code based on optional dependencies?

2017-08-16 Thread Daniel Kozak via Digitalmars-d-learn
There is a question on SO: https://stackoverflow.com/questions/45697469/in-dub-how-do-i-conditionally-compile-code-based-on-optional-dependencies I have found the answer, but I am interesting is there any doc about this?

Re: Help Required on Getopt

2017-09-01 Thread Daniel Kozak via Digitalmars-d-learn
I have same issue. How this help you? Catching exception does not help. How do I catch exception and still print help message? Dne 1. 9. 2017 8:10 odpoledne napsal uživatel "Vino.B via Digitalmars-d-learn" : On Friday, 1 September 2017 at 17:23:01 UTC, Jon Degenhardt wrote: > On Friday, 1 Sept

Re: How to check if path is writable

2017-09-14 Thread Daniel Kozak via Digitalmars-d-learn
You can use https://dlang.org/phobos/std_file.html#getAttributes, but you still need to distinguish Windows and posix platforms On Fri, Sep 15, 2017 at 5:36 AM, Joseph via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Friday, 15 September 2017 at 02:02:54 UTC, Neia Neutulad

Re: How to compile for Win64 with Visual D? Optlink error?

2017-09-19 Thread Daniel Kozak via Digitalmars-d-learn
this should be ok, can you post error when using with m64 On Tue, Sep 19, 2017 at 1:47 PM, Timothy Foster via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > I'm trying to compile my project as a Win64 application but this is > happening: > > Building C:\Users\me\test\test.exe..

Re: Basic LDC Linux Install Question

2017-09-19 Thread Daniel Kozak via Digitalmars-d-learn
Yes you need to add ldc2 to your PATH. So if your ldc2 binary is in /user/something/something/folder_where_is_ldc2/ldc2 you havto add /user/something/something/folder_where_is_ldc2 to your PATH. You can test this by pasting this to terminal: export PATH=$PATH:/user/something/something/folder_where

Re: Does D support nested Templates aka Higher Kinded Polymorphism?

2017-10-03 Thread Daniel Kozak via Digitalmars-d-learn
writeln(bar!(Bar,Foo,int)(Bar!(Foo,int)())); Dne 3. 10. 2017 3:55 odpoledne napsal uživatel "sighoya via Digitalmars-d-learn" : But when I write this to: writeln(bar!(Bar,Foo,int)(Bar!(Foo,int))); it complains by: test.d(11): Error: template instance T!(S!int) does not match template declarati

Re: Does D support nested Templates aka Higher Kinded Polymorphism?

2017-10-03 Thread Daniel Kozak via Digitalmars-d-learn
https://run.dlang.io/is/oqbYNb On Tue, Oct 3, 2017 at 5:52 PM, sighoya via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Tuesday, 3 October 2017 at 15:30:52 UTC, Daniel Kozak wrote: > >> writeln(bar!(Bar,Foo,int)(Bar!(Foo,int)())); >> >> Dne 3. 10. 2017 3:55 odpoledne napsa

Re: how to shorten templates structs name?

2017-10-10 Thread Daniel Kozak via Digitalmars-d-learn
Use alias this Dne 10. 10. 2017 1:30 odpoledne napsal uživatel "drug via Digitalmars-d-learn" : > using classes I can make an inherited class of templated class and avoid > too long mangled name: > ``` > class TemplatedClass(A, Very, Much, Args, Here) { ... } > > class ShortenClass : TemplatedCla

Re: initializing a static array

2017-10-10 Thread Daniel Kozak via Digitalmars-d-learn
struct Double { double v = 0; alias v this; } struct Foo(size_t n) { Double[n] bar; } Dne 10. 10. 2017 3:40 odpoledne napsal uživatel "Simon Bürger via Digitalmars-d-learn" : I have a static array inside a struct which I would like to be initialized to all-zero like so struct Foo(

Re: initializing a static array

2017-10-10 Thread Daniel Kozak via Digitalmars-d-learn
On Tue, Oct 10, 2017 at 4:15 PM, Simon Bürger via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Tuesday, 10 October 2017 at 13:48:16 UTC, Andrea Fontana wrote: > >> On Tuesday, 10 October 2017 at 13:36:56 UTC, Simon Bürger wrote: >> >>> Is there a good way to set them all to

Re: initializing a static array

2017-10-10 Thread Daniel Kozak via Digitalmars-d-learn
Yeah, you are right. My fault. On Tue, Oct 10, 2017 at 4:47 PM, Adam D. Ruppe via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Tuesday, 10 October 2017 at 14:42:15 UTC, Daniel Kozak wrote: > >> It will return dynamic array. it is same as: >> >> double[5] = [0,0,0,0,0]; //

Re: initializing a static array

2017-10-10 Thread Daniel Kozak via Digitalmars-d-learn
https://run.dlang.io/is/SC3Fks

Re: Why do I have to cast arguments from int to byte?

2017-10-11 Thread Daniel Kozak via Digitalmars-d-learn
You can avoid cast: void foo(T)(T bar){...} byte bar = 9; foo!byte(bar + byte(1)); or byte bar = 9; byte num = 1; foo!byte(bar + num); On Tue, Oct 10, 2017 at 9:55 PM, Chirs Forest via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > I keep having to make casts like the fo

Re: struct/class generation

2017-10-11 Thread Daniel Kozak via Digitalmars-d-learn
If you just want to not repeat fields and methods you can use alias this or mixins: https://run.dlang.io/is/0UkjTe On Wed, Oct 11, 2017 at 2:07 PM, drug via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > 11.10.2017 14:37, ANtlord пишет: > > Hello dear community! >> >> I've met

Re: Does D have an equivalent to C#'s String.IsNullOrWhiteSpace?

2017-10-12 Thread Daniel Kozak via Digitalmars-d-learn
Wow, C# is really wierd. They have method IsNullOrEmpty (OK why not), but they have IsNullOrWhiteSpace OK little akward but still OK until you realized it is more like IsNullOrEmptyOrWhiteSpace :D On Thu, Oct 12, 2017 at 8:11 PM, Nieto via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> w

Re: Why do I have to cast arguments from int to byte?

2017-10-13 Thread Daniel Kozak via Digitalmars-d-learn
Not sure :), I have forgoten byte+byte=int. On Thu, Oct 12, 2017 at 10:51 PM, kdevel via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Wednesday, 11 October 2017 at 07:09:26 UTC, Daniel Kozak wrote: > >> You can avoid cast: >> >> void foo(T)(T bar){...} >> >> byte bar = 9;

Re: Why do I have to cast arguments from int to byte?

2017-10-13 Thread Daniel Kozak via Digitalmars-d-learn
but it works ok with immutable, so until you really need to change bar you can use immutable bar = 9; foo!byte(bar + 1); On Fri, Oct 13, 2017 at 9:46 AM, Daniel Kozak wrote: > Not sure :), I have forgoten byte+byte=int. > > On Thu, Oct 12, 2017 at 10:51 PM, kdevel via Digitalmars-d-learn < > di

Re: Does D have an equivalent to C#'s String.IsNullOrWhiteSpace?

2017-10-13 Thread Daniel Kozak via Digitalmars-d-learn
Yes I beleive it is neat functionality. I just dont like those names :) On Fri, Oct 13, 2017 at 8:36 AM, Jacob Carlborg via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On 2017-10-12 21:42, Daniel Kozak wrote: > >> Wow, C# is really wierd. They have method IsNullOrEmpty (OK w

Re: Can't use function with same name as module?

2017-10-17 Thread Daniel Kozak via Digitalmars-d-learn
You can: import fun : fun; int main(string[] args) { fun(); return 0; } On Tue, Oct 17, 2017 at 10:08 AM, Shriramana Sharma via Digitalmars-d-learn wrote: > On Tuesday, 17 October 2017 at 07:33:15 UTC, evilrat wrote: > >> Compiler made that way so it doesn't guess or assume too much, b

Re: Working with images

2017-11-01 Thread Daniel Kozak via Digitalmars-d-learn
You can still use CLib, if you dont find anything else. On Wed, Nov 1, 2017 at 1:22 PM, Antonio Corbi via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Wednesday, 1 November 2017 at 12:02:08 UTC, Alexandre wrote: > >> I have a project written in C++, that I'm thinking to mi

Re: COM/OLE advanced questions

2017-11-02 Thread Daniel Kozak via Digitalmars-d-learn
AFAIK you can only use COM from windows anyway. OK I have been using them from linux but only with WINE help. On Thu, Nov 2, 2017 at 3:22 PM, Guillaume Piolat via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > I wonder if anyone has used COM in dlang extensively. > > Context: I

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-15 Thread Daniel Kozak via Digitalmars-d-learn
Do not use your own taskPool, just use global taskPool proerty (import std.parallelism: taskPool). You should not set blocking to false. And dont use Thread here. There is no reason to do that. Just move that code into the main Dne 15. 11. 2017 12:15 odp. napsal uživatel "ade90036 via Digitalma

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-15 Thread Daniel Kozak via Digitalmars-d-learn
This one works ok for me, but I am on linux: https://dpaste.dzfl.pl/f54decee45bc On Wed, Nov 15, 2017 at 12:46 PM, Daniel Kozak wrote: > Do not use your own taskPool, just use global taskPool proerty (import > std.parallelism: taskPool). > > You should not set blocking to false. And dont use Thr

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-15 Thread Daniel Kozak via Digitalmars-d-learn
And this one https://paste.ofcode.org/KNqxcrmACLZLseB45MvwC Here you can test if threads makes difference when compile with: dmd -O -release -version=SINGLE_THREAD xxx.d it will use only one thread when compile with: dmd -O -release xxx.d it will use thread pool On Wed, Nov 15, 2017 at 2:

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread Daniel Kozak via Digitalmars-d-learn
Hmm works ok for me. What OS? Dne 16. 11. 2017 12:05 dop. napsal uživatel "kdevel via Digitalmars-d-learn" : > On Wednesday, 15 November 2017 at 13:31:46 UTC, Daniel Kozak wrote: > >> This one works ok for me, but I am on linux: >> https://dpaste.dzfl.pl/f54decee45bc >> > > It works, but it does

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread Daniel Kozak via Digitalmars-d-learn
It works for me because I have multiple threads, but when I use only one thread per pool (defaultPoolThreads(1)), it obviosly blocks, which is correct behavior On Thu, Nov 16, 2017 at 7:20 PM, Daniel Kozak wrote: > Hmm works ok for me. What OS? > > Dne 16. 11. 2017 12:05 dop. napsal uživatel "kd

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-16 Thread Daniel Kozak via Digitalmars-d-learn
can you post both code, java and d, for sure we are all testing the sames On Thu, Nov 16, 2017 at 8:37 PM, ade90036 via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > So, what is next? > > Can we enable some sort of profiling to see what is going on? >

Re: Concurrency send immutable

2017-11-24 Thread Daniel Kozak via Digitalmars-d-learn
Should print something like this: std.concurrency.OwnerTerminated@std/concurrency.d(223): Owner terminated Because main thread is terminated, because types do not match this will work import std.stdio; import std.concurrency; void fun() { receive( (immutable (int)[] v) => writeln(v) ); } int ma

Re: Concurrency send immutable

2017-11-24 Thread Daniel Kozak via Digitalmars-d-learn
import std.stdio; import std.traits; int main(string[] args) { immutable int[] arr = [1,2,3,4,5]; writeln(ImplicitConversionTargets!(typeof(arr)).stringof); return 0; } On Fri, Nov 24, 2017 at 1:36 PM, Daniel Kozak wrote: > Should print something like this: > std.concurrency.OwnerTerminated@std

Re: Object oriented programming and interfaces

2017-12-05 Thread Daniel Kozak via Digitalmars-d-learn
You can do something like this: interface Medoid(T) { float distance( T other ); uint id() const @property; } class Item : Medoid!(Item) { float distance( Item m ) { return 0.;} uint id() const @property { return 1; } } class MedoidClassification { this(T:Medoid!T)(T[] list)

Re: lower case only first letter of word

2017-12-05 Thread Daniel Kozak via Digitalmars-d-learn
Something like this: https://dlang.org/phobos/std_uni.html#asCapitalized On Tue, Dec 5, 2017 at 2:31 PM, Marc via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Does D have a native function to capitalize only the first letter of the > word? (I'm asking that so I might avoid re

Re: lower case only first letter of word

2017-12-05 Thread Daniel Kozak via Digitalmars-d-learn
but this will change all other uppercase to lowercase, so maybe it is not what you want. If you really want just change first char to upper, then there is nothing wrong to do it yourself On Tue, Dec 5, 2017 at 2:37 PM, Daniel Kozak wrote: > Something like this: https://dlang.org/phobos/std_uni.h

Re: Binary serialization of a struct

2017-12-08 Thread Daniel Kozak via Digitalmars-d-learn
You should use size_t instead of ulong, but on 32bit you would have still problem because you are trying assign 2^32 which is too big to hold in 32bit On Thu, Dec 7, 2017 at 11:42 PM, kdevel via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Tuesday, 19 September 2017 at 06:

Re: Debugging a druntime issue found by AutoTester

2017-12-12 Thread Daniel Kozak via Digitalmars-d-learn
I would go with some VM and install 32bit system on it. Dne 12. 12. 2017 8:55 dop. napsal uživatel "Ali Çehreli via Digitalmars-d-learn" : > The automatic tests for a PR failed for a target that I could not test > myself: 32-bit build on Darwin_64_32. > > > https://auto-tester.puremagic.com/show-

Re: are scope guards (scope(exit, success, failure)) zero-cost abstractions?

2018-02-08 Thread Daniel Kozak via Digitalmars-d-learn
I mean scope(success), for scope(exit) there is no speed penalty On Thu, Feb 8, 2018 at 12:03 PM, Daniel Kozak wrote: > Yes, it add, but is almost zero > > On Thu, Feb 8, 2018 at 12:00 PM, Timothee Cour via Digitalmars-d-learn < > digitalmars-d-learn@puremagic.com> wrote: > >> I know that, my qu

Re: are scope guards (scope(exit, success, failure)) zero-cost abstractions?

2018-02-08 Thread Daniel Kozak via Digitalmars-d-learn
Yes, it add, but is almost zero On Thu, Feb 8, 2018 at 12:00 PM, Timothee Cour via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > I know that, my question is whether it adds any runtime overhead over > naive way (which is to call the "bar" finalizer before each return > stateme

Re: Equivalent to Python with Statement

2018-02-27 Thread Daniel Kozak via Digitalmars-d-learn
yes, for classes you can use scoped: import std.stdio; import std.typecons : scoped; class A { void saySomething() { writeln("Hi from A"); } ~this() { writeln("Destruct A"); } } void main() { with(scoped!A()) { saySomething(); writeln("s

Re: is it regression?

2018-02-28 Thread Daniel Kozak via Digitalmars-d-learn
Yes it is a regression, please fill a bug report On Wed, Feb 28, 2018 at 2:16 PM, drug via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > https://run.dlang.io/is/HJxtvw > > ``` > import std.stdio, std.typecons, std.math; > void main() > { > auto foo = nullable(2.0); > a

Re: is it regression?

2018-02-28 Thread Daniel Kozak via Digitalmars-d-learn
I would say it is a still regression, but I agree with you, that it should not work on the first place. On Wed, Feb 28, 2018 at 3:28 PM, bauss via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Wednesday, 28 February 2018 at 13:38:56 UTC, drug wrote: > >> done https://issues

Re: Benchmarking sigmoid function between C and D

2018-04-07 Thread Daniel Kozak via Digitalmars-d-learn
can you try it with c math functions? instead of std.math, try to use core.stdc.math On Sat, Apr 7, 2018 at 8:53 PM, Arun Chandrasekaran via Digitalmars-d-learn wrote: > What am I doing wrong here that makes the D equivalent 2.5 times slower > than it's C equivalent? > > Compilers used: > > LDC

Re: Benchmarking sigmoid function between C and D

2018-04-07 Thread Daniel Kozak via Digitalmars-d-learn
or for ldc http://docs.algorithm.dlang.io/latest/mir_math_common.html On Sat, Apr 7, 2018 at 9:10 PM, Daniel Kozak wrote: > can you try it with c math functions? > > instead of std.math, try to use core.stdc.math > > On Sat, Apr 7, 2018 at 8:53 PM, Arun Chandrasekaran via > Digitalmars-d-learn

Re: Benchmarking sigmoid function between C and D

2018-04-08 Thread Daniel Kozak via Digitalmars-d-learn
I would say he has, becaue AFAIK mir.math.common using LLVM intrinsics On Sat, Apr 7, 2018 at 11:53 PM, Guillaume Piolat via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Saturday, 7 April 2018 at 20:33:13 UTC, Arun Chandrasekaran wrote: > >> On Saturday, 7 April 2018 at 19

Re: Why does File.byLine() return char[] and not string

2015-10-16 Thread Daniel Kozak via Digitalmars-d-learn
Shriramana Sharma píše v Pá 16. 10. 2015 v 16:08 +0530: > Is there a particular reason that File.byLine() returns char[] and > not > string i.e. immutable(char)[]? Is it just to avoid being overly > restrictive? > It seems that having to .idup it is inefficient... > You need to do dup or idup a

Re: Why can't function expecting immutable arg take mutable input?

2015-10-16 Thread Daniel Kozak via Digitalmars-d-learn
Shriramana Sharma píše v Pá 16. 10. 2015 v 16:05 +0530: > Hello. I still haven't wrapped my mind around the const/immutable > thing yet > and am still stuck in C/C++ mode. :-( > > A function that takes mutable arguments cannot be called with > immutable > input at the call site since it does not

Re: Why does File.byLine() return char[] and not string

2015-10-18 Thread Daniel Kozak via Digitalmars-d-learn
V Sun, 18 Oct 2015 15:51:13 + Suliman via Digitalmars-d-learn napsáno: > On Sunday, 18 October 2015 at 15:40:09 UTC, novice2 wrote: > >> what buffer you are talking. > > > > internal buffer. where result line resides. > > > > > >> And what is "signal"? How it's working? > > > > just the

Re: foreach loop

2015-10-19 Thread Daniel Kozak via Digitalmars-d-learn
V Mon, 19 Oct 2015 14:28:03 + Namal via Digitalmars-d-learn napsáno: > Is it possible to create a foreach loop with a breakstetemen? > > I mean something like that for the second loop where i want to > break if element from: > > int [] g = [9,15,21]; > int [] v = [2,3,5,7,8,9,11,13,17,19]

Re: Preventing implicit conversion

2015-11-04 Thread Daniel Kozak via Digitalmars-d-learn
V Wed, 04 Nov 2015 14:27:45 + ixid via Digitalmars-d-learn napsáno: > Is there an elegant way of avoiding implicit conversion to int > when you're using shorter types? http://dlang.org/phobos/std_typecons.html#.Typedef

Re: OSX Foundation framework D binding

2015-11-11 Thread Daniel Kozak via Digitalmars-d-learn
V Wed, 11 Nov 2015 06:17:00 + Vadim Lopatin via Digitalmars-d-learn napsáno: > Hello, > > I'm working on native Cocoa backend for DlangUI GUI library under > OSX. > Is there any ready to use bindings for easy accessing Cocoa API? > Probably, there is some HelloWorld program which creates wi

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 13:32:00 UTC, perlancar wrote: Here's my first non-hello-world D program, which is a direct translation from the Perl version. I was trying to get a feel about D's performance: ... While I am quite impressed with how easy I was able to write D, I am not so i

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 12 Nov 2015 09:12:32 + Daniel Kozak via Digitalmars-d-learn napsáno: > On Wednesday, 11 November 2015 at 13:32:00 UTC, perlancar wrote: > > Here's my first non-hello-world D program, which is a direct > > translation from the Perl version. I was trying to get a

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 12 Nov 2015 11:03:38 + Tobias Pankrath via Digitalmars-d-learn napsáno: > > or with ~ operator: > > > > import std.stdio; > > > > [...] > > Did anyone check that the last loop isn't optimized out? Yes, it is not optimized out > Could also be improved further if you make the functi

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 12 Nov 2015 12:13:10 + perlancar via Digitalmars-d-learn napsáno: > On Wednesday, 11 November 2015 at 14:20:51 UTC, Rikki Cattermole > wrote: > > I turned it into mostly using large allocations, instead of > > small ones. > > Although I'd recommend using Appender instead of my custom

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 12 November 2015 at 12:25:08 UTC, Daniel Kozak wrote: V Thu, 12 Nov 2015 12:13:10 + perlancar via Digitalmars-d-learn napsáno: On Wednesday, 11 November 2015 at 14:20:51 UTC, Rikki Cattermole wrote: > I turned it into mostly using large allocations, instead of > small ones.

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 12 November 2015 at 12:49:55 UTC, Daniel Kozak wrote: On Thursday, 12 November 2015 at 12:25:08 UTC, Daniel Kozak wrote: ... auto res = appender(uninitializedArray!(char[])(total)); res.clear(); ... this is faster for DMD and ldc: auto res = appender!(string)(); res.

Re: Using enums as function parameters (in a minimized way)

2015-12-01 Thread Daniel Kozak via Digitalmars-d-learn
V Tue, 01 Dec 2015 10:44:06 + Ozan via Digitalmars-d-learn napsáno: > Hi > > Let's say we have an enum like > > enum SomethingAboutChristmas { >SantaClaus, >Angel, >Tree > } > > and want to use it in a function like > >void goingChristmas(SomethingAboutChristmas enumvalue)

Re: Question about mysql-d Object

2015-12-07 Thread Daniel Kozak via Digitalmars-d-learn
On Monday, 7 December 2015 at 14:40:12 UTC, Martin Tschierschke wrote: When I do the following: auto mysql = new Mysql("localhost", 3306, "mt", "", "verwaltung"); auto rows = mysql.query("select field from my_table limit 50"); foreach(row;rows){ writeln(row["field"]);} // second time same l

Re: Question about mysql-d Object

2015-12-08 Thread Daniel Kozak via Digitalmars-d-learn
V Tue, 08 Dec 2015 14:34:53 + Martin Tschierschke via Digitalmars-d-learn napsáno: > On Monday, 7 December 2015 at 16:11:19 UTC, Daniel Kozak wrote: > > On Monday, 7 December 2015 at 14:40:12 UTC, Martin Tschierschke > > wrote: > >> When I do the following: > >> > >> auto mysql = new Mysql

Re: Question about mysql-d Object

2015-12-08 Thread Daniel Kozak via Digitalmars-d-learn
V Tue, 08 Dec 2015 14:34:53 + Martin Tschierschke via Digitalmars-d-learn napsáno: > On Monday, 7 December 2015 at 16:11:19 UTC, Daniel Kozak wrote: > > On Monday, 7 December 2015 at 14:40:12 UTC, Martin Tschierschke > > wrote: > >> When I do the following: > >> > >> auto mysql = new Mysql

Re: Reason for 'static struct'

2015-12-10 Thread Daniel Kozak via Digitalmars-d-learn
Yes, exactly. Some people even use static if it is not needed because it is harmless. And remove it only when enclosing context is demand. Dne 9. 12. 2015 22:40 napsal uživatel "Jon D via Digitalmars-d-learn" < digitalmars-d-learn@puremagic.com>: > On Wednesday, 9 December 2015 at 21:23:03 UTC, Da

Re: %s not producing string representation of enum?

2015-12-10 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 10 Dec 2015 19:54:43 +0530 Shriramana Sharma via Digitalmars-d-learn napsáno: > Hello. I'm using DMD 2.069.2. As per > http://ddili.org/ders/d.en/enum.html the following code is supposed > to output the *names* of the suits: > > import std.stdio; > void main() > { > enum Suit { spades

Re: %s not producing string representation of enum?

2015-12-10 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 10 Dec 2015 19:54:43 +0530 Shriramana Sharma via Digitalmars-d-learn napsáno: > Hello. I'm using DMD 2.069.2. As per > http://ddili.org/ders/d.en/enum.html the following code is supposed > to output the *names* of the suits: > > import std.stdio; > void main() > { > enum Suit { spades

Re: Why `i` not working on foreach loop if it have byLine option

2015-12-17 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 17 Dec 2015 14:09:57 + Suliman via Digitalmars-d-learn napsáno: > Next code produce error: > > foreach(i, line;fileContent.byLine) > > Error: cannot infer argument types, expected 1 argument, not 2 > > Why it's do not work? http://dlang.org/phobos/std_range.html#enumerate

Re: Socket - handling large numbers of incoming connections

2015-12-21 Thread Daniel Kozak via Digitalmars-d-learn
V Mon, 21 Dec 2015 23:29:14 + "Adam D. Ruppe via Digitalmars-d-learn" napsáno: > On Monday, 21 December 2015 at 23:17:45 UTC, Daniel Kozák wrote: > > If you want to reinvent the wheel you can use > > It isn't really reinventing the wheel to just use an alternate > library... I guess you a

<    1   2   3   4   5   >