Re: Array of const objects with indirections and std.algorithm.copy

2016-07-28 Thread drug via Digitalmars-d-learn
I see. I'll try to rephrase my question to be clear. We have: ``` struct Foo { int i; float f; } int main() { const(Foo)[] cfoo = [Foo(1, 0.5), Foo(2, 0.75)]; Foo[] foo; cfoo.copy(foo); // it works, constness no matter here because Foo is value type } ``` but

Array of const objects with indirections and std.algorithm.copy

2016-07-27 Thread drug via Digitalmars-d-learn
I have the following: ``` struct Foo { int[] i; this(int[] i) { this.i = i.dup; } ref Foo opAssign(ref const(this) other) { i = other.i.dup; return this; } }

Re: Trouble using 'sort'

2016-07-26 Thread drug via Digitalmars-d-learn
26.07.2016 09:11, Jonathan M Davis via Digitalmars-d-learn пишет: It's frequently the case that if you want to sort a range, you have to call array() on it to convert it to an array, and then you can sort the array. - Jonathan M Davis Another option is `makeIndex` (std.algorithm.sorting) and

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

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

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:

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

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

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

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,

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;

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.

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

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 [

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!

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

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

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 {

dpaste.dzfl.pl is blocked

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

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.

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; ```

Why 1f.iota(100f).array returns double[] not float[]?

2015-09-08 Thread drug via Digitalmars-d-learn
import std.array : array; import std.range : iota; pragma(msg, typeof(iota(1f, 100f).array)); // why double[] not float[]? void main() { }

Re: Status of Win32 C++ interop

2015-09-08 Thread drug via Digitalmars-d-learn
On 08.09.2015 11:45, Benjamin Thaut wrote: On Monday, 7 September 2015 at 19:30:44 UTC, drug wrote: 07.09.2015 21:37, Benjamin Thaut пишет: snip So far I haven't found a situation where I couldn't make it work the way I wanted. Its just some work to write the D headers for the C++ classes

Re: Status of Win32 C++ interop

2015-09-07 Thread drug via Digitalmars-d-learn
07.09.2015 21:37, Benjamin Thaut пишет: snip So far I haven't found a situation where I couldn't make it work the way I wanted. Its just some work to write the D headers for the C++ classes and vise versa, because you have to duplicate everything once more. An automated tool for this would be

Re: Why ElementType!(char[3]) == dchar instead of char?

2015-09-02 Thread drug via Digitalmars-d-learn
On 02.09.2015 11:30, FreeSlave wrote: I see, thanks. So I should always treat char[] as UTF in D itself, but because I need to pass char[], wchar[] or dchar[] to a C library I should treat it as not UTF but ubytes sequence or ushort or uint sequence - just to pass it correctly, right? You

std.experimental.logger instantiation fails in 2.067

2015-09-02 Thread drug via Digitalmars-d-learn
Before 2.067 I used std.experimental.logger in form of a dub package. Because it included in 2.067 I stop using the dub package but now I get the error: Error: safe function 'std.experimental.logger.core.Logger.memLogFunctions!cast(LogLevel)cast(ubyte)32u.logImplf!(383, [snip]).logImplf'

Re: std.experimental.logger instantiation fails in 2.067

2015-09-02 Thread drug via Digitalmars-d-learn
On 02.09.2015 11:36, Robert burner Schadek wrote: On Wednesday, 2 September 2015 at 06:57:12 UTC, drug wrote: Before 2.067 I used std.experimental.logger in form of a dub package. Because it included in 2.067 I stop using the dub package but now I get the error: Error: safe function

Re: Why ElementType!(char[3]) == dchar instead of char?

2015-09-01 Thread drug via Digitalmars-d-learn
My case is I don't know what type user will be using, because I write a library. What's the best way to process char[..] in this case?

Re: Safe copy-paste using mixin

2015-09-01 Thread drug via Digitalmars-d-learn
On 31.08.2015 16:30, cym13 wrote: No, in my case there is no problem, I'm curious. I guess that string mixins sometimes may look like a hack. IMHO they are a hack. That's why they should be used with caution (and why using them feels so good ^_^ ). But I don't see how mixing arbitrary code

Re: Why ElementType!(char[3]) == dchar instead of char?

2015-09-01 Thread drug via Digitalmars-d-learn
02.09.2015 00:08, Jonathan M Davis via Digitalmars-d-learn пишет: On Tuesday, September 01, 2015 20:05:18 drug via Digitalmars-d-learn wrote: My case is I don't know what type user will be using, because I write a library. What's the best way to process char[..] in this case? char[] should

