On Wednesday, 16 March 2016 at 11:22:02 UTC, rikki cattermole
wrote:
Change those static if's to just plain old ifs.
But then this wouldn't compile, would it?
```
static if(__traits(compiles, __traits(getMember, a, "b"))) {
return a.b;
}
```
(real code, I am not making this up)
Imagine tho
On Wednesday, 16 March 2016 at 17:34:13 UTC, Steven Schveighoffer
wrote:
On 3/16/16 7:18 AM, Johan Engelen wrote:
Hi all,
I've found discussions, but not an actual "recommended"
solution for
the problem of "statement is not reachable" warnings in
templates with
early returns, e.g.:
```
boo
On Wednesday, 16 March 2016 at 22:07:39 UTC, Anonymouse wrote:
size_t pos = "banana".indexOf("c");
if (pos > 0) {
Although I also think it makes sense to warn (in specific cases)
about mixed-sign comparisons, the example you give here does
nothing that we can warn about. It is a comparison o
On Wednesday, 16 March 2016 at 11:47:35 UTC, QAston wrote:
import std.meta;
template isBool(U)() = is(U == bool);
static if (!allSatisfy!(isBool, T)) {
return true; // no longer emits a warning
}
Something like this should work.
Thanks, but:
On Wednesday, 16 March 2016 at 11:18:36 UTC,
Hi all,
I've found discussions, but not an actual "recommended"
solution for the problem of "statement is not reachable" warnings
in templates with early returns, e.g.:
```
bool nobool(T...)() {
foreach (i, U; T) {
static if (is(U == bool)) {
return false;
}
On Monday, 21 March 2016 at 23:31:06 UTC, ref2401 wrote:
I have got a plenty of structs in my project. Their size varies
from 12 bytes to 128 bytes.
Is there a rule of thumb that states which structs I pass by
value and which I should pass by reference due to their size?
Note that the compiler
On Tuesday, 22 March 2016 at 07:35:49 UTC, ZombineDev wrote:
If the object is larger than the size of a register on the
target machine, it is implicitly passed by ref (i.e. struct
fields are accessed by offset from the stack pointer).
(Oops, sorry ZombineDev, should've read your reply first)
On Friday, 1 April 2016 at 01:21:32 UTC, Walter Bright wrote:
On 3/16/2016 4:18 AM, Johan Engelen wrote:
I've found discussions, but not an actual "recommended"
solution for the
problem of "statement is not reachable" warnings in templates
with early
returns, e.g.:
```
bool nobool(T...)() {
On Tuesday, 5 April 2016 at 18:01:05 UTC, Nick Sabalausky wrote:
These days, DMD/DMDFE version numbers are three parts, ex:
2.070.1.
I can get the first two via std.compiler.version_major and
std.compiler.version_minor. Is there a way to get the third
part?
I know I can "dmd --help | grep D
I am trying to get the vtable pointer as a constant (!).
I've found
auto vptr = typeid(A).vtbl.ptr
gets me the pointer, but because TypeInfo is not immutable
(another forum thread), this will read the pointer from memory
instead of loading a direct value.
Does anybody know how to get the cla
On Thursday, 7 April 2016 at 20:49:40 UTC, Adam D. Ruppe wrote:
On Thursday, 7 April 2016 at 20:43:04 UTC, Johan Engelen wrote:
Does anybody know how to get the class's vtable pointer
without doing a memory read?
I don't think you can... why do you want it though?
I have implemented PGO (pro
On Thursday, 19 May 2016 at 23:21:14 UTC, Jonathan M Davis wrote:
No. D's const and immutable provide no backdoors. Rather, they
provide strong guarantees. So, if a variable is const, then it
cannot be mutated (even internally) except via a mutable
reference to the same data.
The "even inte
The following code compiles with DMD 2.070, but not with 2.071:
```
module mod;
import std.range;
struct S
{
struct Inner
{
int unique_identifier_name;
int tail;
}
Inner inner;
alias inner this;
auto works()
{
return unique_identifier_name;
On Friday, 27 May 2016 at 17:00:04 UTC, Steven Schveighoffer
wrote:
Now, the question here is, when does alias this kick in? I
would say it should follow alias this before looking outside
the module, so I say it's a bug.
https://issues.dlang.org/show_bug.cgi?id=16086
On Tuesday, 31 May 2016 at 18:55:18 UTC, Gary Willoughby wrote:
If I have a pointer and iterate over it using a slice, like
this:
T* foo = &data;
foreach (element; foo[0 .. length])
{
...
}
Is there any overhead compared with pointer arithmeti
On Wednesday, 1 June 2016 at 23:23:49 UTC, ZILtoid1991 wrote:
Here's the assembly code for my alpha-blending routine:
Could you also paste the D version of your code? Perhaps the
compiler (LDC, GDC) will generate similarly vectorized code that
is inlinable, etc.
-Johan
On Tuesday, 7 June 2016 at 15:33:57 UTC, chmike wrote:
or should I do it the C way with multiple embedded static if...
In your example, `version` would also work instead of `static if`.
I would not copy much code needlessly, and go with the embedded
version/static ifs.
- Johan
On Friday, 10 June 2016 at 19:37:13 UTC, Joerg Joergonson wrote:
arm-linux-genuabi? arm-linux-gnueableihfqueridsofeyfh?
aifh-fkeif-f-fdsskjhfkjfafaa?
Rofl!
and ldc requires building from sources(actually I didn't have
too much trouble with installing it but it doesn't work wit
On Saturday, 11 June 2016 at 08:48:42 UTC, Mike Parker wrote:
[... a lot ...]
This looks like a nice writeup Mike, could you get this on the
Wiki or somewhere more permanent where people can find it?
-Johan
On Sunday, 12 June 2016 at 03:11:14 UTC, Mike Parker wrote:
On Sunday, 12 June 2016 at 01:51:05 UTC, Joerg Joergonson wrote:
DMD works fine BTW. GDC and LDC should be a drop in
replacement. Not a totally new setup that has it's own set of
problems. I'm sure I'm not the only one put off by the
On Sunday, 12 June 2016 at 04:19:33 UTC, Joerg Joergonson wrote:
So ldc parses things differently than dmd... I imagine this is
a bug!
That, or you are comparing different D language versions.
The D language is evolving: different DMD compiler versions may
treat the same code differently.
On Sunday, 12 June 2016 at 04:19:33 UTC, Joerg Joergonson wrote:
Here are the versions
The one that isn't working:
LDC - the LLVM D compiler (30b1ed):
based on DMD v2.071.1 and LLVM 3.9.0git-d06ea8a
built with LDC - the LLVM D compiler (1.0.0)
Default target: x86_64-pc-windows-msvc
Host
On Friday, 17 June 2016 at 10:50:55 UTC, Gary Willoughby wrote:
I have a struct where I need to perform default initialization
of some members but the compiler doesn't allow to define a
default constructor which allow optional arguments.
This is a fairly recent change (2.068->2.069 or 2.070),
Hi all,
Is there another way to get access to Voldemort class methods,
or private class members, other than using "pragma(mangle, ...)"
on user symbols?
Example code:
In library, and _should not_ be changed :
```
Object getObject() {
class Vold : Object {
int store;
this
On Friday, 17 June 2016 at 21:07:31 UTC, cy wrote:
On Friday, 17 June 2016 at 19:49:18 UTC, Johan Engelen wrote:
Hi all,
Is there another way to get access to Voldemort class
methods, or private class members, other than using
[... snip ...]
Because of the guarantee that you can link to op
Someone figured out how to do it and put it in std.traits! ;-)
Example:
```
import std.stdio;
import core.thread;
import std.traits;
void main()
{
Fields!Thread[11] a;
writeln(typeid(a));
}
```
This prints "core.thread.Thread.Context" , which is a private
struct type of core.thread.Thre
On Saturday, 18 June 2016 at 17:50:51 UTC, cy wrote:
On Saturday, 18 June 2016 at 08:41:30 UTC, Johan Engelen wrote:
Without going in too much detail, the problem is that I am not
linking to opaque .o files.
The problem is the compiler has to assume you *might* be
linking to opaque .o files,
On Monday, 27 June 2016 at 21:58:04 UTC, "Smoke" Adams wrote:
I'm in need of a way to create a local array that isn't GC'ed.
It must be dynamic in the sense of setting the size at compile
time but it will be used only in scope and only on structs.
`alloca` is made for that purpose.
https://dla
On Saturday, 16 July 2016 at 22:05:49 UTC, ketmar wrote:
`foreach (v; rng)` looks like `foreach` is *reusing* *existing*
*variable*.
+1
How do conditionally compile code for either release ("-release")
or debug ("-debug")?
Something like this:
version(Debug) {
pragma(lib, "libcmtd.lib");
} else {
pragma(lib, "libcmt.lib");
}
In the documentation [1], I don't see any predefined version
identifiers for this purpose.
Th
On Monday, 6 April 2015 at 14:55:58 UTC, Namespace wrote:
debug {
pragma(lib, "libcmtd.lib");
} else {
pragma(lib, "libcmt.lib");
}
Thanks for the quick reply!
Worth adding an example like that to
http://dlang.org/version.html ?
On Monday, 6 April 2015 at 15:24:53 UTC, Namespace wrote:
On Monday, 6 April 2015 at 15:15:48 UTC, Johan Engelen wrote:
On Monday, 6 April 2015 at 14:55:58 UTC, Namespace wrote:
debug {
pragma(lib, "libcmtd.lib");
} else {
pragma(lib, "libcmt.lib");
}
Thanks for the quick reply!
Worth a
Hi all,
I am wondering if there is any Phobos functionality for
indexing into a list using a type. What I mean is something like:
assert( somethingie!(float, float, double, real)(1, 22, 333) ==
1 );
assert( somethingie!(double, float, double, real)(1, 22, 333) ==
22 );
assert( somethi
On Thursday, 18 August 2016 at 11:43:03 UTC, Lodovico Giaretta
wrote:
On Thursday, 18 August 2016 at 11:11:10 UTC, mogu wrote:
Compiler Error exactly. The minimal code is(dmd or ldc2 in
ubuntu 16.04 lts):
```
extern (C++, struct)
class A {}
```
Error: identifier expected for C++ namespace fo
On Friday, 26 August 2016 at 09:48:00 UTC, Jonathan M Davis wrote:
You're supposed to be able to depend on .init existing. Default
initialization for structs can be disabled via
@disable this();
but even then, the init member still exists (it just isn't used
for default initialization).
F
On Thursday, 1 September 2016 at 10:37:18 UTC, Miguel L wrote:
Also, forgot to specify I am using LDC with -05.
And the version of LDC too please ;-)
In the binary heap documentation, I read that
`BinaryHeap.front()` "Returns a copy of the front of the heap".
[1]
Is there no function to access the front of the heap without a
copy? (micro-optimization)
Thanks,
Johan
[1]
https://dlang.org/phobos/std_container_binaryheap.html#.BinaryHeap.
On Tuesday, 13 September 2016 at 08:55:15 UTC, Nicholas Wilson
wrote:
On Tuesday, 13 September 2016 at 08:19:04 UTC, Johan Engelen
wrote:
In the binary heap documentation, I read that
`BinaryHeap.front()` "Returns a copy of the front of the
heap". [1]
Is there no function to access the front of
On Tuesday, 13 September 2016 at 08:19:04 UTC, Johan Engelen
wrote:
In the binary heap documentation, I read that
`BinaryHeap.front()` "Returns a copy of the front of the heap".
[1]
Is there no function to access the front of the heap without a
copy? (micro-optimization)
Answering myself her
What's the bug in the following code:
```d
import std.digest.md;
import std.stdio;
pragma(inline, false) // just in case
string getHash()
{
ubyte[16] hash = [1,2,3,4,5,6,6,78,8,8,7,7,6,3,2,3];
string a = toHexString(hash);
return a;
}
pragma(inline, false) // just in case
void destr
On Wednesday, 21 September 2016 at 12:20:14 UTC, Adam D. Ruppe
wrote:
It is neither, the compiler chose the right overload (remember,
overloads are chosen based on the arguments alone, the type you
specify for the variable holding the return value isn't a
consideration there) and the implemen
On Wednesday, 21 September 2016 at 12:20:14 UTC, Adam D. Ruppe
wrote:
This is a pretty common pitfall (and IMO one of the most
egregious design flaws in the language), I see it all the time.
I write very little D code, so I guess it had to happen at some
point then. Man, this is really bad :
On Wednesday, 21 September 2016 at 13:06:08 UTC, Adam D. Ruppe
wrote:
the variable you are assigning the result to never does
anything with regard to overloads or template args.
Gotcha, thanks.
On Saturday, 15 October 2016 at 07:39:31 UTC, ketmar wrote:
On Friday, 14 October 2016 at 15:13:58 UTC, Jonathan M Davis
wrote:
On Thursday, October 13, 2016 19:07:44 Nordlöw via
Digitalmars-d-learn wrote:
Is there a large speed difference in compilation time
depending on whether the DMD used i
On Tuesday, 18 October 2016 at 05:23:15 UTC, Jason C. Wells wrote:
I am working my way up to building NanoVG per my previous post.
I am able to compile hello world using dmd2. I am running in
cygwin because I understand bash way better than cmd.exe.
Does `ldc2 hello.d` also fail in cmd.exe?
On Tuesday, 18 October 2016 at 17:29:34 UTC, Jason C. Wells wrote:
C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\vcvarsall.bat did in fact exist. My search for the file
must have been errant.
ldc2.exe hello.d also failed in cmd.exe.
I took Mike's advice to run cmd.exe from one of the
On Wednesday, 19 October 2016 at 10:25:51 UTC, Lodovico Giaretta
wrote:
Hi!
A simple question: is there a way to list all defined version
specifications?
Perhaps not what you are looking for but on the commandline:
bin/ldc2 -v test.d
...
predefs LDC all D_Version2 assert X86_64 D_Inline
On Friday, 28 October 2016 at 05:16:45 UTC, Basile B. wrote:
Here are the specifications of token strings:
"Token strings open with the characters q{ and close with the
token }. In between must be valid D tokens. The { and }"
So we can deduce that any invalid D token inside a token string
wi
On Wednesday, 30 November 2016 at 18:50:42 UTC, Dukc wrote:
On Wednesday, 30 November 2016 at 18:26:32 UTC, Jonathan M
Davis wrote:
[snip]
- Jonathan M Davis
Luckily, I have made a branch for my stuff instead of using
master. But thanks for the help, now I know that it does not
matter where
On Tuesday, 13 December 2016 at 21:27:57 UTC, Xavier Bigand wrote:
Hi,
I have the following code snippet :
voidset()
{
GLfloat[] data = [
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
0.0f,
On Wednesday, 14 December 2016 at 07:15:08 UTC, Bauss wrote:
If a function is only called during compile-time will it be
available at runtime?
With "available at runtime", I guess you mean "will it be part of
the object file". In that case: yes. Because even if a function
is _never_ called, i
On Tuesday, 27 December 2016 at 17:56:07 UTC, Stefan Koch wrote:
On Tuesday, 27 December 2016 at 17:50:15 UTC, Joseph Rushton
Wakeling wrote:
Hello all,
[ ... ]
Can anyone advise what could be going wrong here? This looks
like a nasty CTFE bug to me :-(
Thanks & best wishes,
-- Joe
I
On Friday, 3 February 2017 at 17:20:43 UTC, WhatMeWorry wrote:
-file post_processor.d --
module post_processor;
class PostProcessor
{
...
GLuint FBO;
}
-file game.d ---
module game;
PostProcessor postProc; // ju
Hi all,
`isNumeric!string` no longer works like it did in 2.071 when both
std.string and std.traits are imported.
This code no longer compiles with 2.072:
```d
// RUN: dmd -c test.d
import std.string;
import std.traits;
void foo()
{
static if (isNumeric!string) {}
}
```
The error is (
On Thursday, 16 February 2017 at 23:15:09 UTC, Johan Engelen
wrote:
Hi all,
`isNumeric!string` no longer works like it did in 2.071 when
both std.string and std.traits are imported.
https://issues.dlang.org/show_bug.cgi?id=17190
This code compiles with 2.071, but not with 2.072 nor 2.073:
```
struct S {
int i;
auto ref foo() @safe {
return i;
}
auto bar() @safe {
return &foo(); // <-- Error
}
}
void main() {
auto s = S();
s.bar(
On Monday, 20 February 2017 at 13:16:15 UTC, Jonathan M Davis
wrote:
dmd is great for fast compilation and therefore it's great for
development. However, while it produces decent binaries, and it
may very well do certain optimizations better than the gcc or
llvm backends do
This I find hard t
On Wednesday, 1 March 2017 at 18:34:16 UTC, Iain Buclaw wrote:
Simple test case would be:
struct vec_struct {
bool b2;
struct {
bool b;
int8 field;
}
}
static assert(vec_struct.b.offsetof == 32);
static assert(vec_struct.field.offsetof == 64);
With explicit align(
On Thursday, 2 March 2017 at 13:00:08 UTC, Cecil Ward wrote:
Raised bug here, and I'm raising a PR now also.
https://issues.dlang.org/show_bug.cgi?id=17237
Iain, this of course is present in my version of LDC too. (I
checked.) You couldn't poke David Nadlinger or whoever for me?
Poke recei
On Friday, 3 March 2017 at 22:06:11 UTC, berni wrote:
On Friday, 3 March 2017 at 20:10:25 UTC, Ali Çehreli wrote:
Which would put gdc in between the two. Is your experience
different?
Actually, I've got not much experience. A few weeks ago I ran a
test where ldc was in between dmd and gdc. Bu
On Saturday, 4 March 2017 at 18:45:22 UTC, berni wrote:
[...]
If you think, this program could be usefull for you, I can
email it to you...
The smaller the testcase, the better. You mentioned that for
testcase "B" there is a ~10% performance difference between GDC
and LDC, so that's defini
On Saturday, 8 April 2017 at 12:16:10 UTC, Russel Winder wrote:
Fedora Rawhide is now on LLVM 4.0 is that going to be a problem
building LDC?
Of course not! ;-)
-Johan
On Saturday, 20 May 2017 at 08:02:26 UTC, lixiaozi wrote:
[...]
I noticed it's the inline optimization in ldc2 that caused the
crash.
If you are certain that your code is 100% correct, please file a
bug report. Inlining is done by LLVM and it is rare to find an
LLVM bug like that (what archi
On Saturday, 20 May 2017 at 08:02:26 UTC, lixiaozi wrote:
Now, I try to disable inlining in "dub.json" like
==
"dflags":[
"-disable-inlining"
],
==
but it doesn't work, because then dub calls ldc2 like this:
'ldc2 -disable-inlining -release -enable-inlining
-Hkeep-a
On Friday, 9 June 2017 at 16:21:22 UTC, Honey wrote:
What seems particularly strange to me is that -boundscheck=off
leads to a performance decrease.
Strange indeed.
`-release` should be synonymous with `-release -boundscheck=off`.
Investigating...
- Johan
On Saturday, 10 June 2017 at 11:43:06 UTC, Johan Engelen wrote:
On Friday, 9 June 2017 at 16:21:22 UTC, Honey wrote:
What seems particularly strange to me is that -boundscheck=off
leads to a performance decrease.
Strange indeed.
`-release` should be synonymous with `-release
-boundscheck=off`
Reviving this thread to see whether anything has changed on the
topic.
I now have this monster:
```
struct FMT {
// has immutable members. FMT cannot be assigned to.
}
FMT monsterThatCompilerAccepts(T)(){
alias TP = Tuple!(__traits(getAttributes, T));
foreach(i, att; TP){
stat
On Sunday, 18 June 2017 at 09:56:50 UTC, Steven Schveighoffer
wrote:
On Sunday, 18 June 2017 at 09:28:57 UTC, Johan Engelen wrote:
Reviving this thread to see whether anything has changed on
the topic.
If Timon gets static for each into the language, it can look a
little better.
Can you h
How would you solve this problem: do an optional function call
depending on some version(X). If version(X) is not defined, there
should be no call and no extra code at -O0.
```
{
...
foo(); // either compiles to a function call, or to _nothing_.
...
}
```
In C, you could do something like:
On Sunday, 25 June 2017 at 16:31:52 UTC, Moritz Maxeiner wrote:
On Sunday, 25 June 2017 at 15:58:48 UTC, Johan Engelen wrote:
[...]
If version(X) is not defined, there should be no call and no
extra code at -O0.
[...]
In C, you could do something like:
```
#if X
void foo() {..}
#else
On Sunday, 25 June 2017 at 16:29:20 UTC, Anonymouse wrote:
Am I missing something, or can't you just version both the
function and the function ćall?
version(X)
void foo() { /* ... */ }
void main()
{
version(X)
{
foo();
}
}
I am hoping for something where "foo()" would
On Sunday, 25 June 2017 at 22:23:44 UTC, Moritz Maxeiner wrote:
The solution obviously does *not* work if you change the
premise of your question after the fact by artificially
injecting instructions into all function bodies
I meant semantically no call. I am asking for a little more
imagin
On Sunday, 25 June 2017 at 23:02:28 UTC, Adam D. Ruppe wrote:
That'd be kinda tricky because the arguments would still be
liable to be evaluated...
Well..
I guess someone might argue that's a mis-feature of my
preprocessor example: "foo(i++)" may not do what you want. (So
the C code would
On Sunday, 25 June 2017 at 23:02:28 UTC, Adam D. Ruppe wrote:
On Sunday, 25 June 2017 at 22:53:07 UTC, Johan Engelen wrote:
I meant semantically no call.
In the existing language, I think version (or static if) at the
usage and definition points both is as good as you're going to
get.
At t
101 - 174 of 174 matches
Mail list logo