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: 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;

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: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

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,

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 <

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: 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() > > { > >

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

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: 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

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

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

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

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

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 <

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 (

Re: Can i watch folders/files for changes with D language?

2018-10-09 Thread Daniel Kozak via Digitalmars-d-learn
You can use vibed: http://vibed.org/api/vibe.core.file/DirectoryWatcher Or just vibe-core https://code.dlang.org/packages/vibe-core Or https://code.dlang.org/packages/eventcore As a bonus you can use it for networking too. About GUI I do not know what is the best solution. I have some experience

Re: Gui framework

2018-08-01 Thread Daniel Kozak via Digitalmars-d-learn
I am using gtkd and is really nice, but AFAIK it does not have native looking on windows yet On Wed, Aug 1, 2018 at 5:30 PM Greatsam4sure via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Please help me recommend a gui toolkit for dlang, that has the > following > * work

Re: A vibe.d thing

2018-07-31 Thread Daniel Kozak via Digitalmars-d-learn
On Fri, Jul 27, 2018 at 9:30 PM Steven Schveighoffer via Digitalmars-d-learn wrote: > > > > Maybe IOMode.immediate or .once? > > https://vibed.org/api/eventcore.driver/IOMode > > Oh, it looks like you specified once. Hm... that seems to me like it > should work. > > Looks like IOMode is ignored:

Re: High memory usage in vibe.d application

2018-06-29 Thread Daniel Kozak via Digitalmars-d-learn
Have you try use VibeManualMemoryManagement https://github.com/TechEmpower/FrameworkBenchmarks/blob/3b24d0a21463edc536b30e2cea647fd425915401/frameworks/D/vibed/dub.json#L22 On Fri, Jun 29, 2018 at 3:20 PM Anton Fediushin via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On

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 >

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

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

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); >

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();

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 >

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: >

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. > > >

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

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:

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: 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: 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: >

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

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: 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.

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: >>

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

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

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

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:

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

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

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

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

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: 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>

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: 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

Re: initializing a static array

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

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
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

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

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) { ... } >

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

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

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

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

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

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

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: 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:

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

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: 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: 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/

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: > >

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

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,

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
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;

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,

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 < >

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

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: Can I speed up this log parsing script further?

2017-06-09 Thread Daniel Kozak via Digitalmars-d-learn
btw it is important to use right compiler with right flags I am using ldc with this flags ldmd2 -O -release -boundscheck=off On Fri, Jun 9, 2017 at 6:28 PM, uncorroded via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Friday, 9 June 2017 at 14:19:48 UTC, Daniel Kozak

Re: Can I speed up this log parsing script further?

2017-06-09 Thread Daniel Kozak via Digitalmars-d-learn
import std.stdio; import std.array: appender, array; import std.algorithm : findSplit, splitter, joiner, canFind, map; import std.typecons : tuple, Tuple; import std.conv : to; import std.range : dropOne, dropExactly, takeExactly, chain; alias push_type = Tuple!(int, char[], int, bool, bool);

Re: Can I speed up this log parsing script further?

