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;
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 i
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;
}
}
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 t
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
Could somebody point to the D implementation of the scene graph?
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
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
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));
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
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
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
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
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()--
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
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
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
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
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.
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
On 27.11.2015 17:49, Adam D. Ruppe wrote:
__traits(allMembers, Sqrts)
Thanks to all for answers!
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
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.
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.
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
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
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 {
What are alternatives for it? Thanks.
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.
19.10.2015 02:57, holo пишет:
How to make dub to work for me?
Try
```
import kxml.xml; // instead of import kxml;
```
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
and
import std.array : array;
import std.range : iota;
pragma(msg, typeof(iota(1f, 100f).array)); // why double[] not float[]?
void main()
{
}
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 n
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
'std.experim
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 shoul
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' cannot
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?
cha
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?
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 represen
On 01.09.2015 19:18, drug wrote:
http://dpaste.dzfl.pl/4535c5c03126
Should I use ForeachType!(char[3]) instead of ElementType?
http://dpaste.dzfl.pl/4535c5c03126
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 inst
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)
{
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)
{
ret
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 ~ `";`;
}
vo
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 c
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 to
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 ==
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){
writef
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 som
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 a
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
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;
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 ca
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
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
On 27.05.2015 13:50, "Simon Bürger" " 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]Do you want to dynamically change
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 wrote:
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
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.
What
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 immutab
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()
{
long.max.SysTime.toISOExtString.wri
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?
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.
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, h
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?
what is the state of head&tail 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
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
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
Is it intended by some reason?
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 yo
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 do
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.
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 the'@safe'attri
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];
assert(eq
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
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()
{
The real problem is if I comment my unittest out then it compiles. Why
my unittest causes this behaviour?
```
import std.container: RedBlackTree;
class Manager(TT, alias Cmp = "a
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
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?
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");
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");
}
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
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:
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
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
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
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
I tried to pass pointer to static array but it didn't work.
301 - 389 of 389 matches
Mail list logo