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 bo

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

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: 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 = &i; immutable T** r = f(&p); } `f` is `pure`, its parameter is const,

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 valu

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 type

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 how

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 appr

Re: Building (and including libraries) without dub

2017-08-26 Thread drug via Digitalmars-d-learn
26.08.2017 13:05, Hasen Judy пишет: On Saturday, 26 August 2017 at 10:02:03 UTC, drug wrote: It's like C++. If you use Linux then: ``` dmd -L/path/to/lib -llibrarynamewithoutlibprefix ``` or example ``` dmd myapp.d -L../otherproject/lib -lcool ``` line above compiles `myapp.d` file and links

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

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 di

is it bug?

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

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

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

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 Ba

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

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 cle

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!

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 attri

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

Bug? ElementType fails if element type is const

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

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

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

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 redirec

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

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 ove

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 expression

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

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 th

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

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

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

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 interesti

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 https://github.com/dlang/druntime/blob/3d8d4a45c01832fb657c16a656b6e1566d77fb21/src/rt/lifetime.d#L9

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 guess

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

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 (int)[

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 f

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
I've check it before posting using old version dmd 2.073 and it works. What dmd version you compile with?

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 saying

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 v

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 sufficiently

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: https://msdn.microsoft.com/en-us/librar

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

is it regression?

2018-02-28 Thread drug via Digitalmars-d-learn
https://run.dlang.io/is/HJxtvw ``` import std.stdio, std.typecons, std.math; void main() { auto foo = nullable(2.0); auto bar = nullable(2.0); assert (foo.approxEqual(bar)); } ``` Comiling gives the following: Up to 2.067.1: Failure with output: - onlineapp.d(4): Error: unde

Re: is it regression?

2018-02-28 Thread drug via Digitalmars-d-learn
done https://issues.dlang.org/show_bug.cgi?id=18539

Re: How to simplify nested ifs

2018-03-16 Thread drug via Digitalmars-d-learn
On 16.03.2018 09:51, drug wrote: I think that null conditional operator is intended for OOP only. It's really useful if your data field may be nullable. May be start review about this? Oops. I mean *isn't intended for OOP only*

Re: How to simplify nested ifs

2018-03-16 Thread drug via Digitalmars-d-learn
On 16.03.2018 09:34, Satoshi wrote: On Tuesday, 13 March 2018 at 12:23:06 UTC, Ozan Süel wrote: Hi I have a construction like the following if (source) { if (source.pool) { if (source.pool.repository) { if (source.pool.repository.directory) { if (source.pool.repository.director

Re: merkle reverse

2018-04-05 Thread drug via Digitalmars-d-learn
05.04.2018 11:57, SimonN пишет: Here's one solution with std.range.chunks. A small downside is that it needs the array allocation in the middle because chunks cannot offer the bi-directional range necessary for retro.     import std.range;     import std.algorithm;     void main()     {

Re: kxml and dub package manager.

2015-10-18 Thread drug via Digitalmars-d-learn
19.10.2015 02:57, holo пишет: How to make dub to work for me? Try ``` import kxml.xml; // instead of import kxml; ```

looking for sdl2 based application skeleton

2015-11-04 Thread drug via Digitalmars-d-learn
It seems to me I saw somewhere the project like this. I don't want to make another one if there is something like that.

dpaste.dzfl.pl is blocked

2015-11-07 Thread drug via Digitalmars-d-learn
What are alternatives for it? Thanks.

convertion of type tuple to enum

2015-11-24 Thread drug via Digitalmars-d-learn
What is the best way to do subj? I did ``` import std.array: array; import std.typetuple: TypeTuple; import std.typecons: tuple; import std.traits: EnumMembers; struct Foo {} struct Bar {} struct FooBar {} struct Baz {} string convertTypeTupleToEnum(Types...)() { string s = "enum Kind {

Re: Binding to GSL library

2015-11-25 Thread drug via Digitalmars-d-learn
On 25.11.2015 19:11, Radek wrote: Hi, I'm making a trying to bind a gsl library http://www.gnu.org/software/gsl/ so far it was working but when i started binding complex numbers some functions won't work, like trigonometric functions - called they return null. in gsl code complex struct looks li

Re: Converting a list of words or array of values to variables at compile time

2015-11-25 Thread drug via Digitalmars-d-learn
On 26.11.2015 09:33, Louie F wrote: I found out that compile time optimization is quite useful specially for database queries, instead of it being generated at every call, it can be generated like I typed it using compile time optimizations... so I thought, Is it possible to convert an array of

The best way to store a structure by reference

2015-11-27 Thread drug via Digitalmars-d-learn
I need to store a struct like a reference type. Now I use pointer for this, is it the best D way? This pointer is private and access to it is safe, but it's just unusual for me to see pointers in D code.

Re: The best way to store a structure by reference

2015-11-27 Thread drug via Digitalmars-d-learn
On 27.11.2015 11:38, drug wrote: I need to store a struct like a reference type. Now I use pointer for this, is it the best D way? This pointer is private and access to it is safe, but it's just unusual for me to see pointers in D code. Thank to all for answer. I stay with pointers in my case.

EnumMemberNames

2015-11-27 Thread drug via Digitalmars-d-learn
I need to get names of enum members, is it possible? EnumMembers returns the members itself, i.e. ``` enum Sqrts : real { one = 1, two = 1.41421, three = 1.73205, } pragma(msg, [EnumMembers!Sqrts]); ``` returns [1.0L, 1.41421L, 1.73205L] but I need [ "S

Re: EnumMemberNames

2015-11-27 Thread drug via Digitalmars-d-learn
On 27.11.2015 17:49, Adam D. Ruppe wrote: __traits(allMembers, Sqrts) Thanks to all for answers!

Constness understanding

2015-11-30 Thread drug via Digitalmars-d-learn
I have some struct and other struct stores reference to the first one like a pointer to constant. Nevertheless I can change the value of the first struct. Is it some hack? http://dpaste.dzfl.pl/0dfa3dff2df7

Re: Constness understanding

2015-11-30 Thread drug via Digitalmars-d-learn
On 30.11.2015 13:27, Kagamin wrote: Unfortunately in D constant doesn't mean constant :( it means readonly: you can read it, but it can change in other ways. Immutable means constant - doesn't change in any way. Thanks, considering 'const' as 'readonly' explains my case rather well.

Re: Pixelbuffer to draw on a surface

2015-11-30 Thread drug via Digitalmars-d-learn
On 30.11.2015 16:09, drug wrote: On 30.11.2015 15:49, TheDGuy wrote: On Monday, 30 November 2015 at 09:09:00 UTC, lobo wrote: On Monday, 30 November 2015 at 08:37:04 UTC, TheDGuy wrote: Hi, is there any possibility, to draw with a pixelbuffer to a surface (for example with GTKD) and to update

Re: Pixelbuffer to draw on a surface

2015-11-30 Thread drug via Digitalmars-d-learn
On 30.11.2015 15:49, TheDGuy wrote: On Monday, 30 November 2015 at 09:09:00 UTC, lobo wrote: On Monday, 30 November 2015 at 08:37:04 UTC, TheDGuy wrote: Hi, is there any possibility, to draw with a pixelbuffer to a surface (for example with GTKD) and to update it every few milliseconds? Are a

Re: Why does sum not work in static arrays?

2015-12-06 Thread drug via Digitalmars-d-learn
06.12.2015 15:23, Tim K. пишет: Hi! I have the following code: int main(string[] argv) { import std.algorithm: sum; import std.stdio: writeln; uint[3] a1 = [1, 2, 3]; uint[] a2; for (int i = 1; i <= 3; ++i) a2 ~= i; w

Using gdb by some process to let this process monitor its state by itself

2015-12-08 Thread drug via Digitalmars-d-learn
Is it possible to invoke gdb by some process that using data from gdb this process can inspect itself? For example I'd like to generate breakpoints for gdb with conditions and if this conditions meet get for example pointer to some data structure from gdb and process it by means of D, not gdb, t

Re: How to check if result of request to DB is empty?

2015-12-12 Thread drug via Digitalmars-d-learn
12.12.2015 13:28, Suliman пишет: it's seems that next block is execute even if is rs.next() is false: writeln("rs.next()-->", rs.next()); if(!rs.next()) //if user do not in DB { // is execute even if rs.next() is false writeln("Executed, but rs.nst was set to false"); } The output: rs.next()--

D float types operations vs C++ ones

2015-12-17 Thread drug via Digitalmars-d-learn
I have two implementation of the same algorithm - D and C++ (that is port of D version). I assume that running these implementations on the same data should give the same results from both. But with some data the results differ (5th decimal digit after point). For my purpose it isn't important

Re: D float types operations vs C++ ones

2015-12-17 Thread drug via Digitalmars-d-learn
On 17.12.2015 14:52, Andrea Fontana wrote: You should publish some code to check... Too much code to public - operations are simple, but there are many branches and reducing may take much time . In fact I asked to understand _in general_ if it worth diving into code to find the source of the

Re: D float types operations vs C++ ones

2015-12-17 Thread drug via Digitalmars-d-learn
On 17.12.2015 16:09, Nicholas Wilson wrote: Yes the float types are the same. floats doubles are identical long double == real ( at least for x86) The only difference is that float are default initialised to NaN in D. The sources of difference are likely to occur from - const folding (varying b

Re: D float types operations vs C++ ones

2015-12-17 Thread drug via Digitalmars-d-learn
On 18.12.2015 05:58, Nicholas Wilson wrote: On Thursday, 17 December 2015 at 13:30:11 UTC, drug wrote: On 17.12.2015 16:09, Nicholas Wilson wrote: [...] Thanks for answer. My C++ version is tracing D version so commutativity and distributivity aren't requred because order of operations is the

Re: use of typeof to determine auto type with ndslice examples

2015-12-20 Thread drug via Digitalmars-d-learn
21.12.2015 07:23, Jay Norwood пишет: import std.stdio; import std.experimental.ndslice; void main() { import std.algorithm.iteration: map; import std.array: array; import std.range; import std.traits; auto t0 = 1000.iota.sliced(3, 4, 5); pragma(msg, typeof(t0));

Re: Ranges: How to take N last of elements of range

2015-12-25 Thread drug via Digitalmars-d-learn
25.12.2015 17:13, Ur@nuz пишет: static struct LogerInfo { string func; int line; void write(T...)(T data) { import std.stdio; import std.algorithm: splitter; import std.range: retro; import std.range: ta

Re: Derelict SFML2 - structs are forward referenced

2015-12-26 Thread drug via Digitalmars-d-learn
26.12.2015 15:34, Lucien пишет: On Saturday, 26 December 2015 at 10:39:29 UTC, Rene Zwanenburg wrote: On Saturday, 26 December 2015 at 09:48:29 UTC, Lucien wrote: Hello. I want to use Derelict-SFML2 to create a simple window. But when I compile (linked with dub and derelict-util), I have the f

looking for SceneGraph D implementation

2016-04-14 Thread drug via Digitalmars-d-learn
Could somebody point to the D implementation of the scene graph?

Re: build a subpackage in dub?

2016-07-18 Thread drug via Digitalmars-d-learn
16.07.2016 20:26, cy пишет: Say I have a package called "main" and a sub-package in a "complicatedexample" directory, and my dub.json in "main" looks sort of like: "subPackages": [ "./complicatedexample/" ], Let's say I do *not* have ":complicatedexample" in my dependencies for "main", but "c

How to pass static array to function not by value?

2014-11-22 Thread drug via Digitalmars-d-learn
I tried to pass pointer to static array but it didn't work.

Re: How to pass static array to function not by value?

2014-11-22 Thread drug via Digitalmars-d-learn
On 22.11.2014 19:34, ketmar via Digitalmars-d-learn wrote: On Sat, 22 Nov 2014 18:20:44 +0400 drug via Digitalmars-d-learn wrote: I tried to pass pointer to static array but it didn't work. i tried it right now and it works. if you really want to get some help, you'd bett

Re: How to pass static array to function not by value?

2014-11-22 Thread drug via Digitalmars-d-learn
On 22.11.2014 20:26, Ali Çehreli wrote: On 11/22/2014 07:07 AM, drug wrote: > On 22.11.2014 19:34, ketmar via Digitalmars-d-learn wrote: >> On Sat, 22 Nov 2014 18:20:44 +0400 >> drug via Digitalmars-d-learn wrote: >> >>> I tried to pass pointer to static a

Re: How to pass static array to function not by value?

2014-11-22 Thread drug via Digitalmars-d-learn
On 22.11.2014 20:47, ketmar via Digitalmars-d-learn wrote: On Sat, 22 Nov 2014 19:07:14 +0400 drug via Digitalmars-d-learn wrote: Sorry for inconvenience. http://dpaste.dzfl.pl/64ab69ae80d2 this causes stackoverflow because static array is big enough. I'd like to pass it not by value to

Re: How to pass static array to function not by value?

2014-11-22 Thread drug via Digitalmars-d-learn
On 22.11.2014 20:26, Eric wrote: On Saturday, 22 November 2014 at 16:07:25 UTC, drug wrote: On 22.11.2014 19:34, ketmar via Digitalmars-d-learn wrote: On Sat, 22 Nov 2014 18:20:44 +0400 drug via Digitalmars-d-learn wrote: I tried to pass pointer to static array but it didn't work. i

Re: How to pass static array to function not by value?

2014-11-22 Thread drug via Digitalmars-d-learn
On 22.11.2014 20:30, ketmar via Digitalmars-d-learn wrote: On Sat, 22 Nov 2014 08:07:31 -0800 "H. S. Teoh via Digitalmars-d-learn" wrote: On Sat, Nov 22, 2014 at 05:57:30PM +0200, ketmar via Digitalmars-d-learn wrote: On Sat, 22 Nov 2014 15:45:51 + Eric via Digitalmars-d-learn wrote:

Re: How to pass static array to function not by value?

2014-11-22 Thread drug via Digitalmars-d-learn
On 22.11.2014 21:22, ketmar via Digitalmars-d-learn wrote: On Sat, 22 Nov 2014 20:05:13 +0400 drug via Digitalmars-d-learn wrote: Does it worth to make some compiler option that for example prohibits passing static array instead of dynamic one without slicing? Who has a lot of breakable

Re: scope block do not handle failure, but try-catch does

2014-12-14 Thread drug via Digitalmars-d-learn
On 13.12.2014 23:26, Suliman wrote: I reread docs and understood that scope not for such case. Next code is do what I need: try { string dbname = config.getKey("dbname"); string dbpass = config.getKey("dbpass"); string dbhost = config.getKey("dbhost"); string dbport = config.getKey("dbport"); }

Re: scope block do not handle failure, but try-catch does

2014-12-15 Thread drug via Digitalmars-d-learn
On 15.12.2014 12:22, "Marc Schütz" " wrote: Unfortunately you don't have access to the exception object inside the `scope(failure)` block. Ah, yes, it has to be without msg.msg scope(failure) writeln("Something is wrong");

Initialization of structure field w/o default ctor

2015-01-22 Thread drug via Digitalmars-d-learn
What's the best way to initialize structure field that has no default ctor? http://dpaste.dzfl.pl/64cd0a3879fa Also can I avoid "dummy" non-default ctor for Bar?

Re: Initialization of structure field w/o default ctor

2015-01-22 Thread drug via Digitalmars-d-learn
On 22.01.2015 15:30, bearophile wrote: drug: Also can I avoid "dummy" non-default ctor for Bar? One solution: struct Foo { int foo; @disable this(); this(int foo_) pure nothrow @safe @nogc { this.foo = foo_; } } struct Bar { enum arraySize = 3; Foo

is it bug?

2015-01-30 Thread drug via Digitalmars-d-learn
``` import std.container: RedBlackTree; class Manager(TT, alias Cmp = "a

Re: is it bug?

2015-01-30 Thread drug via Digitalmars-d-learn
The real problem is if I comment my unittest out then it compiles. Why my unittest causes this behaviour?

Re: is it bug?

2015-01-30 Thread drug via Digitalmars-d-learn
On 30.01.2015 16:31, BBaz wrote: On Friday, 30 January 2015 at 12:32:05 UTC, drug wrote: static init() { auto instance = new typeof(this)(); instance._cont = new Container(); return instance; } have you tried --- static typeof(this) init() {

Re: is it bug?

2015-01-30 Thread drug via Digitalmars-d-learn
On 30.01.2015 16:14, anonymous wrote: On Friday, 30 January 2015 at 13:11:35 UTC, anonymous wrote: Lines 846-850: static if(less == "a < b") auto vals = [1, 2, 3, 4, 5]; else auto vals = [5, 4, 3, 2, 1]; assert(equal(r, vals)); (Tab + Enter stri

<    1   2   3   4   >