Why ElementType!(char[3]) == dchar instead of char?

2015-09-01 Thread drug via Digitalmars-d-learn
http://dpaste.dzfl.pl/4535c5c03126

Re: Why ElementType!(char[3]) == dchar instead of char?

2015-09-01 Thread drug via Digitalmars-d-learn
On 01.09.2015 19:32, Justin Whear wrote: On Tue, 01 Sep 2015 16:25:53 +, Justin Whear wrote: On Tue, 01 Sep 2015 19:18:42 +0300, drug wrote: http://dpaste.dzfl.pl/4535c5c03126 Arrays of char are assumed to be UTF-8 encoded text and a single char is not necessarily sufficient to

Re: Why ElementType!(char[3]) == dchar instead of char?

2015-09-01 Thread drug via Digitalmars-d-learn
On 01.09.2015 19:18, drug wrote: http://dpaste.dzfl.pl/4535c5c03126 Should I use ForeachType!(char[3]) instead of ElementType?

Safe copy-paste using mixin

2015-08-31 Thread drug via Digitalmars-d-learn
I have code that is being duplicated in several places and I'd like to use mixins to simplify code maintenance but I failed to do it. For example https://github.com/drug007/hdf5-d-examples/blob/tmp/examples/aux.d Lines 80-82, 91-93 and 99-101 are identical, how can I use mixin here? I failed

Re: Safe copy-paste using mixin

2015-08-31 Thread drug via Digitalmars-d-learn
On 31.08.2015 13:57, Andrea Fontana wrote: Just create a function that return a string with those three lines and mixin it! Like: import std.stdio; string toMix( string a, string b, string c) { return `string a = "` ~ a ~ `";` ~ `string b = "` ~ b ~ `";` `string c = "` ~ c ~ `";`; }

Re: Safe copy-paste using mixin

