Re: Library design

2014-06-13 Thread Rutger via Digitalmars-d-learn
On Friday, 13 June 2014 at 05:54:02 UTC, TheFlyingFiddle wrote: On Friday, 13 June 2014 at 04:11:38 UTC, Rutger wrote: I'm trying to create a minimal tweening library in D based on the commonly used easing equations by Robert Penner (http://www.robertpenner.com/easing/). One of the goals with

Re: Working on a library: request for code review

2014-06-13 Thread Mike via Digitalmars-d-learn
On Thursday, 12 June 2014 at 19:30:06 UTC, Rene Zwanenburg wrote: I need to go. Please don't mind any typo's and untested code ;). Didn't take a look at writers yet, readers and util need some more scrutiny, but the main theme is: eliminate unnecessary temporary GC allocations. Thank you for

Re: Cannot alias null

2014-06-13 Thread via Digitalmars-d-learn
On Thursday, 12 June 2014 at 21:07:47 UTC, Tom Browder via Digitalmars-d-learn wrote: What I was really trying to do was D'ify C expressions like this: typedef ((struct t*)0) blah; This doesn't compile for me with GCC, and I don't know what it's supposed to mean. ((struct t*) 0) is a

Re: Cannot alias null

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 12 June 2014 at 22:54:20 UTC, Ali Çehreli wrote: On 06/12/2014 03:38 PM, monarch_dodra wrote: So there's something special about null. The difference is that null is an expression. It is the same limitation as not being able to alias a literal. alias zero = 0; alias

Re: Cannot alias null

2014-06-13 Thread Tom Browder via Digitalmars-d-learn
On Fri, Jun 13, 2014 at 7:59 AM, via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 12 June 2014 at 21:07:47 UTC, Tom Browder via Digitalmars-d-learn wrote: What I was really trying to do was D'ify C expressions like this: typedef ((struct t*)0) blah; This

Re: Dub. Mercurial (bitbucket.org). Projects deployment

2014-06-13 Thread Uranuz via Digitalmars-d-learn
Thanks for all the answers) 8. I have another more simple question about rdmd utility. It takes one *.d file and searches for all dependencies. What if I need to pass independent *.d file or *.ddoc file directly to dmd compiler? How could I do that using dmd? I have no idea how I could

Re: Cannot alias null

2014-06-13 Thread Philpax via Digitalmars-d-learn
On Friday, 13 June 2014 at 15:05:49 UTC, Tom Browder via Digitalmars-d-learn wrote: On Fri, Jun 13, 2014 at 7:59 AM, via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 12 June 2014 at 21:07:47 UTC, Tom Browder via Digitalmars-d-learn wrote: What I was really trying

Re: Cannot alias null

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 13 June 2014 at 15:05:49 UTC, Tom Browder via Digitalmars-d-learn wrote: So I'm not sure how to translate that into D. I do know my first attempt here doesn't work, even with it being surrounded by extern (C) {}: $ cat chdr.d struct t; struct t* t_ptr = null; This seems to work

Re: Cannot alias null

2014-06-13 Thread Tom Browder via Digitalmars-d-learn
On Fri, Jun 13, 2014 at 10:15 AM, monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 13 June 2014 at 15:05:49 UTC, Tom Browder via Digitalmars-d-learn wrote: So I'm not sure how to translate that into D. I do know my first attempt here doesn't work,

User defined forward range - foreach initializes f.r.