2017-06-09 Thread Daniel Kozak via Digitalmars-d-learn
On Fri, Jun 9, 2017 at 9:34 AM, uncorroded via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Hi guys, > > I am a beginner in D. As a project, I converted a log-parsing script in > Python which we use at work, to D. This link was helpful - ( >

Re: Can I speed up this log parsing script further?

2017-06-09 Thread Daniel Kozak via Digitalmars-d-learn
Dne 9.6.2017 v 09:50 rikki cattermole via Digitalmars-d-learn napsal(a): On 09/06/2017 8:34 AM, uncorroded wrote: Hi guys, ... The code isn't entirely 1:1. Any usage of IO (includes stdout via writeln) is expensive. Your python code doesn't write anything to stdout (or perform any calls).

Re: Can I speed up this log parsing script further?

2017-06-09 Thread Daniel Kozak via Digitalmars-d-learn
I would considered using appender for pushed and npushed. Can you post file on which you are running benchmarking? On Fri, Jun 9, 2017 at 9:50 AM, rikki cattermole via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On 09/06/2017 8:34 AM, uncorroded wrote: > >> Hi guys, >> >> I

Re: howto count lines - fast

2017-05-31 Thread Daniel Kozak via Digitalmars-d-learn
Dne 31.5.2017 v 02:13 Ali Çehreli via Digitalmars-d-learn napsal(a): I could not make the D program come close to wc's performance when the data was piped from stdin. A typical run with Daniel Kozak's program: $ time cat deleteme.txt | wc -l 5062176 real0m0.086s user0m0.068s sys

Re: ushort calls byte overload

2017-05-30 Thread Daniel Kozak via Digitalmars-d-learn
Dne 30.5.2017 v 23:16 Oleg B via Digitalmars-d-learn napsal(a): Hello. I have this code import std.stdio; void foo(byte a) { writeln(typeof(a).stringof); } void foo(short a) { writeln(typeof(a).stringof); } void foo(int a) { writeln(typeof(a).stringof); } void main() { foo(0); // int,

Re: howto count lines - fast

2017-05-30 Thread Daniel Kozak via Digitalmars-d-learn
I do not know this is my first attempt and it is almost same fast as wc on my pc: int main(string[] args) { import std.stdio : writeln, writefln, File; import std.array : uninitializedArray; auto f = File("data"); size_t c = 0; auto buffer =

Re: Error: func(const(A) a) is not callable using argument types (const(A)

2017-05-30 Thread Daniel Kozak via Digitalmars-d-learn
http://forum.dlang.org/post/xpmpakmusudanwuzz...@forum.dlang.org https://issues.dlang.org/show_bug.cgi?id=9631 On Tue, May 30, 2017 at 1:07 PM, Biotronic via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Tuesday, 30 May 2017 at 10:46:12 UTC, Andrew Edwards wrote: > >> On

Re: Error: func(const(A) a) is not callable using argument types (const(A)

2017-05-30 Thread Daniel Kozak via Digitalmars-d-learn
import std.traits : fqn = fullyQualifiedName; On Tue, May 30, 2017 at 12:24 PM, Biotronic via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Tuesday, 30 May 2017 at 10:09:50 UTC, Andrew Edwards wrote: > >> What does that even mean? >> >> Scenario: >> >> bool func(const

Re: Error: func(const(A) a) is not callable using argument types (const(A)

2017-05-30 Thread Daniel Kozak via Digitalmars-d-learn
It seems there are two different ImVec2 types. So ImVec2 is not same as ImVec2 :) On Tue, May 30, 2017 at 12:09 PM, Andrew Edwards via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > What does that even mean? > > Scenario: > > bool func(const ImVec2 label_size) > { > return

Re: 64-bit DMD

2017-03-30 Thread Daniel Kozak via Digitalmars-d-learn
Dne 31.3.2017 v 00:41 Inquie via Digitalmars-d-learn napsal(a): Is there a 64-bit DMD compiler that doesn't have the 2GB memory limitations that the 32-bit one has? I am not talking about compiling 64-bit programs but the dmd binary itself. I belive it is 4GB ok maybe 3GB :)

Re: bug in foreach continue

2017-03-17 Thread Daniel Kozak via Digitalmars-d-learn
Dne 17.3.2017 v 02:34 Hussien via Digitalmars-d-learn napsal(a): foreach (y; aliasSeqOf!["a", "b", "c"]) { static if (y == "a") { } else pragma(msg, y); } works but foreach (y; aliasSeqOf!["a", "b", "c"]) { static if (y == "a") continue pragma(msg, y); } fails. Seems like continue needs to

Re: Inline mixin

2017-03-14 Thread Daniel Kozak via Digitalmars-d-learn
Dne 14.3.2017 v 18:38 Inquie via Digitalmars-d-learn napsal(a): Many times I need to build a type using a string. I have to resort to building the entire expression/statement using the mixin: mixin("This is a long and complex expression where I only need to modify X") Is there any way to

Re: groupBy in D?

2017-03-14 Thread Daniel Kozak via Digitalmars-d-learn
Dne 14.3.2017 v 16:02 Russel Winder via Digitalmars-d-learn napsal(a): I am having a hard time Google-ing today. Pytho, Groovy, Kotlin, etc. have a "groupBy" function that takes a sequence and a key and creates a dictionary/associative array with keys the result of the key function on the

Re: listdir

2017-03-14 Thread Daniel Kozak via Digitalmars-d-learn
There is no such function in D2 You can use dirEntries https://dlang.org/phobos/std_file.html#.dirEntries.2 Dne 14.3.2017 v 16:04 hadas via Digitalmars-d-learn napsal(a): Hi, I'm trying to read all the txt files in specific path. I tried to use listdir function, but I get this error: Error:

Re: What is PostgreSQL driver is most stable?

2017-03-14 Thread Daniel Kozak via Digitalmars-d-learn
Dne 14.3.2017 v 14:21 Daniel Kozak napsal(a): Dne 14.3.2017 v 14:13 Suliman via Digitalmars-d-learn napsal(a): I need to develop App that should work on Linux and Windows. It need PostgreSQL driver. I tried Vadim's ddbc for PostgreSQL but it's fail on x64 version of PostgreSQL and possible

Re: What is PostgreSQL driver is most stable?

2017-03-14 Thread Daniel Kozak via Digitalmars-d-learn
Dne 14.3.2017 v 14:13 Suliman via Digitalmars-d-learn napsal(a): I need to develop App that should work on Linux and Windows. It need PostgreSQL driver. I tried Vadim's ddbc for PostgreSQL but it's fail on x64 version of PostgreSQL and possible will not on x64 PG on Linux (I can't test it

Re: Date formatting in D

2017-03-07 Thread Daniel Kozak via Digitalmars-d-learn
Dne 7.3.2017 v 21:29 aberba via Digitalmars-d-learn napsal(a): I've been trying to figure out an inbuilt functionality in phobos for formatting date. In my use case, I've been trying to format current Unix timestamp to something like "Thu, 08 Mar 2017 12:00:00 GMT". How do I go by this

Re: Date formatting in D

2017-03-07 Thread Daniel Kozak via Digitalmars-d-learn
Dne 7.3.2017 v 22:07 aberba via Digitalmars-d-learn napsal(a): On Tuesday, 7 March 2017 at 20:29:07 UTC, aberba wrote: I've been trying to figure out an inbuilt functionality in phobos for formatting date. In my use case, I've been trying to format current Unix timestamp to something like

Re: Date formatting in D

2017-03-07 Thread Daniel Kozak via Digitalmars-d-learn
I do not know? Is this some ISO/ANSI format for dates? If yes than we should add it. If no there is no reason. Dne 7.3.2017 v 22:07 aberba via Digitalmars-d-learn napsal(a): On Tuesday, 7 March 2017 at 20:29:07 UTC, aberba wrote: I've been trying to figure out an inbuilt functionality in

Re: How do I use CTFE to generate an immutable associative array at compile time?

2017-02-22 Thread Daniel Kozak via Digitalmars-d-learn
Yes this is how I mean it. Dne 22. 2. 2017 9:05 napsal uživatel "Jacob Carlborg via Digitalmars-d-learn" : > On 2017-02-21 23:49, H. S. Teoh via Digitalmars-d-learn wrote: > > That may appear to work, but I would *strongly* recommend against it, >> because what

Re: How do I use CTFE to generate an immutable associative array at compile time?

2017-02-21 Thread Daniel Kozak via Digitalmars-d-learn
I have similar issue and I beleive I was able to workaround that somehow, but it is so many years now :(. Have you tried enum dataLookup instead of immutable string[string] dataLookup Dne 21.2.2017 v 22:53 Chad Joan via Digitalmars-d-learn napsal(a): Hello all, I'm trying to make this work:

Re: Force inline

2017-02-21 Thread Daniel Kozak via Digitalmars-d-learn
Dne 21.2.2017 v 08:41 Daniel Kozak napsal(a): Dne 21.2.2017 v 08:31 Johan Engelen via Digitalmars-d-learn napsal(a): On Monday, 20 February 2017 at 13:16:15 UTC, Jonathan M Davis wrote: dmd is great for fast compilation and therefore it's great for development. However, while it produces

<    1   2   3   4   5   >