2015-08-31 Thread drug via Digitalmars-d-learn
On 31.08.2015 14:36, cym13 wrote: On Monday, 31 August 2015 at 11:06:40 UTC, drug wrote: On 31.08.2015 13:57, Andrea Fontana wrote: Just create a function that return a string with those three lines and mixin it! Like: import std.stdio; string toMix( string a, string b, string c) {

Re: How to get BaseEnumType?

2015-08-31 Thread drug via Digitalmars-d-learn
On 31.08.2015 11:12, Enamex wrote: On Monday, 31 August 2015 at 07:55:53 UTC, drug wrote: Hello I need to get the type to which I can cast the enum for using with foreign library. For example: ``` enum Foo { A = "a", B = "b", } enum Bar { A = 123, B = 432, } static assert(is(BaseEnumType!Foo

Re: How to get BaseEnumType?

2015-08-31 Thread drug via Digitalmars-d-learn
On 31.08.2015 11:10, wobbles wrote: In std.traits there is the required isX funcitons. import std.stdio; import std.traits; void main(){ static if(isSomeString!Foo){ writefln("String: %s", Foo.A); } static if(isScalarType!Bar){

Re: Safe copy-paste using mixin

2015-08-31 Thread drug via Digitalmars-d-learn
On 31.08.2015 13:35, drug wrote: I have code that is being duplicated in several places and I'd like to use mixins to simplify code maintenance but I failed to do it. For example https://github.com/drug007/hdf5-d-examples/blob/tmp/examples/aux.d Lines 80-82, 91-93 and 99-101 are identical, how

How to get BaseEnumType?

2015-08-31 Thread drug via Digitalmars-d-learn
Hello I need to get the type to which I can cast the enum for using with foreign library. For example: ``` enum Foo { A = "a", B = "b", } enum Bar { A = 123, B = 432, } static assert(is(BaseEnumType!Foo == string)); static assert(is(BaseEnumType!Bar == int)); I guess there is simple answer

Re: Safe copy-paste using mixin

2015-08-31 Thread drug via Digitalmars-d-learn
On 31.08.2015 15:28, Andrea Fontana wrote: On Monday, 31 August 2015 at 11:06:40 UTC, drug wrote: On 31.08.2015 13:57, Andrea Fontana wrote: Just create a function that return a string with those three lines and mixin it! Like: import std.stdio; string toMix( string a, string b, string c)

Re: What is the D way to map a binary file to a structure?

2015-08-29 Thread drug via Digitalmars-d-learn
29.08.2015 15:56, cym13 пишет: Hi, Let's say I have a simple binary file whose structure is well-known. Here is an example which stores points: struct Point { long x; long y; long z; } struct BinFile { uintmagicNumber; // Some identifier ulong pointsNumber;

Re: What is the D way to map a binary file to a structure?

2015-08-29 Thread drug via Digitalmars-d-learn
29.08.2015 17:17, cym13 пишет: On Saturday, 29 August 2015 at 13:56:10 UTC, drug wrote: Try, for example, MessagePack https://github.com/msgpack/msgpack-d.git Thanks, but it isn't answering the question at all. I'm not looking for a serialization method, I'm looking for the best way to read a

Re: What is the D way to map a binary file to a structure?

2015-08-29 Thread drug via Digitalmars-d-learn
29.08.2015 18:05, cym13 пишет: On Saturday, 29 August 2015 at 14:52:51 UTC, drug wrote: 29.08.2015 17:17, cym13 пишет: On Saturday, 29 August 2015 at 13:56:10 UTC, drug wrote: Try, for example, MessagePack https://github.com/msgpack/msgpack-d.git Thanks, but it isn't answering the question

Re: Removing elements from dynamic array

2015-08-09 Thread drug via Digitalmars-d-learn
09.08.2015 23:22, Reflexive пишет: Try to use this.sabotarray = this.sabotarray.remove(id_card); remove() removes element(s) but doesn't change length of 'old' array. To get new length you should use 'new' array that returned from remove(). In this case I get rid of two excessive kings in

Re: Using std.random.uniform as a range

2015-08-08 Thread drug via Digitalmars-d-learn
08.08.2015 01:34, Ali Çehreli пишет: On 08/07/2015 06:59 AM, drug wrote: What is the best way to create range from uniform() function (in other words create a generator based on some function, returning, say, scalar, not range)? I did http://dpaste.dzfl.pl/53e3d9255cd7 but I'm not sure it's the

Using std.random.uniform as a range

2015-08-07 Thread drug via Digitalmars-d-learn
What is the best way to create range from uniform() function (in other words create a generator based on some function, returning, say, scalar, not range)? I did http://dpaste.dzfl.pl/53e3d9255cd7 but I'm not sure it's the best way. At least sequence using looks ugly

How to implement immutable ring buffer?

2015-05-27 Thread drug via Digitalmars-d-learn
Could somebody share his thoughts on the subject? Would it be efficient? Is it possible to avoid memory copying to provide immutability? To avoid cache missing ring buffer should be like array, not list, so it's possible that the whole buffer should be moved. Is it neccessary to be real

Re: How to implement immutable ring buffer?

2015-05-27 Thread drug via Digitalmars-d-learn
On 27.05.2015 11:04, thedeemon wrote: This whole idea sounds self-contradictory. Ring buffer is a mutable-array-based implementation of something, for example of a queue. You can ask about immutable implementations of a queue, but that would be another question, not involving a ring buffer.

Re: How to implement immutable ring buffer?

2015-05-27 Thread drug via Digitalmars-d-learn
On 27.05.2015 11:10, Daniel Kozák via Digitalmars-d-learn wrote: On Wed, 27 May 2015 09:20:52 + drug via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Could somebody share his thoughts on the subject? Would it be efficient? Is it possible to avoid memory copying to provide

Re: problem with custom predicate

2015-05-27 Thread drug via Digitalmars-d-learn
On 27.05.2015 13:50, Simon Bürger simon.buer...@rwth-aachen.de wrote: I am trying to use a Container class with a custom predicate, but the following code does not compile. Any hints on how to do it? import std.container; class C { int[] prio; RedBlackTree!(int, (a,b)=prio[a]prio[b])

Re: is it std.datetime bug?

2015-04-02 Thread drug via Digitalmars-d-learn
On 02.04.2015 09:19, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, March 31, 2015 12:47:34 anonymous via Digitalmars-d-learn wrote: On Tuesday, 31 March 2015 at 11:51:26 UTC, drug wrote: import std.datetime; import std.stdio; void main() {

is it std.datetime bug?

2015-03-31 Thread drug via Digitalmars-d-learn
import std.datetime; import std.stdio; void main() { long.max.SysTime.toISOExtString.writeln; } dmd 2.065 (dpaste.dzfl.pl): +29228-09-14T02:48:05.4775807 dmd v2.067-devel-c6b489b (using Digger): -29227-04-20T00:11:54.5224191 could somebody confirm it?

Re: D constness: head tail

2015-03-02 Thread drug via Digitalmars-d-learn
On 02.03.2015 14:51, Jonathan M Davis via Digitalmars-d-learn wrote: On Monday, March 02, 2015 14:20:45 drug via Digitalmars-d-learn wrote: I'm just trying to study constness in D and periodically fails with it. Thanks for answer. Then I guess that constness in D is in the finished form, hasn't

Shouldn't std.conv.emplace be @nogc?

2015-03-02 Thread drug via Digitalmars-d-learn
I guess the reason why std.conv.emplace is not @nogc-ed is that nobody added it yet? I didn't see using of gc in the emplace sources.

D constness: head tail

2015-03-02 Thread drug via Digitalmars-d-learn
what is the state of headtail constness in D? Where we are and where we are moving toward? Where can I find some info about head and tail constness? I mean forum posts, stackoverflow questions, arcticles somewhere and so on. Thank in advance

Re: D constness: head tail

2015-03-02 Thread drug via Digitalmars-d-learn
I'm just trying to study constness in D and periodically fails with it. Thanks for answer. Then I guess that constness in D is in the finished form, hasn't some pitfalls, won't be changed significantly in some future and so I just need to learn it and understand it?

Re: Why rbtree.length isn't const?

2015-03-01 Thread drug via Digitalmars-d-learn
On 26.02.2015 18:44, Steven Schveighoffer wrote: Please submit an issue. http://issues.dlang.org -Steve Done: https://issues.dlang.org/show_bug.cgi?id=14234

Why rbtree.length isn't const?

2015-02-26 Thread drug via Digitalmars-d-learn
Is it intended by some reason?

Getting range of const rbtree

2015-02-26 Thread drug via Digitalmars-d-learn
I can't get the range of const RedBlackTree because opSlice is mutable: http://dpaste.dzfl.pl/02fadc472eea What is the best way to iterate over const collection of elements? Thanks

Re: What am I doing Wrong (OpenGL SDL)

2015-02-05 Thread drug via Digitalmars-d-learn
On 05.02.2015 10:53, Entity325 wrote: On Thursday, 5 February 2015 at 07:23:15 UTC, drug wrote: Look at this https://github.com/drug007/geoviewer/blob/master/src/sdlapp.d I used here SDL and OpenGL and it worked. Ctor of SDLApp creates SDL window with OpenGL context, may be it helps. Tested

Re: What am I doing Wrong (OpenGL SDL)

2015-02-04 Thread drug via Digitalmars-d-learn
On 05.02.2015 09:57, Entity325 wrote: On Thursday, 5 February 2015 at 06:07:34 UTC, Entity325 wrote: I will see how much I can strip away and still reproduce the problem. If I find the cause before then, I'll be sure to report back here. I don't know if this is relevant, but while stripping

Re: is it bug?

2015-01-30 Thread drug via Digitalmars-d-learn
On 30.01.2015 16:56, anonymous wrote: Besides, it's a bad idea to call a member init, because it steals the name of the default initializer. It doesn't override the default initializer, it just takes its name. The compiler should not accept it, in my opinion. Good remark! I'll rename it.

Re: is it bug?

2015-01-30 Thread drug via Digitalmars-d-learn
On 30.01.2015 17:04, BBaz wrote: Yes, that was the point: bad idea to call a member init. But I've missed something with inference of return type... let's call this the BMS : big-mouth-syndrom... I didn't know it could be ommitted...I thought it could be if the function has

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

Re: is it bug?

2015-01-30 Thread drug via Digitalmars-d-learn
On 30.01.2015 16:35, drug wrote: 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];

is it bug?

2015-01-30 Thread drug via Digitalmars-d-learn
``` import std.container: RedBlackTree; class Manager(TT, alias Cmp = ab) { alias Container = RedBlackTree!(TT, Cmp); Container _cont; static init() { auto instance = new typeof(this)(); instance._cont = new Container(); return instance; } }

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;

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 schue...@gmx.net 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);

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); } catch

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-learndigitalmars-d-learn@puremagic.com 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

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-learndigitalmars-d-learn@puremagic.com wrote: I tried to pass pointer to static array but it

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-learndigitalmars-d-learn@puremagic.com wrote: I tried to pass pointer to static

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 digitalmars-d-learn@puremagic.com 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

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-learndigitalmars-d-learn@puremagic.com wrote: Does it worth to make some compiler option that for example prohibits passing static array instead of dynamic one without slicing?

<    1   2   3   4