Re: How to check if aggregate member is static templated method?

2018-02-15 Thread drug via Digitalmars-d-learn
15.02.2018 18:49, RazvanN пишет: On Thursday, 15 February 2018 at 13:51:41 UTC, drug wrote: 15.02.2018 16:50, drug пишет: https://run.dlang.io/is/zHT2XZ I can check againts if member is either static function or template. But I failed to check if it both static and templated. The best I

Re: How to check if aggregate member is static templated method?

2018-02-15 Thread drug via Digitalmars-d-learn
15.02.2018 16:50, drug пишет: https://run.dlang.io/is/zHT2XZ I can check againts if member is either static function or template. But I failed to check if it both static and templated.

How to check if aggregate member is static templated method?

2018-02-15 Thread drug via Digitalmars-d-learn
https://run.dlang.io/is/zHT2XZ

Re: Vibe-d issue with timer in separate thread on debug builds

2018-01-18 Thread drug via Digitalmars-d-learn
18.01.2018 08:45, Andres Clari пишет: I see, then although it works (or it may work) on release shouldn't that assert happen for release builds by default too? Or is the thought that you got the error running the debug build you should do it a different way on your own and skip the check all

Re: What's equivalent to C#'s select?

2018-01-14 Thread drug via Digitalmars-d-learn
15.01.2018 00:21, Marc пишет: give a list, how can I select only the elements of a range according to a condition give by a lamba function? something like this: auto l = myList.select(e => e.id < 300); it would return a range. Similar to C#'s select:

Re: opCmp with double values

2017-12-24 Thread drug via Digitalmars-d-learn
25.12.2017 10:40, drug пишет: 25.12.2017 09:50, Ali Çehreli пишет: On 12/24/2017 02:10 AM, kerdemdemir wrote:  >  if (  fabs(diff) < 0.0001 ) I can't answer your question but I know that the comparison above is wrong because it can be meaningful only if the values are

Re: opCmp with double values

2017-12-24 Thread drug via Digitalmars-d-learn
25.12.2017 09:50, Ali Çehreli пишет: On 12/24/2017 02:10 AM, kerdemdemir wrote: >  if (  fabs(diff) < 0.0001 ) I can't answer your question but I know that the comparison above is wrong because it can be meaningful only if the values are sufficiently larger than that hard-coded

Re: Templates Instantiation error

2017-12-15 Thread drug via Digitalmars-d-learn
15.12.2017 11:49, yes9111 пишет: Hey Y'all, I'm trying to write a simple utility class to read rows from a SQLite3 database using compile time parameters, but I've run into a weird problem. https://pastebin.com/eTnbRjEd If I try to instantiate a Reader class I'm hitting a linker error

Re: Problem getting Cimgui to work

2017-12-06 Thread drug via Digitalmars-d-learn
I've check it before posting using old version dmd 2.073 and it works. What dmd version you compile with?

Re: Problem getting Cimgui to work

2017-12-06 Thread drug via Digitalmars-d-learn
probably this can help you https://github.com/drug007/timespatial this project uses cimgui by means of derelict-imgui

Re: Problem getting Cimgui to work

2017-12-06 Thread drug via Digitalmars-d-learn
06.12.2017 20:51, Thomas пишет: Hi guys! I need some help or advice about Cimgui (a C-API for Imgui) because I have no idea how to get it working. First, I'm new to D (only a few weeks) and still learning. I have a small C++/C# background, but wanted to try something new. So D got into my

Re: Concurrency send immutable

