Re: Fastest Way to Append Multiple Elements to an Array

2014-12-19 Thread anonymous via Digitalmars-d-learn
On Friday, 19 December 2014 at 14:41:07 UTC, Anonymous wrote: What a big surprise. If you make an array of struct, each item of your array has the length of the struct. structs a values. If you want to append a struct to an array just append a pointer to the struct: -- struct arg{uint

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-19 Thread anonymous via Digitalmars-d-learn
On Saturday, 20 December 2014 at 00:15:21 UTC, MarcelDuchamp wrote: You've forget the array of ref version. (append the address of the first data) What array of ref version? Sounds like it would be a different data structure, which would be beyond the scope the topic. And adding S to an array

Re: Referring to alias parameters in a mixin template

2014-12-17 Thread anonymous via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 02:34:16 UTC, aldanor wrote: On Wednesday, 17 December 2014 at 02:12:52 UTC, anonymous wrote: Sure, straight forward: mixin template makeProperty(T, string name, alias func) { mixin(T %s() @property { return func(); }.format(name)); }

Re: Referring to alias parameters in a mixin template

2014-12-17 Thread anonymous via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 15:40:25 UTC, aldanor wrote: On Wednesday, 17 December 2014 at 12:49:10 UTC, anonymous wrote: [...] As to if there were `T` or `func` in the target scope, they'd be shadowed by the template parameters, no matter if there's a string mixin or not. That makes

Re: Referring to alias parameters in a mixin template

2014-12-16 Thread anonymous via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 01:14:36 UTC, aldanor wrote: A partial solution would be something like this: mixin template makeProperty(T, string name, alias func) { enum p = makeUnnamedProperty!(T, func); mixin(enum %s = p;.format(name)); // or alias } however now

Re: Referring to alias parameters in a mixin template

2014-12-16 Thread anonymous via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 01:49:14 UTC, aldanor wrote: Wonder if this is doable within a single mixin template without using makeUnnamedProperty? Sure, straight forward: mixin template makeProperty(T, string name, alias func) { mixin(T %s() @property { return func();

Re: mixin template and const property qualifier?

2014-12-15 Thread anonymous via Digitalmars-d-learn
On Monday, 15 December 2014 at 23:14:30 UTC, aldanor wrote: Could someone please explain why the following doesn't compile with const qualifier while it does work without it? /* test.d */ module test; mixin template Foo() { mixin(@property int bar() const { return foo; }); } int foo =

Re: Sargon component library now on Dub

2014-12-14 Thread anonymous via Digitalmars-d-announce
On Sunday, 14 December 2014 at 13:31:57 UTC, disapoint wrote: On Sunday, 14 December 2014 at 03:26:56 UTC, Walter Bright wrote: http://code.dlang.org/packages/sargon These two modules failed to generate much interest in incorporating them into Phobos, but I'm still rather proud of them :-)

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-14 Thread anonymous via Digitalmars-d-learn
On Sunday, 14 December 2014 at 23:52:15 UTC, zeljkog wrote: On 15.12.14 00:16, Nordlöw wrote: or some other trick? void append(T, Args...)(ref T[] arr, Args args){ arr.length += args.length; foreach(i, e; args) arr[$ - args.length + i] = args[i]; } void main() { int[] arr = [1, 2,

Re: Fast matrix struct

2014-12-14 Thread anonymous via Digitalmars-d-learn
On Sunday, 14 December 2014 at 22:14:55 UTC, Ryan wrote: I'm writing a Matrix struct that I plan to use for some number crunching, which will be intensive at times. So I want it to be fast. Will I do better by manually managing the memory myself with malloc and free in the

Re: Very short anonymous survey

2014-12-10 Thread Anonymous via Digitalmars-d
On Wednesday, 10 December 2014 at 08:02:25 UTC, Kagamin wrote: The form doesn't accept my input. Just provide your cool build system so people could use it to build the library. Yeah, you'll be able to build the library yourself (or download builds other people make, even). The survey is so I

Re: Very short anonymous survey

2014-12-10 Thread Anonymous via Digitalmars-d
On Wednesday, 10 December 2014 at 08:29:51 UTC, Martin Drašar via Digitalmars-d wrote: Dne 10.12.2014 v 6:33 Anonymous via Digitalmars-d napsal(a): Hello all, If I could have a minute of your time for a short anonymous survey regarding D libraries and tools, I'd really appreciate it. http

Re: Very short anonymous survey

2014-12-10 Thread Anonymous via Digitalmars-d
On Wednesday, 10 December 2014 at 15:24:13 UTC, BBaz wrote: On Wednesday, 10 December 2014 at 05:33:20 UTC, Anonymous wrote: Hello all, If I could have a minute of your time for a short anonymous survey regarding D libraries and tools, I'd really appreciate it.

Very short anonymous survey

2014-12-09 Thread Anonymous via Digitalmars-d
Hello all, If I could have a minute of your time for a short anonymous survey regarding D libraries and tools, I'd really appreciate it. http://goo.gl/forms/lMrHRr335C This is explained further in the link above, but for context: I'm a developer working on a library for D that I need for

Re: How do i use std.functional.binaryFun?

2014-12-08 Thread anonymous via Digitalmars-d-learn
On Monday, 8 December 2014 at 20:08:35 UTC, Gary Willoughby wrote: import std.stdio; import std.functional; class Foo(T, alias greater = a b) if (is(typeof(binaryFun!(greater)(T.init, T.init)) == bool)) { private alias compare = binaryFun!(greater); public this() {

Re: Accented Characters and Counting Syllables

2014-12-07 Thread anonymous via Digitalmars-d-learn
On Saturday, 6 December 2014 at 22:37:19 UTC, Nordlöw wrote: Given the fact that static assert(é.length == 2); I was surprised that static assert(é.byCodeUnit.length == 2); static assert(é.byCodePoint.length == 2); string already iterates over code points. So byCodePoint doesn't

can't build git head phobos

2014-11-30 Thread anonymous via Digitalmars-d
Git head dmd and druntime build fine, but phobos hangs at (shortened): ../dmd/src/dmd -I../druntime/import -w -m64 -O -release -lib -ofgenerated/linux/release/64/libphobos2.a ../druntime/lib/libdruntime-linux64.a [... *.d ...] [... *.o ...] This used to finish in a couple of seconds. Now it

Re: can't build git head phobos

2014-11-30 Thread anonymous via Digitalmars-d
On Sunday, 30 November 2014 at 12:22:58 UTC, anonymous wrote: I'm testing with fresh clones from Github: Seems to be an issue with my setup. Testing on a fresh user, phobos builds without problems.

Re: can't build git head phobos

2014-11-30 Thread anonymous via Digitalmars-d
On Sunday, 30 November 2014 at 12:41:38 UTC, anonymous wrote: Seems to be an issue with my setup. Testing on a fresh user, phobos builds without problems. Alright, traced it down. I have a copy of gdc lying around. Its /bin/ was in my $PATH. Apparently, gdc's g++ caused the trouble. When I

Re: What am I missing? Pure constructor behaves differently when assigning string member

2014-11-29 Thread anonymous via Digitalmars-d-learn
On Saturday, 29 November 2014 at 09:41:00 UTC, jostly wrote: I can't find a way to use a pure constructor to create both mutable and immutable instances of the same class, when one of the fields I assign is a string. [...] The question is: am I missing something that would make it possible to

Re: Programming in D book, draft of the first print edition and eBook formats

2014-11-26 Thread Anonymous via Digitalmars-d-announce
Thx, your book's just helped me last night (opSlice template not well explained in the official html). Two questions: - do you know that your website has serious design issue ? - does paper version mean no more free pdf/ebook ?

Re: Casting in Safe D

2014-11-23 Thread anonymous via Digitalmars-d-learn
On Sunday, 23 November 2014 at 19:37:45 UTC, Nordlöw wrote: I just noticed that void foo() @safe pure nothrow { void[] void_array = new void[3]; auto ubyte_array = cast(ubyte[])void_array; auto short_array = cast(short[])void_array; } compiles but gives a object.Error@(0): array

Re: lazy void vs int delegate() as overloads - bug or illegal use of overloading?

2014-11-22 Thread anonymous via Digitalmars-d
On Saturday, 22 November 2014 at 15:16:42 UTC, Johan Östling wrote: void execute(lazy void f) I think it's a bug that the compiler accepts a lazy void parameter. It errors out on a non-lazy void parameter with cannot have parameter of type void. lazy shouldn't somehow enable void

Re: overiding mutable methods in immutable classes

2014-11-22 Thread anonymous via Digitalmars-d-learn
On Saturday, 22 November 2014 at 02:37:21 UTC, Eric wrote: I know I can make a class immutable, but the problem is I want to constrain a template parameter to only immutable types, and I want to use class types. template Foo(T : immutable Object) Accepts immutable(Object) and other immutable

Re: overiding mutable methods in immutable classes

2014-11-22 Thread anonymous via Digitalmars-d-learn
On Saturday, 22 November 2014 at 15:00:00 UTC, Eric wrote: Yes, but if I don't declare the class T as immutable, I don't think this constraint will work. You're mistaken. It works just fine. class X /* not immutable */ { private int x; this(int x) pure { this.x = x; } } template

Re: overiding mutable methods in immutable classes

2014-11-22 Thread anonymous via Digitalmars-d-learn
On Saturday, 22 November 2014 at 17:40:42 UTC, Eric wrote: Yes, but this is what I really want: class X(T : immutable Object) { private T x; this(T x) pure { this.x = x; } } class Y { private int x; this(int x) pure { this.x = x; } } void main() { immutable(Y) y = new

Re: how to compare the type of a subclass

2014-11-21 Thread anonymous via Digitalmars-d-learn
On Friday, 21 November 2014 at 22:15:37 UTC, Eric wrote: Suppose I have: module test; class X { } class Y : X { } Y y = new Y; X x = y; assert(is(typeof(x) == test.Y); // this assertion will fail assert(typeid(x).toString() == test.Y); // this assertion will pass Is there a way I can

Re: how to compare the type of a subclass

2014-11-21 Thread anonymous via Digitalmars-d-learn
On Friday, 21 November 2014 at 22:30:52 UTC, Eric wrote: On Friday, 21 November 2014 at 22:25:32 UTC, anonymous wrote: On Friday, 21 November 2014 at 22:15:37 UTC, Eric wrote: [...] class X { } class Y : X { } Y y = new Y; X x = y; [...] I have't quite mastered the whole is/typeof/typeid

Re: overiding mutable methods in immutable classes

2014-11-21 Thread anonymous via Digitalmars-d-learn
On Saturday, 22 November 2014 at 00:24:39 UTC, Eric wrote: immutable class X { private int x; this(int x) { this.x = x; } ... override size_t toHash(); // error: can't override mutable method } Since toHash() cannot be overridden in an immutable class, is there a work-around?

Re: Compiler error with slices, .dup and ref Parameter

2014-11-20 Thread anonymous via Digitalmars-d-learn
On Thursday, 20 November 2014 at 09:20:34 UTC, Ali Çehreli wrote: Judging from the name init(), I don't think you need ref anyway. thanks for the explanation. I can't remove the ref because it is Main.init in gtkd. A simple solution is init(args) I just tried to remove a non-GTK argument (a

Re: Recursive template

2014-11-15 Thread anonymous via Digitalmars-d-learn
On Saturday, 15 November 2014 at 18:30:00 UTC, Eric wrote: Hi - I've never designed a recursive template before, but I think that would solve my problem. What I would like is someting like this: class X(V, K...) { // I want to declare a type based on K and V such // that for X!(V,

Re: Delegates and C function pointers

2014-11-08 Thread anonymous via Digitalmars-d-learn
On Saturday, 8 November 2014 at 12:23:45 UTC, Nicolas Sicard wrote: I would like to register a D delegate to a C API that takes a function pointer as a callback and a void* pointer to pass data to this callback. My solution is in http://dpaste.dzfl.pl/7d9b504b4b965. Is this code correct? Is

Re: std.array.array and immutable elements

2014-11-07 Thread anonymous via Digitalmars-d-learn
On Friday, 7 November 2014 at 14:57:56 UTC, ketmar via Digitalmars-d-learn wrote: `map` cannot return range with immutable elements, 'cause they are obviously generated by program, and therefore aren't immutable. That's not true. Runtime generated values can be immutable just fine. And it's

Re: Reading unicode string with readf (%s)

2014-11-04 Thread anonymous via Digitalmars-d-learn
On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: Hi! The following code does not correctly handle Unicode strings. - import std.stdio; void main () { string s; readf (%s, s); write (s); } - Example input (Test. in cyrillic): - Тест. -

Re: Pointer across threads

2014-11-04 Thread anonymous via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 12:47:11 UTC, Chris wrote: The following struct DATA { short* data; size_t len; } // data and len are provided by a C function // ... auto data = mymodule.getSpeechData(); // cast to immutable, because of concurrency immutable short* tmp =

Re: Pointer across threads

2014-11-04 Thread anonymous via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 14:36:19 UTC, Chris wrote: I'm still curious, though, how D handles this internally, because data.data is still mutable while the other reference to the same address (tmp) is not. What if I change data.data while the other thread is being executed? Changing

Re: shallow copy of const(Object)[]

2014-11-02 Thread anonymous via Digitalmars-d-learn
On Sunday, 2 November 2014 at 00:33:53 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: If you want to make sure that a dynamic array refers to new memory and is not a slice of another one, then you'd typically use dup or idup, and in almost all cases, that's exactly what you want. However,

Re: bug in assigning to dynamic array element

2014-11-01 Thread anonymous via Digitalmars-d
On Saturday, 1 November 2014 at 09:03:42 UTC, ketmar via Digitalmars-d wrote: as i can guess, the bug is in evaluating left part of '=' operation before the right part. I don't know how D defines this, and I couldn't find anything but a forum discussion [1] (which I didn't read all of). But

Re: bug in assigning to dynamic array element

2014-11-01 Thread anonymous via Digitalmars-d
On Saturday, 1 November 2014 at 11:50:34 UTC, ketmar via Digitalmars-d wrote: this *IS* a bug. either compiler should error on this, or it shouldn't modify random memory. imagine the situation when old array contents not only collected by GC, but that memory was allocated to something

Re: shallow copy of const(Object)[]

2014-11-01 Thread anonymous via Digitalmars-d-learn
On Saturday, 1 November 2014 at 00:08:23 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: So, by shallow copy, you mean that you want an array that contains the same elements but is a new array? yes If that's what you want, just slice the array. auto b = a[]; This is the same as

Re: pop popFront combined

2014-11-01 Thread anonymous via Digitalmars-d-learn
On Saturday, 1 November 2014 at 13:22:34 UTC, Nordlöw wrote: On Saturday, 1 November 2014 at 11:45:25 UTC, Nordlöw wrote: So why isn't something like x.stealFront already in Phobos? First try here: https://github.com/nordlow/justd/blob/master/range_ex.d#L14 Please comment! That is: auto

Re: pop popFront combined

2014-11-01 Thread anonymous via Digitalmars-d-learn
On Saturday, 1 November 2014 at 13:25:03 UTC, Nordlöw wrote: On Saturday, 1 November 2014 at 13:22:34 UTC, Nordlöw wrote: https://github.com/nordlow/justd/blob/master/range_ex.d#L14 Please comment! What's the recommended way of making stealFront and stealBack inout here? Can I somehow use

Re: pop popFront combined

2014-11-01 Thread anonymous via Digitalmars-d-learn
On Saturday, 1 November 2014 at 13:36:05 UTC, Marc Schütz wrote: On Saturday, 1 November 2014 at 13:30:16 UTC, anonymous wrote: [...] auto ref stealFront(R)(ref R r) { import std.range: moveFront, popFront; auto e = r.moveFront; r.popFront; return e; } [...] It's probably intended to mean

Re: pop popFront combined

2014-11-01 Thread anonymous via Digitalmars-d-learn
On Saturday, 1 November 2014 at 14:01:42 UTC, Nordlöw wrote: On Saturday, 1 November 2014 at 13:36:05 UTC, anonymous wrote: I don't see what you'd need inout for here. stealFront/stealBack are not methods. inout can be used on free functions aswell. See for example

shallow copy of const(Object)[]

2014-10-31 Thread anonymous via Digitalmars-d-learn
I have a const(Object)[] and I want a shallow copy of the array. .dup doesn't do it, which I thought a bug, but according to Martin Nowak it's by design [1]. std.array.array fails, too. Is there really nothing in phobos for this? static import std.array; void main() { const(Object)[] a;

Re: alias and extern(C)

2014-10-30 Thread anonymous via Digitalmars-d-learn
On Thursday, 30 October 2014 at 18:43:21 UTC, Laeeth Isharc wrote: The code below works fine if you remove the extern(C). But I get the error functionpointertest.d(6): Error: basic type expected, not extern with the code as it is. How do I use alias with extern ? [...] alias Callback=

Re: Equivalent in D for .p2align 4,,15 ?

2014-10-29 Thread anonymous via Digitalmars-d-learn
On Wednesday, 29 October 2014 at 17:16:23 UTC, Etienne wrote: I'm looking for the D inline assembler equivalent of the .p2align 4,,15 directive to optimize a loop. Here's more information: http://stackoverflow.com/questions/21546946/what-p2align-does-in-asm-code I tried searching through a

Re: Using imm8 through inline assembler

2014-10-28 Thread anonymous via Digitalmars-d-learn
On Tuesday, 28 October 2014 at 21:05:15 UTC, Etienne wrote: I'm trying to write (in DMD) the assembler that handles the function : __m256i _mm256_permute4x64_epi64(__m256i a, in int M); This translates to vpermq The closest thing I could find in DMD assembly is VPERMILPS, which is called

Re: Need assistance translating this C++ template

2014-10-27 Thread anonymous via Digitalmars-d-learn
On Monday, 27 October 2014 at 22:43:23 UTC, John wrote: The C++ code: // Bitfield utilities templateunsigned bitno, unsigned nbits=1, typename T=u8 struct RegBit { [...] templatetypename T2 RegBit operator=(T2 val) [...] }; My D implementation thus far: [...] template RegBit(uint

Re: Creation of 0MQ D project

2014-10-27 Thread anonymous via Digitalmars-d-learn
On Monday, 27 October 2014 at 23:56:11 UTC, Evan Lowry wrote: ../../.dub/packages/zeromq-master/deimos/zmq/zmq.d(96): Error: function deimos.zmq.zmq.zmq_strerror without 'this' cannot be const You found a bug in the binding. Line 96 of zmq.d [1]: const char* zmq_strerror(int errnum); Should

Re: forum.dlang.org open source?

2014-10-26 Thread anonymous via Digitalmars-d-learn
On Sunday, 26 October 2014 at 23:57:41 UTC, Mike wrote: Does forum.dlang.org have an open source repository somewhere that we can contribute pull requests to, or are bug reports to recommended procedure. http://forum.dlang.org/help#contributing

Re: passing non-dynamic arrays to variadic functions

2014-10-26 Thread anonymous via Digitalmars-d-learn
On Monday, 27 October 2014 at 00:26:00 UTC, ketmar via Digitalmars-d-learn wrote: Hello. let's assume we have this code: void doWrite(A...) (A args) { import std.stdio; import std.conv; writeln(to!string(args[0])); } void main () { char[3] a0 = abc; char[3] a1 =

Re: parser bug?

2014-10-23 Thread anonymous via Digitalmars-d-learn
On Thursday, 23 October 2014 at 18:15:26 UTC, Charles Hixson via Digitalmars-d-learn wrote: The code: voidgo(ulongrecNum) {assert (buf[0] == (fh.sizeof + recNo * buf.length) 0x7f); if(dirty) yields the error message: ells$ dmd test.d test.d(78): Error:

Re: std.stdio breaks casting operation

2014-10-23 Thread anonymous via Digitalmars-d-learn
On Thursday, 23 October 2014 at 18:43:54 UTC, tcak wrote: Then I change the Test.setIt method as follows: import std.stdio; s = cast( typeof( s ) )sock; Error on s = cast... line: cannot cast module socket of type void to shared(Socket) Apparently std.stdio

Re: Bug?

2014-10-23 Thread anonymous via Digitalmars-d-learn
On Thursday, 23 October 2014 at 21:17:25 UTC, deed wrote: Some testing can be found on http://dpaste.dzfl.pl/5f55f4152aa8 for both Windows and Linux. This just illustrates the sin function. I think the tests marked [1] are expected to fail. They involve converting one operand of the

Re: Bug?

2014-10-23 Thread anonymous via Digitalmars-d-learn
On Thursday, 23 October 2014 at 21:42:46 UTC, anonymous wrote: On Thursday, 23 October 2014 at 21:17:25 UTC, deed wrote: Some testing can be found on http://dpaste.dzfl.pl/5f55f4152aa8 for both Windows and Linux. This just illustrates the sin function. I think the tests marked [1] are

Re: Destructor order

2014-10-22 Thread anonymous via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 15:45:02 UTC, eles wrote: D version: { //displays ~A~B~C A foo = scoped!(A)(); B bar = scoped!(B)(); C caz = new C(); destroy(caz); } Why the objects are not destroyed in the inverse order of their

Re: debug = x overrides command line

2014-10-21 Thread anonymous via Digitalmars-d
On Tuesday, 21 October 2014 at 19:51:34 UTC, Gary Willoughby wrote: Ah, where's the documentation for this? http://dlang.org/function.html#pure-functions As a concession to practicality, a pure function can: [...] perform impure operations in statements that are in a ConditionalStatement

Re: Global const variables

2014-10-21 Thread anonymous via Digitalmars-d-learn
On Tuesday, 21 October 2014 at 12:08:35 UTC, Solomon E wrote: On Tuesday, 21 October 2014 at 08:48:09 UTC, safety0ff wrote: const int[] a; int[] b; static this() { b = [1]; a = b; } `a` isn't a reference to `b`. `a` is assigned by value and has its own storage. `a` is indeed a copy

Re: Really in need of help with std.container.array.d

2014-10-20 Thread anonymous via Digitalmars-d-learn
On Sunday, 19 October 2014 at 22:19:05 UTC, Nordlöw wrote: https://github.com/nordlow/phobos/commit/ce6b9e9ae600b7c28ecddd1e3af7b1516247fb33 now errors as array.d(927,15): Error: None of the overloads of 'opSlice' are callable using a const object, candidates are: array.d(472,25):

Re: Really in need of help with std.container.array.d

2014-10-20 Thread anonymous via Digitalmars-d-learn
On Monday, 20 October 2014 at 11:20:30 UTC, Nordlöw wrote: On Monday, 20 October 2014 at 10:56:43 UTC, anonymous wrote: On Sunday, 19 October 2014 at 22:19:05 UTC, Nordlöw wrote: By the way, since we're in D.learn, I'm assuming you want to do this yourself. But if you'd like, I could make a

cannot create account on issues.dlang.org

2014-10-19 Thread anonymous via Digitalmars-d
A confirmation email has been sent containing a link to continue creating an account. The link will expire if an account is not created within 3 days. Tried this a couple times. First time was yesterday. No email yet. Maybe some gears are stuck on the server?

Re: Really in need of help with std.container.array.d

2014-10-19 Thread anonymous via Digitalmars-d-learn
On Wednesday, 15 October 2014 at 21:15:14 UTC, Nordlöw wrote: https://github.com/nordlow/phobos/commit/9daf235d7091f76cd941e29e3c167d559bf56a94 but that triggers a new interesting suite of errors Error: mutable method std.container.array.Array!int.Array.__fieldPostBlit is not callable using

Re: Really in need of help with std.container.array.d

2014-10-19 Thread anonymous via Digitalmars-d-learn
On Sunday, 19 October 2014 at 18:58:50 UTC, Nordlöw wrote: On Sunday, 19 October 2014 at 15:21:02 UTC, anonymous wrote: version(none) _outer = data; /* Error: mutable method [...].Array.opAssign is not callable using a const object */ What do these comments

Re: Really in need of help with std.container.array.d

2014-10-19 Thread anonymous via Digitalmars-d-learn
On Sunday, 19 October 2014 at 19:30:40 UTC, Nordlöw wrote: On Sunday, 19 October 2014 at 19:13:33 UTC, anonymous wrote: Yes, they don't compile. It's three slightly different versions of initializing _outer. The first one, `_outer = data;`, is the original one. It's understandable that it

Re: Really in need of help with std.container.array.d

2014-10-19 Thread anonymous via Digitalmars-d-learn
On Sunday, 19 October 2014 at 20:10:33 UTC, Nordlöw wrote: Used your ideas here https://github.com/nordlow/phobos/commit/be6b5f8c4d428a9708a52757a3f31aab6878d379 but unittests now fails as array.d(234,13): Error: mutable method std.container.array.Array!int.Array.opAssign is not callable

Re: Really in need of help with std.container.array.d

2014-10-19 Thread anonymous via Digitalmars-d-learn
On Sunday, 19 October 2014 at 20:39:18 UTC, anonymous wrote: Spell the type out or use `typeof(result)`. Should be `typeof(return)`.

Re: Really in need of help with std.container.array.d

2014-10-19 Thread anonymous via Digitalmars-d-learn
On Sunday, 19 October 2014 at 15:21:02 UTC, anonymous wrote: struct RefCounted { this(this) /* const doesn't help */ {} ~this() /* const doesn't help */ {} } struct Array { RefCounted _data; } void main() {const Array a; const copy = a;} /* works */ struct RangeM {Array a;}

Re: Function parameters from TypeTuple

2014-10-17 Thread anonymous via Digitalmars-d-learn
On Friday, 17 October 2014 at 17:57:58 UTC, Tofu Ninja wrote: On Friday, 17 October 2014 at 17:44:48 UTC, Tofu Ninja wrote: Not sure if what I wrote made sense, instead I will just post the code that is vomiting on me... You forgot the imports. template arrayType(T) { alias

Re: Function parameters from TypeTuple

2014-10-17 Thread anonymous via Digitalmars-d-learn
On Friday, 17 October 2014 at 19:18:29 UTC, Tofu Ninja wrote: I had the imports, I just didn't post them. My problem is most likely that I used Tuple! instead of tuple... which is probably because the differences between the like 20(exaggeration) different types of tuples in D are confusing as

Re: Mixin template functions are ignored in struct

2014-10-14 Thread anonymous via Digitalmars-d-learn
On Tuesday, 14 October 2014 at 20:58:19 UTC, tcak wrote: I have written a struct and a mixin template, and that mixin template is mixed into that struct as follows. private mixin template TestCommonMethods(){ public bool apply( int d, int e ){ return false; } }

Re: how to call class' template constructor

2014-10-12 Thread anonymous via Digitalmars-d-learn
On Sunday, 12 October 2014 at 19:46:41 UTC, ketmar via Digitalmars-d-learn wrote: Hello. please, how to call template constructor of a class? it's completely escaped my mind. i.e. i have this class: class A { this(alias ent) (string name) { ... } } and i want to do:

Re: Using inline assembler

2014-10-09 Thread anonymous via Digitalmars-d-learn
On Thursday, 9 October 2014 at 12:37:20 UTC, Etienne wrote: I'm a bit new to the inline assembler, I'm trying to use the `movdqu` operation to move a 128 bit double quadword from a pointer location into another location like this: align(16) union __m128i { ubyte[16] data }; void

Re: Using inline assembler

2014-10-09 Thread anonymous via Digitalmars-d-learn
On Thursday, 9 October 2014 at 13:29:27 UTC, Etienne wrote: On 2014-10-09 8:54 AM, anonymous wrote: This compiles: align(16) union __m128i { ubyte[16] data; } /* note the position of the semicolon */ void store(__m128i* src, __m128i* dst) { asm { movdqu XMM0, [src]; /*

Re: (this MyType) and interface: Symbol undefined

2014-10-08 Thread anonymous via Digitalmars-d-learn
On Wednesday, 8 October 2014 at 13:00:56 UTC, andre wrote: Hi, please consider following example. I want to acces class B by interface I. Method work should print the actual class (B). The linker say: Error 42: Symbol Undefined _D3app1I17__T4workTC3app1IZ4workMFZv Is this is missing

Re: (this MyType) automatic deduction?

2014-10-08 Thread anonymous via Digitalmars-d-learn
On Wednesday, 8 October 2014 at 10:36:33 UTC, andre wrote: Hi, could you check whether it is correct, that second line in main failes with a compiler error? I think the compiler should be able to deduce the type without explicitly passing it to the method call. Kind regards André template

Re: Formatted output of range of tuples

2014-10-08 Thread anonymous via Digitalmars-d-learn
On Wednesday, 8 October 2014 at 21:21:47 UTC, antropod wrote: Hello! Consider this code: +++ import std.stdio; import std.range; import std.algorithm; void printIndexedArray1(T, Range)(T[] source, Range indexes) { foreach(row; zip(indexes, source)) {

Re: How to detect start of Unicode symbol and count amount of graphemes

2014-10-06 Thread anonymous via Digitalmars-d-learn
On Monday, 6 October 2014 at 17:28:45 UTC, Uranuz wrote: ( str[index] 0b1000 ) == 0 || ( str[index] 0b1110 ) == 0b1100 || ( str[index] 0b ) == 0b1110 || ( str[index] 0b1000 ) == 0b If it is true it means that first byte of sequence found and I can count

Re: How do I check if a function got CTFE?

2014-10-02 Thread anonymous via Digitalmars-d-learn
On Thursday, 2 October 2014 at 17:56:29 UTC, AsmMan wrote: I'd like to check if a function got CTFE, ie, the compiler was able to replace my foo(s); by the computed value at compile-time. I'm trying to convert the binary executable to assembly by using objconv tool but I'm finding it very

Re: How do I check if a function got CTFE?

2014-10-02 Thread anonymous via Digitalmars-d-learn
On Thursday, 2 October 2014 at 18:42:56 UTC, AsmMan wrote: I was thiking the dmd compiler did CTFE without someone ask for this, in the way as I've mentioned, checking for constant arguments + function's purity and if all this is true, it did the CTFE rather than generate code to compute it at

Re: find all public properties at compile time

2014-09-30 Thread anonymous via Digitalmars-d-learn
On Tuesday, 30 September 2014 at 20:04:29 UTC, gedaiu wrote: [sorry... this is the edit for the prev post] Thank you for your response! I don't think that it helps me... I wanted to get an array like this [ a, b, c ] for this class class test { int a; string b; double c; } import

Re: Recursive function call

2014-09-24 Thread anonymous via Digitalmars-d-learn
On Wednesday, 24 September 2014 at 10:57:27 UTC, Suliman wrote: string getFileName() { [...] getFilename(); //I need something similar, to call function again. You mistyped the function name, it's getFileName (capital N), and you forgot return. So: return getFileName();

Re: parallel foreach hangs

2014-09-22 Thread anonymous via Digitalmars-d-learn
On Monday, 22 September 2014 at 11:25:53 UTC, Daniel Kozak wrote: this code never end import std.stdio; import std.file; import std.parallelism : parallel; import std.algorithm : filter; void main(string[] args) { foreach(d; parallel(args[1 .. $], 1)) { auto phpFiles =

Re: Cannot deduce from type

2014-09-22 Thread anonymous via Digitalmars-d-learn
On Monday, 22 September 2014 at 14:45:31 UTC, Chris wrote: Why is that? import std.stdio, std.array void main() { auto output = appender!(string); output ~= world!; // output.data.insertInPlace(0, Hello, ); // Doesn't work auto asString = output.data; asString.insertInPlace(0, Hello,

Re: regex problems

2014-09-20 Thread anonymous via Digitalmars-d-learn
On Saturday, 20 September 2014 at 15:28:54 UTC, seany wrote: In haystack, there are two such ID : -s. once at the beginning, ID : generateWorld. and then the final, last ID However, this is returning all 5 ID-s as match what am I doing wrong? Prints ID : ID : for me. I'd advise against

Re: String[] pointer to void* and back

2014-09-19 Thread anonymous via Digitalmars-d-learn
On Friday, 19 September 2014 at 12:14:19 UTC, seany wrote: On Thursday, 18 September 2014 at 22:16:48 UTC, Ali Çehreli wrote: If you are holding an address in a void*, you must make sure that the original object is still at that location when you attempt to access the object. Does that

Re: Defaulting delegate member variables to do-nothing stubs

2014-09-18 Thread anonymous via Digitalmars-d
On Thursday, 18 September 2014 at 17:49:34 UTC, H. S. Teoh via Digitalmars-d wrote: I'm trying to write a struct with delegate member variables that I want to default to do-nothing stubs (rather than null function pointers that will crash when called), but it appears that such a thing is not

Re: String[] pointer to void* and back

2014-09-18 Thread anonymous via Digitalmars-d-learn
On Thursday, 18 September 2014 at 21:35:50 UTC, seany wrote: Yes, thank you, I corrected that. However, if this v is a member of a class, like import std.stdio; import std.conv; import core.vararg; struct S { void *v; } class C { S* sx = new S; void dothings() {

Re: Why does this not work?

2014-09-17 Thread anonymous via Digitalmars-d-learn
On Wednesday, 17 September 2014 at 13:20:15 UTC, Shachar wrote: On Wednesday, 17 September 2014 at 13:03:05 UTC, flamencofantasy wrote: the result of ubyte + ubyte is int I believe. Try; void func( int c ) { ubyte a; a = cast(ubyte)(cast(ubyte)c + cast(ubyte)c); } From

Re: Increasing D's visibility

2014-09-16 Thread anonymous via Digitalmars-d
On Monday, 15 September 2014 at 20:09:31 UTC, Martin Nowak wrote: http://learnxinyminutes.com/ On Monday, 18 November 2013 at 12:38:31 UTC, anonymous wrote: I had a go at it a while ago, but I lost interest. Here's what I came up with: https://gist.github.com/anonymous/7527033. If anyone

Re: Increasing D's visibility

2014-09-16 Thread Anonymous via Digitalmars-d
Dlang on 4chan http://boards.4chan.org/g/thread/44196390/dlang

Re: Extracting string parameter from template instance received via alias parameter

2014-09-12 Thread anonymous via Digitalmars-d
On Friday, 12 September 2014 at 19:44:28 UTC, MrSmith wrote: Given the following program: - import std.stdio; template first(string s) { string first(string par) { if (par == s) return true;

Re: How to cast to void*, while bypassing alias this or opCast

2014-08-28 Thread anonymous via Digitalmars-d-learn
On Thursday, 28 August 2014 at 10:45:52 UTC, monarch_dodra wrote: I'm investigating a phobos regression. From doesPointTo: // static if (isPointer!S || is(S == class) || is(S == interface)) { const m = cast(void*) source; // Basically, given a pointer like structure,

Re: Is this a bug when creating proxies in classes?

2014-08-28 Thread anonymous via Digitalmars-d-learn
On Tuesday, 26 August 2014 at 18:13:52 UTC, Gary Willoughby wrote: With that in mind what is strange is that if in my example you change the class for a struct everything works as expected. Why is that? That's because when not mixed into a class, Proxy did import std.traits: static if

Re: Building library

2014-08-28 Thread anonymous via Digitalmars-d-learn
On Thursday, 28 August 2014 at 19:29:40 UTC, papaboo wrote: My current file and module layout is test.d src/math/vector.d - module dragonfly.math.vector src/math/quaternion.d - module dragonfly.math.quaternion Compiling with $ dmd test.d src/math/vector.d src/math/quaternion.d ./test works

Re: How do I translate this bit of code from C(using pointers) to D?

2014-08-26 Thread anonymous via Digitalmars-d
On Tuesday, 26 August 2014 at 20:58:15 UTC, MacAsm wrote: string str = foobaa; string prev; [...] prev = str; // - I want to avoid this string duplication did in every move() call If you're worried that this copies the string data, it doesn't. A dynamic array (which string is) is a pair

Re: Error: template cannot deduce function from argument types.

2014-08-24 Thread anonymous via Digitalmars-d-learn
On Sunday, 24 August 2014 at 02:53:41 UTC, Damian Day wrote: Hi, I've been trying to reduce a bug in the containers (8824). From the example below it seems the dup method is passing the constructor an array of dchars and the template is failing. Is this a compiler bug, or ? import

Re: std.stdio.tmpfile() return shared(_IO_FILE)* and not File

2014-08-24 Thread anonymous via Digitalmars-d-learn
On Sunday, 24 August 2014 at 17:55:05 UTC, simendsjo wrote: Using DMD 2.066 on GNU/Linux x86_64. This is strange: import std.stdio; void main() { auto f = tmpfile(); pragma(msg, typeof(f)); // shared(_IO_FILE)* } But stdio.d looks like the following: static File tmpfile() @safe

Re: D for the Win

2014-08-21 Thread anonymous via Digitalmars-d-announce
On Thursday, 21 August 2014 at 01:51:11 UTC, ketmar via Digitalmars-d-announce wrote: i always wonder how good people at finding various offences I'm not offended. and fascims everywhere. It's pretty much the Nazi anthem. It doesn't get much more fascist than that. Of course, someone can

Re: D for the Win

2014-08-21 Thread anonymous via Digitalmars-d-announce
On Wednesday, 20 August 2014 at 22:57:21 UTC, Paulo Pinto wrote: As a Portuguese living in Germany, I would say not everyone knows that outside Germany. Certainly. As I said, from an Israeli it's probably benign. I guess if aynthing, it's meant to be jokingly provoking towards Germans. I don't

<    3   4   5   6   7   8   9   >