2014-06-13 Thread Andre via Digitalmars-d-learn
Hi, I have a template class List which should provide generic list functionality. In my use case, using a class instead a struct is more comfortable. Following unittest fails, although the forward range implements the save method. unittest { auto intList = new List!int(1,2,3);

Re: User defined forward range - foreach initializes f.r.

2014-06-13 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 13, 2014 at 08:14:11PM +0200, Andre via Digitalmars-d-learn wrote: Hi, I have a template class List which should provide generic list functionality. In my use case, using a class instead a struct is more comfortable. Following unittest fails, although the forward range

Re: User defined forward range - foreach initializes f.r.

2014-06-13 Thread Andre via Digitalmars-d-learn
Am 13.06.2014 20:22, schrieb H. S. Teoh via Digitalmars-d-learn: [...] Generally, it's a bad idea to conflate a container with a range over its contents. In this sense, built-in arrays are a very bad example, because they show precisely this sort of conflation. But they get away with it because

Re: User defined forward range - foreach initializes f.r.

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 13 June 2014 at 18:14:10 UTC, Andre wrote: Hi, I have a template class List which should provide generic list functionality. In my use case, using a class instead a struct is more comfortable. Following unittest fails, although the forward range implements the save method.

Initialization sequence of runtime environment

2014-06-13 Thread Tim via Digitalmars-d-learn
I recently posted another thread (regarding crt1.o: could not read symbols: Bad value - I'm creating a new thread because it's another problem) and I figured out that the following error: stack_bottom = 7fc98804ae18 thread_stack 0x4 /usr/sbin/mysqld(my_print_stacktrace+0x35)[0x8cea15]

Re: User defined forward range - foreach initializes f.r.

2014-06-13 Thread Ali Çehreli via Digitalmars-d-learn
I am making the following comment to have others confirm, as well as remind others about a potential problem. On 06/13/2014 11:14 AM, Andre wrote: unittest { auto intList = new List!int(1,2,3); [...] class List(T) { private T[] items; this(T[] items...) {

Re: User defined forward range - foreach initializes f.r.

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 13 June 2014 at 19:03:12 UTC, Ali Çehreli wrote: I am making the following comment to have others confirm, as well as remind others about a potential problem. On 06/13/2014 11:14 AM, Andre wrote: unittest { auto intList = new List!int(1,2,3); [...] class List(T) {

Why is stdin.byLine.writeln so slow?

2014-06-13 Thread Jyxent via Digitalmars-d-learn
I've been playing around with D and noticed that: stdin.byLine.writeln takes ~20 times as long as: foreach(line; stdin.byLine) writeln(line); I asked on IRC and this was suggested: stdin.byLine(KeepTerminator.yes).copy(stdout.lockingTextWriter) which is slightly faster than the foreach

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 13 June 2014 at 20:48:16 UTC, Jyxent wrote: I've been playing around with D and noticed that: stdin.byLine.writeln takes ~20 times as long as: foreach(line; stdin.byLine) writeln(line); I asked on IRC and this was suggested:

Re: Working on a library: request for code review

2014-06-13 Thread Mike Wey via Digitalmars-d-learn
On 06/12/2014 09:30 PM, Rene Zwanenburg wrote: I remember a function which does something like only only + canFind on one go. It would look something like header.colorMapDepth.among(16, 32); but I can't find it right now.. Maybe it was only proposed but never added.

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread Ali Çehreli via Digitalmars-d-learn
On 06/13/2014 02:08 PM, monarch_dodra wrote: Given this input: line 1 line2 Yo! Then stdin.byLine.writeln will produce this string: [line 1, line\t2, Yo!] Do you mean writeln() first generates an array and then prints that array? I've always imagined that it used the range interface

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread Jyxent via Digitalmars-d-learn
On Friday, 13 June 2014 at 21:08:08 UTC, monarch_dodra wrote: On Friday, 13 June 2014 at 20:48:16 UTC, Jyxent wrote: I've been playing around with D and noticed that: stdin.byLine.writeln takes ~20 times as long as: foreach(line; stdin.byLine) writeln(line); I asked on IRC and this was

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 13 June 2014 at 21:17:27 UTC, Ali Çehreli wrote: On 06/13/2014 02:08 PM, monarch_dodra wrote: Given this input: line 1 line2 Yo! Then stdin.byLine.writeln will produce this string: [line 1, line\t2, Yo!] Do you mean writeln() first generates an array and then prints that

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread Ali Çehreli via Digitalmars-d-learn
On 06/13/2014 03:02 PM, monarch_dodra wrote: No, it just receives a range, so it does range formating. eg: [ ~ Element ~ , ~ Element ... ]. It still looks like it could send the formatting characters as well as the elements separately to the output stream: [ Element , ... ] I am

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 13 June 2014 at 22:12:01 UTC, Ali Çehreli wrote: On 06/13/2014 03:02 PM, monarch_dodra wrote: No, it just receives a range, so it does range formating. eg: [ ~ Element ~ , ~ Element ... ]. It still looks like it could send the formatting characters as well as the elements

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 13, 2014 at 10:02:49PM +, monarch_dodra via Digitalmars-d-learn wrote: [...] That said, you can use one of D's most powerful formating abilities: Range formating: writefln(%-(%s\n%), stdin.byLine()); And BOOM. Does what you want. I freaking love range formatting. More info

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 13 June 2014 at 22:25:25 UTC, H. S. Teoh via Digitalmars-d-learn wrote: In C/C++, you'd have to manually write nested loops to print out the data, which may involve manually calling accessor methods, manually counting them, perhaps storing intermediate output fragments in

does there exist a dimensional analysis library for D?

2014-06-13 Thread Vlad Levenfeld via Digitalmars-d-learn
something similar to boost/units?

Does __gshared have shared semantics?

2014-06-13 Thread Mike Franklin via Digitalmars-d-learn
In other words, is 'shared __gshared' redundant?

Re: Does __gshared have shared semantics?

2014-06-13 Thread Kapps via Digitalmars-d-learn
On Saturday, 14 June 2014 at 01:24:05 UTC, Mike Franklin wrote: In other words, is 'shared __gshared' redundant? All __gshared does is makes the variable not go into thread-local storage, nothing more. Shared does this, as well as modify the type to be shared(T) instead of just T. So yes,

DMD Fails with fPIC error

2014-06-13 Thread Reuben via Digitalmars-d-learn
Hi, I'm new to D and am trying to compile a simple hello world program. I get the following error when compiling it: dmd test.d /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld: /opt/dmd-2.065/lib64/libphobos2.a(lifetime_488_4cd.o): relocation R_X86_64_32

Casts and @trusted

2014-06-13 Thread Anonymous via Digitalmars-d-learn
This seems to work from quick testing, but it has casts in get_ref that I want to avoid. cast(T*) refs[i] is obviously not @safe. cast(T*) _buffer[read].ptr doesn't seem necessary, since _buffer[read] is conceivably a T so _buffer[read].ptr should be a T*. But without it I get Error: cannot

Re: Casts and @trusted

2014-06-13 Thread Ali Çehreli via Digitalmars-d-learn
On 06/13/2014 06:56 PM, Anonymous wrote: @trusted void get_ref(TS strat=TS.cyclic)(size_t n, const(T*)[] refs) const nothrow { [...] cast(T*) refs[i] = cast(T*) _buffer[read].ptr; The left-hand side violates a promise: The function takes a slice where the elemenst

Universal Construction Syntax for Pointers?

2014-06-13 Thread Meta via Digitalmars-d-learn
I thought this was possible, but DMD 2.065 doesn't allow it, saying no constructor for int: int* p = new int(3); Is something like this planned for the future? I know we can already do: int n = int(3);

Re: does there exist a dimensional analysis library for D?

2014-06-13 Thread Philippe Sigaud via Digitalmars-d-learn
Hi Vlad, you can try David Nadlinger's std.units: http://klickverbot.at/code/units/std_units.html See the discussion at http://forum.dlang.org/thread/io1vgo$1fnc$1...@digitalmars.com From what I deemly remember of Boost/units, it's a bit less complete, but far easier to use.