2017-11-24 Thread drug via Digitalmars-d-learn
24.11.2017 15:53, SrMordred пишет: On Friday, 24 November 2017 at 12:36:42 UTC, Daniel Kozak wrote: Should print something like this: std.concurrency.OwnerTerminated@std/concurrency.d(223): Owner terminated Yes, it was, I was aware of this and put some sleep after that too. (immutable

Re: reduce condition nesting

2017-11-23 Thread drug via Digitalmars-d-learn
23.11.2017 17:16, Andrea Fontana пишет: On Thursday, 23 November 2017 at 13:47:37 UTC, Adam D. Ruppe wrote: On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote: for instance in kotlin it can be replace with this: when {     c1 -> foo(),     c2 -> bar(),     c3 -> ...     else ->

Re: glfwSetDropCallback undefined symbol

2017-11-23 Thread drug via Digitalmars-d-learn
23.11.2017 09:33, Tim Hsu пишет: DCD and DMD says that the symbol is undefined! However, I look into derelichtGLFW3. It has this symbol defined! It looks like a bug for me! DerelictGLFW3 has this symbol, but it does not define it, it should be defined in shared/dynamic library you use. I

Re: interfacing c++

2017-11-22 Thread drug via Digitalmars-d-learn
22.11.2017 19:06, Markus пишет: another indicator (as documented) that GC destructor won't work // extern(C++) classes don't have a classinfo pointer in their vtable so the GC can't finalize them

Re: interfacing c++

2017-11-22 Thread drug via Digitalmars-d-learn
22.11.2017 02:12, Markus пишет: snip I could do the instancing/destruction by functions and write a custom d class that calls these methods in this()/~this(). This is what I used to do as special members like ctor/dtor did not supported in D before, but your example of using ctor is

Re: dub: Use Alternate Dependency

2017-11-20 Thread drug via Digitalmars-d-learn
21.11.2017 07:42, bauss пишет: On Tuesday, 21 November 2017 at 02:51:13 UTC, jmh530 wrote: I'm working on two related dub projects on code.dlang.org. One has a dependency on the other. However, I've made changes to both and to run the tests properly requires me to use both versions in my

Re: Trait to identify if a type is a struct one

2017-10-18 Thread drug via Digitalmars-d-learn
18.10.2017 18:11, pham пишет: Is there a way to identify if a type is a struct, something like isStruct similar to isArray. struct X { } isStruct!X == true? Also, there are isAbstractClass & isFinalClass but want to check if type is a class regardless? something like isClass? Thanks Pham

Re: Skynet 1M Fiber microbenchmark in D

2017-10-18 Thread drug via Digitalmars-d-learn
18.10.2017 16:37, ikod пишет: I ran this under linux perf, and here is top from 'perf report' # Overhead  Command  Shared Object   Symbol #   ...  .. ... # 7.34%  t 

Re: Skynet 1M Fiber microbenchmark in D

2017-10-18 Thread drug via Digitalmars-d-learn
18.10.2017 14:34, Nordlöw пишет: And how do I parallelize this over multiple worker threads? AFAICT fibers are by default all spawned in the same main thread, right? Probably it will works - every fiber substract 1 from its argument, then divides remainder by count of child fibers and spawns

dtor of std.container.array.Array

2017-10-18 Thread drug via Digitalmars-d-learn
Is there any reason `std.container.array.Array.__dtor` isn't @safe, @pure etc?

Re: testing if data is allocated on the stack or heap

2017-10-17 Thread drug via Digitalmars-d-learn
17.10.2017 20:27, Biotronic пишет: module stackCheck; private size_t stackStart; enum size_t pageSize = 0x1000; static this() {     import core.stdc.stdlib : alloca;     stackStart = cast(size_t)alloca(size_t.sizeof) & ~(pageSize-1); } bool onStack(void* p) {     size_t end = (cast(size_t)

testing if data is allocated on the stack or heap

2017-10-17 Thread drug via Digitalmars-d-learn
My code fails and I guess the reason is I have a slice to data in the stack and it becomes garbage in some moment. So I need a way to check where data is placed. Is it right that it can be done in linux using `sbrk` so that if the addr of data is less than `sbrk(0)` returning then data is on

Re: testing if data is allocated on the stack or heap

2017-10-17 Thread drug via Digitalmars-d-learn
https://run.dlang.io/is/vOh6YY

Re: what operator(s) should I overload to prevent this?

2017-10-16 Thread drug via Digitalmars-d-learn
16.10.2017 15:18, Biotronic пишет: On Monday, 16 October 2017 at 12:00:13 UTC, drug wrote: I refactored `MyStructure` added own implementation of malloced array based on pureRealloc/pureFree instead of dynamic array I used before and now I have error: Error: cannot implicitly convert

what operator(s) should I overload to prevent this?

2017-10-16 Thread drug via Digitalmars-d-learn
I refactored `MyStructure` added own implementation of malloced array based on pureRealloc/pureFree instead of dynamic array I used before and now I have error: Error: cannot implicitly convert expression get(msg.getData()) of type const(MyStructure) to MyStructure. What operators should I

Re: Two way struct wrapper

2017-10-14 Thread drug via Digitalmars-d-learn
14.10.2017 16:23, Alex пишет: On Saturday, 14 October 2017 at 12:39:17 UTC, Alex wrote: ok, the last version for now. Without assumptions on alias number. Sorry for noise. https://run.dlang.io/is/OSJYtY That's cool, but unfortunately demands access to source code of Foo, it's not my case( I

Two way struct wrapper

2017-10-11 Thread drug via Digitalmars-d-learn
Using `alias this` it's easy to make wrapper for structure that calls wrapped structure methods like its own. This is one way - from wrapper to wrapped transformation. Is it possible to create the opposite way from wrapped to wrapper? https://run.dlang.io/is/Avyu3I All calls to Bar is

Re: struct/class generation

2017-10-11 Thread drug via Digitalmars-d-learn
11.10.2017 14:37, ANtlord пишет: Hello dear community! I've met a little issue. How can I generate struct or class copying some fields and methods from another struct or class? I've found methods to get fields. They are std.traits.FieldNameTuple and std.traits.FieldTypeTuple but I can't find

how to shorten templates structs name?

2017-10-10 Thread drug via Digitalmars-d-learn
using classes I can make an inherited class of templated class and avoid too long mangled name: ``` class TemplatedClass(A, Very, Much, Args, Here) { ... } class ShortenClass : TemplatedClass!(A,Very, Much, Args, Here) { ... }; ``` Now ShortenClass has a nice mangling. What can be done in case

Re: Bug? ElementType fails if element type is const

2017-10-09 Thread drug via Digitalmars-d-learn
oops, it was my fault. sorry for noise. my apologies to ElementType ))

Bug? ElementType fails if element type is const

2017-10-09 Thread drug via Digitalmars-d-learn
https://run.dlang.io/is/duecIS

Re: learning reflection in D

2017-10-05 Thread drug via Digitalmars-d-learn
05.10.2017 18:04, Adam D. Ruppe пишет: On Thursday, 5 October 2017 at 14:59:10 UTC, drug wrote: 1) why .stringof and typeid() is equal logically and different in fact? What is difference between them? Is it that stringof compile time and typeid runtime things? Anyway wouldn't it be better they

learning reflection in D

2017-10-05 Thread drug via Digitalmars-d-learn
https://run.dlang.io/is/8LbmzG 1) why .stringof and typeid() is equal logically and different in fact? What is difference between them? Is it that stringof compile time and typeid runtime things? Anyway wouldn't it be better they will equal both logically and literally? 2) Where do these

Re: How to implement `isTemplate` traits?

2017-10-04 Thread drug via Digitalmars-d-learn
04.10.2017 12:54, Biotronic пишет: template isTemplate(T...) if (T.length == 1) {     enum isTemplate = __traits(isTemplate, T[0]); } --   Biotronic Thank you!

How to implement `isTemplate` traits?

2017-10-04 Thread drug via Digitalmars-d-learn
I need to separate templates: ``` foreach(member; __traits(allMembers, V)) { static if (__traits(compiles, { auto _val = &__traits(getMember, value, member); }) { // a template needs to be instantiated to be addressable, so it works, but I think it's dirty hack instead of dry and

Re: segfault on gc.impl.conservative.gc.Gcx.smallAlloc

2017-09-26 Thread drug via Digitalmars-d-learn
26.09.2017 00:34, Mengu пишет: hi all this following code block [0] is exiting with "terminated by signal SIGBUS (Misaligned address error)" error. it processes like 200K rows and then fails. any ideas? void getHotels() {   import std.parallelism : taskPool;   import std.functional  :

Re: is it bug?

2017-09-26 Thread drug via Digitalmars-d-learn
26.09.2017 15:16, Steven Schveighoffer пишет: Yes, that is the bug, as I said at the end of my message. But you had confused the issue by showing that "hey bar.foo isn't null!" which had nothing to do with the bug. It wasn't null, and wasn't improperly being treated as null. You don't need

Re: is it bug?

2017-09-26 Thread drug via Digitalmars-d-learn
25.09.2017 22:58, Steven Schveighoffer пишет: First up, the non-bug: You wrote: writeln(bar.foo.isNull); // false writeln(bar.foo); // error But bar.foo is this: struct Foo {    Nullable!(char[2]) value; } And bar.foo is nullable itself. It's a nullable!Foo. It's a Nullable!Foo, that is

Re: is it bug?

2017-09-25 Thread drug via Digitalmars-d-learn
https://run.dlang.io/is/pZwsoX As I can see std.format.formatElement thinks Nullable!Foo is not null, try to get its value but it is null so fail?

Re: is it bug?

2017-09-25 Thread drug via Digitalmars-d-learn
25.09.2017 20:47, Adam D. Ruppe пишет: On Monday, 25 September 2017 at 17:44:54 UTC, drug wrote: https://run.dlang.io/is/uk0CMC You didn't initialize it. It's not null, but it also isn't a valid character. but exception is caused by using `get` on null Foo instance, not by invalid character

is it bug?

2017-09-25 Thread drug via Digitalmars-d-learn
https://run.dlang.io/is/uk0CMC

Re: opEquals code generation

2017-09-19 Thread drug via Digitalmars-d-learn
19.09.2017 15:38, Steven Schveighoffer пишет: On 9/19/17 8:01 AM, drug wrote: I iterate over struct members and check against equality depending on member type. is there more simple/cleaner/better way to achieve this functionality? Especially without string mixins? Why not just use tupleof

Re: opEquals code generation

2017-09-19 Thread drug via Digitalmars-d-learn
19.09.2017 15:01, drug пишет: I iterate over struct members and check against equality depending on member type. is there more simple/cleaner/better way to achieve this functionality? Especially without string mixins? oops, https://run.dlang.io/is/PbZE5i

opEquals code generation

2017-09-19 Thread drug via Digitalmars-d-learn
I iterate over struct members and check against equality depending on member type. is there more simple/cleaner/better way to achieve this functionality? Especially without string mixins?

Re: How do I send a message to a struct member function?

2017-08-26 Thread drug via Digitalmars-d-learn
26.08.2017 09:49, Enjoys Math пишет: I have a series of structs each of which needs to spawn a worker thread on initialization. There seems to be no way to send a message back to the struct for instance to cause a member function call on /that/ structs data. Please advise me. If it is

Re: Building (and including libraries) without dub

2017-08-26 Thread drug via Digitalmars-d-learn
26.08.2017 12:03, Hasen Judy пишет: Building simple programs without dub is easy, just pass a list of .d source files to `dmd` or `ldc2`. What if I want to include a 3rd party library? Surely before dub existed, people were incorporating other libraries in their projects. I want to learn

Re: std.container.array of struct inside a struct fails

2017-07-14 Thread drug via Digitalmars-d-learn
14.07.2017 19:53, Anton Fediushin пишет: On Friday, 14 July 2017 at 16:42:59 UTC, drug wrote: It's because Array(T) is a value type and needs type size to define itself, so you have expected forward reference. But T[] is reference type and its size is known in advance - it doesn't depend on

Re: std.container.array of struct inside a struct fails

2017-07-14 Thread drug via Digitalmars-d-learn
14.07.2017 19:12, Anton Fediushin пишет: This code: - import std.container.array; struct Test { Array!Test t; } - Fails with an error: - /usr/include/dlang/dmd/std/traits.d(2404): Error: struct arrayissue.Test no size because of forward reference It's because Array(T) is a

Re: pure factory function vs immutable(Foo)**

2017-07-10 Thread drug via Digitalmars-d-learn
10.07.2017 17:57, ag0aep6g пишет: I feel like I must be missing something here. This works: alias T = int; T** f(const T** input) pure { T** output; return output; } void main() { T i; T* p = immutable T** r = f(); } `f` is `pure`, its parameter is const, and

Re: iterate over variadic

2017-07-09 Thread drug via Digitalmars-d-learn
10.07.2017 01:21, FoxyBrown пишет: How can we iterate over a variadic and have it's index. I'll do different things depend on if it's an even or odd index, but seems to be no way to get it. auto foo(Types...)() { foreach(T; Types) { // do what you need

Re: safe method overloading with different refness of its arguments

2017-07-04 Thread drug via Digitalmars-d-learn
04.07.2017 15:06, Basile B. пишет: On Tuesday, 4 July 2017 at 10:40:42 UTC, drug wrote: ``` struct Foo { ubyte width, length; // by reference bool opEquals(ref const(Foo) other) const pure @safe { if (width != other.width) return false; if (length !=

safe method overloading with different refness of its arguments

2017-07-04 Thread drug via Digitalmars-d-learn
``` struct Foo { ubyte width, length; // by reference bool opEquals(ref const(Foo) other) const pure @safe { if (width != other.width) return false; if (length != other.length) return false; return true; } // by value

Re: std.string.format call from varyargs

2017-07-02 Thread drug via Digitalmars-d-learn
02.07.2017 09:52, H. S. Teoh via Digitalmars-d-learn пишет: On Sun, Jul 02, 2017 at 12:49:30AM +, LeqxLeqx via Digitalmars-d-learn wrote: Hello! How does one go about invoking a templated-variatic function such as std.string.format with an array of objects? For example: string

Re: weird error message

2017-07-02 Thread drug via Digitalmars-d-learn
02.07.2017 04:06, Ali Çehreli пишет: On 07/01/2017 04:56 PM, crimaniak wrote: > about very long error messages generated in some > cases. Please submit a bug report. The compiler may be able to abbreviate certain types. For example, in this case most of the error message text is values of

Re: D, Game Development, GLSL, Math

2017-07-01 Thread drug via Digitalmars-d-learn
01.07.2017 22:07, Void-995 пишет: (Void-995) Hi, everyone. I'm pretty excited with what have D to offer for game development, especially meta programming, traits, object.factory, signals and bunch of other neat things that may save a lot of time. Also, i saw support for vector data types and

Re: rank of range

2017-07-01 Thread drug via Digitalmars-d-learn
01.07.2017 20:33, Ali Çehreli пишет: On 07/01/2017 10:05 AM, drug wrote: Hello! Is there a convenient way to get rank of range a.k.a. count of dimensions in compile time? Like: static assert( rankOf!(uint[]) == 1); static assert( rankOf!(uint[][][]) == 3); I'm not aware of one but this seems

rank of range

2017-07-01 Thread drug via Digitalmars-d-learn
Hello! Is there a convenient way to get rank of range a.k.a. count of dimensions in compile time? Like: static assert( rankOf!(uint[]) == 1); static assert( rankOf!(uint[][][]) == 3);

Re: is it bug? (out contract in method causes dmd (2.072.2, 2.74.1) segfaults)

2017-06-14 Thread drug via Digitalmars-d-learn
14.06.2017 14:25, ag0aep6g пишет: It's always a bug when dmd segfaults. filed https://issues.dlang.org/show_bug.cgi?id=17502

is it bug? (out contract in method causes dmd (2.072.2, 2.74.1) segfaults)

2017-06-14 Thread drug via Digitalmars-d-learn
https://dpaste.dzfl.pl/b66fffa3bc8d

Re: How to implement opCmp?

2017-06-09 Thread drug via Digitalmars-d-learn
I re-read thoroughly and got it)

Re: How to implement opCmp?

2017-06-09 Thread drug via Digitalmars-d-learn
09.06.2017 18:12, Steven Schveighoffer пишет: int doCmp(T)(auto ref T t1, auto ref T t2) { static if(is(typeof(t1.opCmp(t2 return t1.opCmp(t2); else { if(t1 < t2) return -1; else if(t1 > t2) return 1; return 0; } } Isn't it enough to use just '<' et

Re: [Solved] Confusing error message

2017-06-07 Thread drug via Digitalmars-d-learn
07.06.2017 22:40, bachmeier пишет: On Wednesday, 7 June 2017 at 19:02:59 UTC, drug wrote: How do compiler know that you want use `std.conv.to` instead of _already imported_ `core.time.to`? In general it's impossible. There is no way for compiler to guess that you want some other symbol from

Re: [Solved] Confusing error message

2017-06-07 Thread drug via Digitalmars-d-learn
07.06.2017 21:07, bachmeier пишет: On Wednesday, 7 June 2017 at 14:58:26 UTC, drug wrote: For me it's a good message. Messages like this were an annoyance when I started out. If you don't import std.stdio, you get the error message Error: 'writeln' is not defined, perhaps you need to

Re: [Solved] Confusing error message

2017-06-07 Thread drug via Digitalmars-d-learn
07.06.2017 16:27, Wulfklaue пишет: Some of the dmd error messages need some tweaking. import std.datetime; auto t = Clock.currStdTime; writeln(to!string(t)); Result in: Error: template core.time.to cannot deduce function from argument types !(string)(long), candidates are:

Re: binding to C++

2017-05-29 Thread drug via Digitalmars-d-learn
27.05.2017 02:44, Nicholas Wilson пишет: Thats weird. DMD may have got the mangling wrong. Could you post the exact mangling (i.e. non-demangled)? And if DMD has got it wrong and its just the one function you could just `pragma(mangle, ...);` it. I use pragma(mangle, "...") (how I forget about

binding to C++

2017-05-26 Thread drug via Digitalmars-d-learn
Trying to bind to cpp code I stop at some moment having undefined reference to some cpp function. But objdump -Ct cpplibrary.so shows me that this cpp function exists in the library. linker message about cpp function is _identical_ to objdump message so I don't know where is the difference.

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-12 Thread drug via Digitalmars-d-learn
12.05.2017 14:58, k-five пишет: On Friday, 12 May 2017 at 11:41:57 UTC, cym13 wrote: On Friday, 12 May 2017 at 11:10:01 UTC, k-five wrote: --- Shorter: void main( string[] args ){ dirEntries( ".", SpanMode.depth, false )

Re: Stuck with DMD, and Unit-Threaded

2017-04-16 Thread drug via Digitalmars-d-learn
16.04.2017 11:20, Russel Winder via Digitalmars-d-learn пишет: There are points when you need to ask someone for help… I am trying to get Dub to build integration tests from test-source as a separate thing from building unit tests from source. The latter is easy and works, as does building the

Re: Dub, Git, Mercurial, Bazaar

2017-04-11 Thread drug via Digitalmars-d-learn
11.04.2017 15:12, Russel Winder via Digitalmars-d-learn пишет: On Tue, 2017-04-11 at 14:21 +0300, drug via Digitalmars-d-learn wrote: 11.04.2017 14:15, Russel Winder via Digitalmars-d-learn пишет: On Tue, 2017-04-11 at 09:55 +0300, drug via Digitalmars-d-learn wrote: […] You can use local

Re: Dub, Git, Mercurial, Bazaar

2017-04-11 Thread drug via Digitalmars-d-learn
11.04.2017 14:15, Russel Winder via Digitalmars-d-learn пишет: On Tue, 2017-04-11 at 09:55 +0300, drug via Digitalmars-d-learn wrote: […] You can use local repository if you want But that implies something very manual, go and cargo handle all that. How go and cargo know where the local

Re: Dub and compilation

2017-04-11 Thread drug via Digitalmars-d-learn
11.04.2017 08:15, Russel Winder via Digitalmars-d-learn пишет: As I understand it, Dub compiles a downloaded dependency into the local Dub cache. This means you cannot store a debug build and a release build for multiple architectures and different compilers, at the same time, and you only get a

Re: Dub, Git, Mercurial, Bazaar

2017-04-11 Thread drug via Digitalmars-d-learn
11.04.2017 07:59, Russel Winder via Digitalmars-d-learn пишет: Go only uses Git, Mercurial, or Bazaar for dependency handling. Rust (via Cargo) allows for a central repository, and Git (, and Mercurial ?) repositories. Dub appears only to allow for central repository, or have I missed it's

Re: Testing D codes

2017-04-11 Thread drug via Digitalmars-d-learn
10.04.2017 19:20, Russel Winder via Digitalmars-d-learn пишет: On Fri, 2017-04-07 at 11:40 +0300, drug via Digitalmars-d-learn wrote: […] I do this. I have unittests in the module sources and have a separate subpackage intended for more advanced testing only. Do you have an example project

Re: Testing D codes

2017-04-07 Thread drug via Digitalmars-d-learn
06.04.2017 19:34, Russel Winder via Digitalmars-d-learn пишет: I am still wondering about separating integration and system tests out of the module source leaving the unit tests in the module source. I do this. I have unittests in the module sources and have a separate subpackage intended

Re: Testing D codes

2017-04-06 Thread drug via Digitalmars-d-learn
06.04.2017 16:49, Russel Winder via Digitalmars-d-learn пишет: On Thu, 2017-04-06 at 13:08 +, Kagamin via Digitalmars-d-learn wrote: https://github.com/ikod/dlang-requests/blob/master/tests/app.d Which implies that in the D milieu all tests are unittests even if they are not unittests.

Re: Need advice on using DUB registry

2017-04-02 Thread drug via Digitalmars-d-learn
02.04.2017 17:43, Eric пишет: On Sunday, 2 April 2017 at 04:14:56 UTC, rikki cattermole wrote: On 02/04/2017 2:37 AM, Eric wrote: I'm planning on some day putting a package in the DUB registry. My package is dependent on my "util" package which is a collection of stuff I use across all my

Re: CT aggregate computations

2017-03-30 Thread drug via Digitalmars-d-learn
30.03.2017 21:59, H. S. Teoh via Digitalmars-d-learn пишет: http://wiki.dlang.org/User:Quickfur/Compile-time_vs._compile-time Really useful link, thank you very much!

Re: Derelict SDL segfaulting on ubuntu?

2017-03-21 Thread drug via Digitalmars-d-learn
21.03.2017 16:04, Robly18 пишет: On Tuesday, 21 March 2017 at 12:39:26 UTC, WebFreak001 wrote: On Tuesday, 21 March 2017 at 12:31:41 UTC, Robly18 wrote: I've been working on a small game of tic tac toe using Derelict SDL, and development has been going along great... Until I tried to develop

Re: A bug?

2017-02-15 Thread drug via Digitalmars-d-learn
15.02.2017 19:00, berni пишет: I'm not sure if this is considered a bug: import std.stdio; import std.string; int c = 0; void main() { try { write(++c," "); stdout.flush(); int[10] tmp; throw new Exception(format("%s",tmp)); } finally {

Re: Better than "Clock.currStdTime()/10000000"

2017-02-15 Thread drug via Digitalmars-d-learn
15.02.2017 16:19, berni пишет: I need to measure time elapsed in seconds, like this: auto start = Clock.currStdTime(); // some stuff auto stop = Clock.currStdTime(); auto duration = (stop-start)/1000; This works, but I wonder if there is something better that using the magic constant

Re: std.datetime

2017-02-10 Thread drug via Digitalmars-d-learn
10.02.2017 19:31, Jonathan M Davis via Digitalmars-d-learn пишет: On Friday, February 10, 2017 19:06:53 drug via Digitalmars-d-learn wrote: 10.02.2017 18:02, Jonathan M Davis via Digitalmars-d-learn пишет: On Friday, February 10, 2017 14:35:28 drug via Digitalmars-d-learn wrote: I found

Re: std.datetime

2017-02-10 Thread drug via Digitalmars-d-learn
10.02.2017 18:02, Jonathan M Davis via Digitalmars-d-learn пишет: On Friday, February 10, 2017 14:35:28 drug via Digitalmars-d-learn wrote: I found error - years should start from 1, not 0. But if months or days start from 0 std.datetime throws exception and don't for years - it isn't clear

Re: std.datetime

2017-02-10 Thread drug via Digitalmars-d-learn
10.02.2017 14:15, drug пишет: unittest { import std.datetime : SysTime, UTC; { auto st = SysTime(); st.timezone(UTC()); long date = st.fromISOExtString("2017-02-10T00:00:00Z").stdTime, time_of_day =

std.datetime

2017-02-10 Thread drug via Digitalmars-d-learn
unittest { import std.datetime : SysTime, UTC; { auto st = SysTime(); st.timezone(UTC()); long date = st.fromISOExtString("2017-02-10T00:00:00Z").stdTime, time_of_day =

Re: iterating through members of bitfields

2017-01-20 Thread drug via Digitalmars-d-learn
20.01.2017 15:04, Nestor пишет: Where does one define the size for a field using AliasSeq, and in this example, why does it take 1 bit if the size is not declared anywhere? Something like that https://goo.gl/zV8T23

Re: iterating through members of bitfields

2017-01-20 Thread drug via Digitalmars-d-learn
20.01.2017 15:04, Nestor пишет: On Friday, 20 January 2017 at 08:13:08 UTC, drug wrote: Something like that https://goo.gl/C4nOqw Because you generate code iterating over AliasSeq you can do almost everything you need - for example generate setters/getters. Interesting site, I wouldn't

Re: iterating through members of bitfields

2017-01-20 Thread drug via Digitalmars-d-learn
20.01.2017 04:21, Nestor пишет: On Wednesday, 18 January 2017 at 12:52:56 UTC, drug wrote: I've "solved" the same problem by using AliasSeq to generate bitfields so that for iterating over bitfields I can iterate over alias sequence and mixin code. Not very good but it works. Interesting,

Re: iterating through members of bitfields

2017-01-18 Thread drug via Digitalmars-d-learn
I've "solved" the same problem by using AliasSeq to generate bitfields so that for iterating over bitfields I can iterate over alias sequence and mixin code. Not very good but it works.

emplacing extern(C++) class

2017-01-16 Thread drug via Digitalmars-d-learn
I'm interfacing to C++ I using emplacing extern(C++) to malloc'ed memory like http://wiki.dlang.org/Memory_Management (see Explicit Class Instance Allocation) This code segfaulted with extern(C++) TestClass. I guess it's because extern(C++) class aren't rooted from Object so instead of

Re: how to copy const struct with indirections to mutable one (of the same type)

2016-11-29 Thread drug via Digitalmars-d-learn
29.11.2016 13:49, Mathias Lang пишет: On Tuesday, 29 November 2016 at 10:46:04 UTC, drug wrote: I had the following code: ``` import std.algorithm: equal; [...] You are not calling the (identity) opAssign here, but postblit. To call identity opAssign, you need an already constructed

how to copy const struct with indirections to mutable one (of the same type)

2016-11-29 Thread drug via Digitalmars-d-learn
I had the following code: ``` import std.algorithm: equal; struct Data { int[3] arr; } int main() { auto const_data = const(Data)([1, 2, 3]); assert(const_data.arr[].equal([1, 2, 3])); Data mutable_data = const_data;

Re: The return of std.algorithm.find

2016-11-15 Thread drug via Digitalmars-d-learn
15.11.2016 12:50, RazvanN пишет: On Tuesday, 15 November 2016 at 09:43:27 UTC, RazvanN wrote: The find function which receives an input haystack and a needle returns the haystack advanced to the first occurrence of the needle. For normal ranges this is fine, but for sorted ranges (aka

Re: The return of std.algorithm.find

2016-11-15 Thread drug via Digitalmars-d-learn
15.11.2016 12:48, drug пишет: 15.11.2016 12:43, RazvanN пишет: The find function which receives an input haystack and a needle returns the haystack advanced to the first occurrence of the needle. For normal ranges this is fine, but for sorted ranges (aka SortedRange) it is a bit odd. For

Re: The return of std.algorithm.find

2016-11-15 Thread drug via Digitalmars-d-learn
15.11.2016 12:43, RazvanN пишет: The find function which receives an input haystack and a needle returns the haystack advanced to the first occurrence of the needle. For normal ranges this is fine, but for sorted ranges (aka SortedRange) it is a bit odd. For example: find(assumeSorted[1, 2, 4,

Re: Working with ranges: mismatched function return type inference

2016-10-11 Thread drug via Digitalmars-d-learn
11.10.2016 18:46, orip пишет: On Tuesday, 11 October 2016 at 13:06:37 UTC, pineapple wrote: Rewrite `return chain(ints[0..5], ints[8..$]);` as `return ints[0..5] ~ ints[8..$];` The `chain` function doesn't return an array, it returns a lazily-evaluated sequence of an entirely different type

artistic and boost licenses compatibility

2016-10-04 Thread drug via Digitalmars-d-learn
Could somebody answer the following question: may I port a project that has artistic license to D and relicense it under boost one? Artistic license allows relicensing in total but I'm not sure it's possible in case of Boost license. Thanks

Re: [UDA] Error: first argument is not a symbol

2016-09-15 Thread drug via Digitalmars-d-learn
15.09.2016 15:56, Steven Schveighoffer пишет: This is due to int not being a symbol, which apparently __traits(getAttributes, ...) requires. int is a keyword and not considered a symbol. An annoying distinction without a difference in this case. I'd say it's something we should fix, but this

[UDA] Error: first argument is not a symbol

2016-09-15 Thread drug via Digitalmars-d-learn
https://dpaste.dzfl.pl/9548c481ce46 shouldn't commented line return 'false' as built-in type 'int' has no any UDAs instead of cryptic (for me) message about wrong first argument?

Re: Classes new'd inside for loop are all the same instance?

2016-09-08 Thread drug via Digitalmars-d-learn
08.09.2016 15:24, lobo пишет: I am confused, which is normal, but I'd appreciate some help :-) If I create N classes in a for loop they are all the same instance. I would expect each to be a unique instance of the class. See the code below --- class C {} void main() { import std.stdio;

<    1   2   3   4   >