Re: pragma(inline)

2015-12-30 Thread Daniel Kozak via Digitalmars-d-learn
V Wed, 30 Dec 2015 03:24:45 + Ilya via Digitalmars-d-learn napsáno: > Hi, > > Does `pragma(inline, true)` force DMD compiler to inline function > when `-inline` was _not_ defined? > > I am failing to get a good disassembled code with obj2asm/otool > :-( > > Best, Ilya pragma(inline), pr

Re: pragma(inline)

2015-12-30 Thread Daniel Kozak via Digitalmars-d-learn
V Wed, 30 Dec 2015 03:24:45 + Ilya via Digitalmars-d-learn napsáno: > Hi, > > Does `pragma(inline, true)` force DMD compiler to inline function > when `-inline` was _not_ defined? > > I am failing to get a good disassembled code with obj2asm/otool > :-( > > Best, Ilya No

Re: reduce a BitArray[]

2015-12-29 Thread Daniel Kozak via Digitalmars-d-learn
V Tue, 29 Dec 2015 17:42:26 + Alex Parrill via Digitalmars-d-learn napsáno: > On Tuesday, 29 December 2015 at 09:26:31 UTC, Alex wrote: > > The problem is, that the last line with the reduce does not > > compile. Why? > > If you get an error, it is imperative that you tell us what it is.

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 22 December 2015 at 18:27:12 UTC, cym13 wrote: ... I don't think there is anything in the standard library that would really help here as (if I read it correctly) it is mainly because of the conversion from ranges to arrays that this code is slow. Yes, it has been faster in past,

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 12:55:10 -0800 "H. S. Teoh via Digitalmars-d-learn" napsáno: > On Tue, Dec 22, 2015 at 08:54:35PM +0100, Daniel Kozák via > Digitalmars-d-learn wrote: > > V Tue, 22 Dec 2015 09:43:00 -0800 > > "H. S. Teoh via Digitalmars-d-learn" > >

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 21:10:54 + rumbu via Digitalmars-d-learn napsáno: > On Tuesday, 22 December 2015 at 20:52:07 UTC, rumbu wrote: > > On Tuesday, 22 December 2015 at 19:45:46 UTC, Daniel Kozák > > wrote: > >> V Tue, 22 Dec 2015 18:11:24 + > >&

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 20:52:07 + rumbu via Digitalmars-d-learn napsáno: > On Tuesday, 22 December 2015 at 19:45:46 UTC, Daniel Kozák wrote: > > V Tue, 22 Dec 2015 18:11:24 + > > rumbu via Digitalmars-d-learn > > > > napsáno: > > > >> On Tuesday

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 09:43:00 -0800 "H. S. Teoh via Digitalmars-d-learn" napsáno: > On Tue, Dec 22, 2015 at 05:23:11PM +, Andrew Chapman via > Digitalmars-d-learn wrote: [...] > > for({int i; i = 0;} i < num; i++) { > > //string s = to!string(i); > > Cust

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 17:15:27 + Andrew Chapman via Digitalmars-d-learn napsáno: > Sorry if this is a silly question but is the to! method from the > conv library the most efficient way of converting an integer > value to a string? > > e.g. > string s = to!string(100); > > I'm seeing a prett

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 18:39:16 + Ivan Kazmenko via Digitalmars-d-learn napsáno: > On Tuesday, 22 December 2015 at 18:11:24 UTC, rumbu wrote: > > On Tuesday, 22 December 2015 at 17:15:27 UTC, Andrew Chapman > > wrote: > >> Sorry if this is a silly question but is the to! method from > >> the

Re: Most performant way of converting int to string

2015-12-22 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 22 Dec 2015 18:11:24 + rumbu via Digitalmars-d-learn napsáno: > On Tuesday, 22 December 2015 at 17:15:27 UTC, Andrew Chapman > wrote: > > Sorry if this is a silly question but is the to! method from > > the conv library the most efficient way of converting an > > integer value to a

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 alter

Re: Socket - handling large numbers of incoming connections

2015-12-21 Thread Daniel Kozák via Digitalmars-d-learn
V Mon, 21 Dec 2015 20:53:14 + Jakob Jenkov via Digitalmars-d-learn napsáno: > On Monday, 21 December 2015 at 20:20:44 UTC, Stefan wrote: > > How about https://github.com/dcarp/asynchronous ? Asyncio > > Socket handling is sometimes quite nice. It's performance is > > okay for nearly no effo

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: %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: Reason for 'static struct'

2015-12-10 Thread Daniel Kozak via Digitalmars-d-learn
015 at 21:23:03 UTC, Daniel Kozák wrote: > >> V Wed, 09 Dec 2015 21:10:43 + >> Jon D via Digitalmars-d-learn >> napsáno: >> >> There is a fair bit of range related code in the standard library >>> structured like: >>> >

Re: Reason for 'static struct'

2015-12-09 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 09 Dec 2015 21:10:43 + Jon D via Digitalmars-d-learn napsáno: > There is a fair bit of range related code in the standard library > structured like: > > auto MyRange(Range)(Range r) > if (isInputRange!Range) > { > static struct Result > { >

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

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

Re: Reset all Members of a Aggregate Instance

2015-12-07 Thread Daniel Murphy via Digitalmars-d-learn
On 4/12/2015 8:38 AM, Chris Wright wrote: An object reference is just a pointer, but we can't directly cast it. So we make a pointer to it and cast that; the type system allows it. Now we can access the data that the object reference refers to directly. Casting is fine too: cast(void*)classRef

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: Can someone check this on win32 ?

2015-12-01 Thread Daniel Murphy via Digitalmars-d-learn
On 21/11/2015 10:46 PM, BBaz wrote: Seems to be fixed: __ import std.math; void main() {real function(real) c = &sin;} __ https://issues.dlang.org/show_bug.cgi?id=4541 At least it works on linux x86_64. It works because of https://github.com/D-Prog

Re: Something about Chinese Disorder Code

2015-12-01 Thread Daniel Murphy via Digitalmars-d-learn
On 25/11/2015 2:16 PM, Rikki Cattermole wrote: On 25/11/15 1:47 AM, Meta wrote: I'm pretty sure you can just do: wstring text = "my string"; Or auto text = "my string"w; The second one is correct yes. I'm just assuming that it isn't compiled into the executable. Either is fine. Non-suffi

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

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

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
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 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
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: 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: 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: Capturing __FILE__ and __LINE in a variadic templated function

2015-11-02 Thread Daniel N via Digitalmars-d-learn
On Monday, 2 November 2015 at 11:36:27 UTC, Nordlöw wrote: I want it to print the name of Arg in the closing as x is 11 See my previous comment: Arg -> Args[i].stringof

Re: Capturing __FILE__ and __LINE in a variadic templated function

2015-11-02 Thread Daniel N via Digitalmars-d-learn
On Monday, 2 November 2015 at 09:54:50 UTC, John Colvin wrote: Why can't I make Args a sequence of aliases? Works for me on multiple compilers. To be precise, this worked: Except it prints Arg instead of x, try: debug write(Args[i].stringof, " is ", Arg);

Re: D bindings for Bonjour

2015-10-28 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 28 Oct 2015 16:36:32 + Vincent R via Digitalmars-d-learn napsáno: > On Wednesday, 28 October 2015 at 16:12:08 UTC, Vincent R wrote: > > On Wednesday, 28 October 2015 at 16:09:02 UTC, Cauterite wrote: > >> On Wednesday, 28 October 2015 at 16:04:52 UTC, Vincent R wrote: > >>> [...]

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: 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: 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-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: Purity of std.conv.to!string

2015-09-27 Thread Daniel Murphy via Digitalmars-d-learn
On 27/09/2015 3:14 AM, cym13 wrote: On Saturday, 26 September 2015 at 17:08:00 UTC, Nordlöw wrote: Why is the following code not pure: float x = 3.14; import std.conv : to; auto y = x.to!string; ??? Is there a reason for it not being pure? If not, this is a serious problem as thi

Re: Weird behaviour with File.eof

2015-09-20 Thread Daniel Kozák via Digitalmars-d-learn
V Sun, 20 Sep 2015 20:17:36 + Dandyvica via Digitalmars-d-learn napsáno: > Hi all, > > I can't explain to myself this weird behavior: > > void main(string[] argv) > { > char[] line; > auto fh = File(argv[1]); > while (!fh.eof) { > writef("before readln eof=%s

Re: Simple template constraint question

2015-09-19 Thread Daniel Kozak via Digitalmars-d-learn
WhatMeWorry píše v So 19. 09. 2015 v 17:09 +: > Does D provide complete template constraint granularity? > > In other words, I want to only accept structs in the template > below. > I've find the isAggregateType which is close but no cigar. Am I > missing > some other filters? > > And a mor

Re: foreach(line; f.byLine) produces core.exception.InvalidMemoryOperationError@(0) in 2.067 but not 2.066

2015-09-15 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 15 Sep 2015 13:56:36 + Andrwe Brown via Digitalmars-d-learn wrote: > Hi, > > I'm trying to read a file line by line, and I get a > core.exception.InvalidMemoryOperationError@(0), even after > reducing the program to: > > import std.stdio; > > void main() > { >File f = File("

Re: friends with phobos, workaround?

2015-09-11 Thread Daniel N via Digitalmars-d-learn
On Thursday, 10 September 2015 at 13:19:08 UTC, Adam D. Ruppe wrote: On Thursday, 10 September 2015 at 08:22:29 UTC, Daniel N wrote: this(string caller = __MODULE__)(int val) if(caller == "std.conv") // Use scoped!Awesome That's disgustingly genius. I'm a bit jealou

Re: Huge output size for simple programs

2015-09-11 Thread Daniel N via Digitalmars-d-learn
On Friday, 11 September 2015 at 11:15:33 UTC, NX wrote: I compile a simple hello world program in C and the results: hello_world.o -> 1.5 KB hello_world (linux executable) -> 8.5 KB If you care about binary sizes, use ldc2: ldc 225544 bytes (stripped + writeln) ldc 175736 bytes (stripped + p

Re: What is the difference between D and C++ regarding Unique, RefCounted and Scoped?

2015-09-10 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 10 Sep 2015 11:38:35 + "Gary Willoughby" wrote: > On Wednesday, 9 September 2015 at 23:22:49 UTC, ponce wrote: > > - RefCounted > > > > Only for D structs. std::shared_ptr works for all. > > RefCounted works with classes as well. > > http://dlang.org/phobos/std_typecons.html#.RefCo

Re: friends with phobos, workaround?

2015-09-10 Thread Daniel N via Digitalmars-d-learn
On Thursday, 10 September 2015 at 08:22:29 UTC, Daniel N wrote: import std.typecons; class Awesome1 { private: int val; this(string caller = __MODULE__)(int val) if(caller == "std.conv") // Use scoped!Awesome { this.val = val; } } class Awesome2 { private: int v

Re: friends with phobos, workaround?

2015-09-10 Thread Daniel N via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 23:44:14 UTC, Idan Arye wrote: How about using a mixin template(http://dlang.org/template-mixin.html)? Thanks, it's a good solution. My only reservation is I would prefer to find a way to directly invoke a symbol in std.* as otherwise different frameworks m

friends with phobos, workaround?

2015-09-09 Thread Daniel N via Digitalmars-d-learn
For the record, I think D made the right decision... omitting friends. However there's one case in particular which I find useful, anyone see a good workaround for this? #include class Friendly { private: int val; Friendly(int&& val) : val(val) {} friend std::unique_ptr std::make_uni

Re: Appenders and Arrays

2015-09-01 Thread Daniel Kozak via Digitalmars-d-learn
Dne 1.9.2015 v 19:20 Steven Schveighoffer via Digitalmars-d-learn napsal(a): On 9/1/15 12:49 PM, default0 wrote: Hello A simple thing I stumbled across: int main() { import std.stdio; import std.range; int[] d; d ~= 10; d ~= 20; d.put(5); writeln(d);

Re: Array initialization with Struct templates

2015-08-31 Thread Daniel N via Digitalmars-d-learn
On Monday, 31 August 2015 at 05:38:54 UTC, Jonathan M Davis wrote: So, you're going to need to pass it a Chameleon!(float, purpose.POSITIONAL) and a Chameleon!(float, purpose.COLOR_ONLY color), not 6 doubles - either that, or you're going to need to declare a constructor for VertexData which ta

Re: What is this function call operator?

2015-08-27 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 27 Aug 2015 15:18:22 + "Gary Willoughby" wrote: > If you visit this link: > > http://dlang.org/phobos/std_traits.html#isCallable > > There is this paragraph: > > "Detect whether T is a callable object, which can be called with > the function call operator (...)." > > What is thi

Re: order of declaration/definition

2015-08-27 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 27 Aug 2015 13:26:11 + vitus via Digitalmars-d-learn wrote: > On Thursday, 27 August 2015 at 13:14:24 UTC, Daniel Kozák wrote: > > > > On Thu, 27 Aug 2015 13:01:02 + > > vitus via Digitalmars-d-learn > > wrote: > >> > > > > work

Re: order of declaration/definition

2015-08-27 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 27 Aug 2015 13:01:02 + vitus via Digitalmars-d-learn wrote: > On Monday, 24 August 2015 at 01:01:13 UTC, John Colvin wrote: > > enum A = 1; > > enum B = C; //Error > > static if(A) > > enum C = 0; > > enum D = C; //OK > > > > Is order supposed to matter here? > > Beter: > > enu

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 12:29:26 + "yawniek" wrote: > On Friday, 7 August 2015 at 11:45:00 UTC, Daniel Kozak wrote: > > On Friday, 7 August 2015 at 09:12:32 UTC, yawniek wrote: > >> [...] > > > > Can you try it without write operation (comment out

Re: zlib performance

2015-08-07 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 7 August 2015 at 09:12:32 UTC, yawniek wrote: On Friday, 7 August 2015 at 08:50:11 UTC, Daniel Kozák wrote: > ldc[2] -O -release -boundscheck=off -singleobj app.d ldc 0.15.2 beta2 2.86s user 0.55s system 77% cpu 4.392 total v2.068-devel-8f81ffc 2.86s user 0.67s system 78%

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 08:42:45 + "yawniek" wrote: > On Friday, 7 August 2015 at 08:24:11 UTC, Daniel Kozák wrote: > > > can you try it with ldc? > > > > ldc[2] -O -release -boundscheck=off -singleobj app.d > > > ldc 0.15.2 beta2 > 2.86s use

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 08:13:01 + "yawniek" wrote: > On Friday, 7 August 2015 at 08:05:01 UTC, Daniel Kozák wrote: > > import > > std.zlib, > > std.file, > > std.stdio, > > std.conv; > > > > void main(string[] args) > >

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 08:13:01 + "yawniek" wrote: > On Friday, 7 August 2015 at 08:05:01 UTC, Daniel Kozák wrote: > > import > > std.zlib, > > std.file, > > std.stdio, > > std.conv; > > > > void main(string[] args) > >

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 7 Aug 2015 09:43:25 +0200 Daniel Kozák wrote: > > On Fri, 07 Aug 2015 07:36:39 + > "yawniek" wrote: > > > On Friday, 7 August 2015 at 07:29:15 UTC, Daniel Kozák wrote: > > > Which compiler and version. There has been some performance >

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 08:01:27 + "yawniek" wrote: > On Friday, 7 August 2015 at 07:48:25 UTC, yawniek wrote: > > On Friday, 7 August 2015 at 07:43:25 UTC, Daniel Kozák wrote: > > the fastest version i could come up so far is below. > > std.conv slows it down

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 07:19:43 + "yawniek" wrote: > hi, > > unpacking files is kinda slow, probably i'm doing something wrong. > > below code is about half the speed of gnu zcat on my os x machine. > why? > > why do i need to .dup the buffer? It depends. In your case you don't need to. by

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 07:36:39 + "yawniek" wrote: > On Friday, 7 August 2015 at 07:29:15 UTC, Daniel Kozák wrote: > > Which compiler and version. There has been some performance > > problem with IO on OSX, it should be fixed in 2.068 release > > i'm on

Re: zlib performance

2015-08-07 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 07 Aug 2015 07:19:43 + yawniek via Digitalmars-d-learn wrote: > hi, > > unpacking files is kinda slow, probably i'm doing something wrong. > > below code is about half the speed of gnu zcat on my os x machine. > why? > > why do i need to .dup the buffer? > can i get rid of the cas

Re: [dmd2.068] Bug or future?

2015-08-07 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 7 August 2015 at 06:26:21 UTC, VlasovRoman wrote: I have some code: import std.stdio; auto dot(T, R)(T x, R y) { return x * y; } struct Vector(T) { alias selftype = Vector!T; int len = 5; pure: const @property{ static if( is( typeof( dot( selftype.init, self

Re: Concurrency Confusion

2015-08-04 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 04 Aug 2015 10:29:55 + "岩倉 澪" wrote: > On Tuesday, 4 August 2015 at 08:35:10 UTC, Dicebot wrote: > > auto output = receiveOnly!(immutable(Bar)[]); > > Won't message passing like this result in an expensive copy No it will copy only struct containing length and pointer to data,

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Daniel Kozak via Digitalmars-d-learn
V Sat, 01 Aug 2015 20:20:14 + NX via Digitalmars-d-learn napsáno: > On Saturday, 1 August 2015 at 19:33:26 UTC, Daniel Kozak wrote: > > My fault It is not on stack, but still it is a static allocation > > I think you're misusing "static allocation" and "st

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Daniel Kozak via Digitalmars-d-learn
V Sat, 01 Aug 2015 19:21:36 + NX via Digitalmars-d-learn napsáno: > On Saturday, 1 August 2015 at 18:50:09 UTC, Daniel Kozak wrote: > > No you don't. You still use static allocation for array > > Can clarify why does that happen and I still suspect it's a >

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Daniel Kozak via Digitalmars-d-learn
V Sat, 01 Aug 2015 19:16:16 + NX via Digitalmars-d-learn napsáno: > On Saturday, 1 August 2015 at 18:47:00 UTC, Daniel Kozak wrote: > > Still same problem, You can`t allocate more then 16M on stack. > > Use dynamic allocation > > I don't think "new MyStruc

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Daniel Kozak via Digitalmars-d-learn
On Saturday, 1 August 2015 at 18:07:51 UTC, NX wrote: On Saturday, 1 August 2015 at 17:29:54 UTC, Adam D. Ruppe wrote: Sorry, I can't see _the_ point in that. I understand that could be a problem if it was a "global" array but this scenery is completely wrong in my view. I'm already going to d

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Daniel Kozak via Digitalmars-d-learn
V Sat, 01 Aug 2015 18:07:50 + NX via Digitalmars-d-learn napsáno: > On Saturday, 1 August 2015 at 17:29:54 UTC, Adam D. Ruppe wrote: > > On Saturday, 1 August 2015 at 17:22:40 UTC, NX wrote: > >> I wonder if the followings are compiler bugs: > > > > No, it is by design, the idea is to keep st

Re: Why approxEqual not working for integers in dmd 2068-b2

2015-07-28 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 28 Jul 2015 02:16:56 + "lobo" wrote: > Hi all, > > I have a bunch of unittests for template code taking any numeric > type. Because I'm lazy I just use the approxEqual for both > floating point and integer comparisons in these tests. > > In DMD 2067.1 everthing compiled OK but in

Re: Why approxEqual not working for integers in dmd 2068-b2

2015-07-28 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 28 Jul 2015 08:50:53 +0200 Daniel Kozák wrote: > > On Tue, 28 Jul 2015 02:16:56 + > "lobo" wrote: > > I would say it is a compiler bug. > > consider this: > > bool some(real x, real y) { > return true; > } > >

Re: Why approxEqual not working for integers in dmd 2068-b2

2015-07-27 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 28 Jul 2015 02:16:56 + "lobo" wrote: > Hi all, > > I have a bunch of unittests for template code taking any numeric > type. Because I'm lazy I just use the approxEqual for both > floating point and integer comparisons in these tests. > > In DMD 2067.1 everthing compiled OK but in

Re: [Rosettacode] sum of powers conjecture

2015-07-26 Thread Daniel N via Digitalmars-d-learn
On Sunday, 26 July 2015 at 18:40:59 UTC, bearophile wrote: I've translated the C++ entry to D as third D entry, but it's not a good translation, I've just converted iterators to pointers instead of using ranges (the resulting speed is acceptable). You're welcome to improve it: http://rosettac

Re: What D really needs :D

2015-07-25 Thread Daniel Kozak via Digitalmars-d-learn
On Saturday, 25 July 2015 at 18:30:16 UTC, Daniel Kozak wrote: https://github.com/avinassh/rockstar?utm_content=buffer64b3c&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer Wrong forum, someone put learn on top. http://forum.dlang.org/post/ooybhdoonxoxkzdsz...@forum.dlang.org

Re: static linking

2015-07-25 Thread Daniel Kozak via Digitalmars-d-learn
On Sat, 25 Jul 2015 18:02:46 + Laeeth Isharc via Digitalmars-d-learn wrote: > Hi. > > Is static linking with dmd still broken on linux? If so, can I > link statically with gdc or ldc, and if so how? > > https://issues.dlang.org/show_bug.cgi?id=12268 > > I am trying to compile a D binary

What D really needs :D

2015-07-25 Thread Daniel Kozak via Digitalmars-d-learn
https://github.com/avinassh/rockstar?utm_content=buffer64b3c&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer

Re: idiom for C error strings

2015-07-21 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 21 Jul 2015 12:27:55 + "yawniek" wrote: > whats the proper way to use/wrap C functions that expect a error > string buffer > e.g.: > somefun(T param1, char* errstr, size_t errstr_size) > in D ? > dynamic: auto buf = new char[size]; somefun(param1, buf.ptr, buf.length); or some

Re: How to use core.thread.Thread

2015-07-16 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 16 Jul 2015 07:57:10 + aki via Digitalmars-d-learn wrote: > I can't resolve the compile errors: > > import core.thread; > class DerivedThread : Thread { > int count = 0; > this() { > super(&run); > } > private void run() { > inc();

Re: Weird behavior of "this" in a subclass, I think?

2015-07-15 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 16 Jul 2015 00:18:30 + seashell86 via Digitalmars-d-learn wrote: > So I've been mostly just toying around with D as it seems like it > will end up being a strong language for game development both now > and even moreso in the future. That being said, I'm perplexed by > using this

Re: Casting random type to random struct - is this a bug?

2015-07-15 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 15 Jul 2015 15:45:43 + "rumbu" wrote: > struct S { int a, b; } > auto s = cast(S)10; > //compiles and sets s.a to 10. > > It works also for any other type, if the structure contains a > member of that type in the first position. > > Is this normal behaviour? Yes, this is OK If y

Re: Casting random type to random struct - is this a bug?

2015-07-15 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 15 Jul 2015 11:57:01 -0400 Steven Schveighoffer wrote: > On 7/15/15 11:45 AM, rumbu wrote: > > struct S { int a, b; } > > auto s = cast(S)10; > > //compiles and sets s.a to 10. > > > > It works also for any other type, if the structure contains a > > member of that type in the first posi

Re: goroutines vs vibe.d tasks

2015-07-01 Thread Daniel Kozák via Digitalmars-d-learn
Same problem still extreamly slow On Wed, 01 Jul 2015 03:28:01 + "rsw0x" wrote: > On Tuesday, 30 June 2015 at 15:18:36 UTC, Jack Applegame wrote: > > Just creating a bunch (10k) of sleeping (for 100 msecs) > > goroutines/tasks. > > > > Compilers > > go: go version go1.4.2 linux/amd64 >

Re: Bug or feature?

2015-06-30 Thread Daniel Kozák via Digitalmars-d-learn
On Mon, 29 Jun 2015 05:04:36 -0700 Jonathan M Davis via Digitalmars-d-learn wrote: > On Sunday, June 28, 2015 11:37:59 Jack Applegame via > Digitalmars-d-learn wrote: > > I don't see any reason why it should not compile. > > > > import std.array; > > import std.range; > > import std.algorithm; >

Re: Struct vs. Class

2015-06-26 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 26 Jun 2015 11:11:15 + Chris via Digitalmars-d-learn wrote: > I have still some classes lying around in my code. As threading > is becoming more and more of an issue, classes and OOP in general > turn out to be a nuisance. It's not so hard to turn the classes > into structs, a lot

Re: Struct vs. Class

2015-06-26 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 26 Jun 2015 11:11:15 + Chris via Digitalmars-d-learn wrote: > I have still some classes lying around in my code. As threading > is becoming more and more of an issue, classes and OOP in general > turn out to be a nuisance. It's not so hard to turn the classes > into structs, a lot

Re: Abstract sockets (linux)

2015-06-25 Thread Daniel Kozak via Digitalmars-d-learn
On Thu, 25 Jun 2015 15:56:04 + freeman via Digitalmars-d-learn wrote: > I am having trouble using abstract sockets on Linux. > > Here is sample python code that works, which works: > ptm_sockname = "\0/var/run/ptmd.socket" > sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

Re: Return types of the methods of a struct

2015-06-19 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 19 Jun 2015 13:52:52 + Quentin Ladeveze via Digitalmars-d-learn wrote: > On Friday, 19 June 2015 at 13:38:45 UTC, Steven Schveighoffer > wrote: > > > > Does this work for you, or is there a further expectation? > > > > auto asTuple() { return Tuple!(int, "a", ...)(a, b, > > stringV

Re: Calling a cpp function from d

2015-06-16 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 16 Jun 2015 13:01:09 + via Digitalmars-d-learn wrote: > On Tuesday, 16 June 2015 at 12:42:16 UTC, C2D wrote: > > On Tuesday, 16 June 2015 at 12:31:23 UTC, John Chapman wrote: > >> On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote: > >>> BOOL result = SHGetFolderPath(null, 0x23, nul

Re: Calling a cpp function from d

2015-06-16 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 16 Jun 2015 12:26:45 + C2D via Digitalmars-d-learn wrote: > Hi, > I encountered the following error: > > Error: function files.SHGetFolderPath (void* hwndOwner, int > nFolder, void* hToken, uint dwFlags, char* pszPath) is not > callable using argument types (typeof(null), int, typ

Re: How to avoid multiple spelling `import`

2015-06-16 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 16 Jun 2015 11:45:22 + Dennis Ritchie via Digitalmars-d-learn wrote: > Maybe not everyone needs these features. But, unfortunately, I > often use a lot of imported modules. And use every time the word > `import` very bad. > > version (none) { > import std.math, > std.conv,

Re: Qualified destructors / immutable objects

2015-06-13 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 12 June 2015 at 15:36:22 UTC, anonymous wrote: no need for ~this() to modify immutable data: class C { int a; this(int a) { this.a = a; } } struct S { C elem = new C(42); } void main() { import std.stdio; immutable(S) s1;

Re: Shortest way to allocate an array and initialize it with a specific value.

2015-06-11 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 11 Jun 2015 11:43:25 + via Digitalmars-d-learn wrote: > On Thursday, 11 June 2015 at 08:33:46 UTC, Daniel Kozák wrote: > > On Wed, 10 Jun 2015 20:22:17 + > > Adel Mamin via Digitalmars-d-learn > > > > wrote: > > > >> ubyte[5] a = 0x

Re: Encapsulate return value in scoped

2015-06-11 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 11 Jun 2015 09:01:04 + Yuxuan Shui via Digitalmars-d-learn wrote: > A x = scoped!A(10); use auto x = scoped!A(10);

Re: Shortest way to allocate an array and initialize it with a specific value.

2015-06-11 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 10 Jun 2015 20:22:17 + Adel Mamin via Digitalmars-d-learn wrote: > ubyte[5] a = 0xAA; // Fine. Five 0xAA bytes. > auto a2 = new ubyte[5]; // Fine. Five 0 bytes. > Now, let's say, I want to allocate an array of a size, derived at > run time, and initialize it to some non-zero value at

Re: Utf8 to Utf32 cast cost

2015-06-08 Thread Daniel Kozak via Digitalmars-d-learn
On Mon, 08 Jun 2015 18:16:57 + Anonymouse via Digitalmars-d-learn wrote: > On Monday, 8 June 2015 at 11:44:47 UTC, Daniel Kozák wrote: > > No difference even with GC.disable() results are same. > > Profile! Callgrind is your friend~ Yep, but I dont care, I am the one who

Re: Utf8 to Utf32 cast cost

2015-06-08 Thread Daniel Kozák via Digitalmars-d-learn
On Mon, 08 Jun 2015 11:32:07 + Kagamin via Digitalmars-d-learn wrote: > On Monday, 8 June 2015 at 10:59:45 UTC, Daniel Kozák wrote: > > import std.conv; > > import std.utf; > > import std.datetime; > > import std.stdio; > > > > void f0() { > >

Re: Utf8 to Utf32 cast cost

2015-06-08 Thread Daniel Kozak via Digitalmars-d-learn
On Monday, 8 June 2015 at 11:06:07 UTC, Daniel Kozák wrote: On Mon, 08 Jun 2015 10:51:53 + weaselcat via Digitalmars-d-learn wrote: On Monday, 8 June 2015 at 10:49:59 UTC, Ilya Yaroshenko wrote: > On Monday, 8 June 2015 at 10:42:00 UTC, Kadir Erdem Demir > wrote: >> I wa

<    1   2   3   4   5   6   7   8   9   10   >