```
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
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 !=
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
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,
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
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
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
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
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
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?
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
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
https://run.dlang.io/is/uk0CMC
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
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?
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
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
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
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
04.10.2017 12:54, Biotronic пишет:
template isTemplate(T...) if (T.length == 1) {
enum isTemplate = __traits(isTemplate, T[0]);
}
--
Biotronic
Thank you!
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
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
https://run.dlang.io/is/duecIS
oops, it was my fault. sorry for noise. my apologies to ElementType ))
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
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
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
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
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
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
https://run.dlang.io/is/vOh6YY
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
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)&
Is there any reason `std.container.array.Array.__dtor` isn't @safe,
@pure etc?
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
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
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
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
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
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
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
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
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)[
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
probably this can help you
https://github.com/drug007/timespatial
this project uses cimgui by means of derelict-imgui
I've check it before posting using old version dmd 2.073 and it works.
What dmd version you compile with?
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
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
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
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
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
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.
https://run.dlang.io/is/zHT2XZ
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
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
done https://issues.dlang.org/show_bug.cgi?id=18539
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*
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
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()
{
19.10.2015 02:57, holo пишет:
How to make dub to work for me?
Try
```
import kxml.xml; // instead of import kxml;
```
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.
What are alternatives for it? Thanks.
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 {
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
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
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 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 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 17:49, Adam D. Ruppe wrote:
__traits(allMembers, Sqrts)
Thanks to all for answers!
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 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.
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 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
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
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
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()--
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
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
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 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
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));
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
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
Could somebody point to the D implementation of the scene graph?
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
I tried to pass pointer to static array but it didn't work.
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
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 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, 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: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 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 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 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");
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 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
```
import std.container: RedBlackTree;
class Manager(TT, alias Cmp = "a
The real problem is if I comment my unittest out then it compiles. Why
my unittest causes this behaviour?
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()
{
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
201 - 300 of 389 matches
Mail list logo