On Tuesday, 25 October 2022 at 08:14:26 UTC, Per Nordlöw wrote:
On Monday, 24 October 2022 at 20:43:45 UTC, ryuukk_ wrote:
I wish we could do ``version(DebugFast | Release)``
Moreover, I've been using, for instance,
```d
version(D_Coverage) {} else pragma(inline, true);
void foo() {}
```
to
I use
```
pragma(inline, true)
function definition
```
all over my code. And by default, DMD inlines these functions
even in debug builds, which normally is great. I have a custom
dynamic array container and if the indexing operator overload
function wasn't inlined the debug build would have
On Thursday, 20 January 2022 at 01:14:51 UTC, Adam Ruppe wrote:
On Thursday, 20 January 2022 at 00:55:33 UTC, Jack Stouffer
wrote:
static foreach(member; __traits(allMembers,
Manager))
member here is a string, not the member. I prefer to call it
memberName.
Then you __traits(get
On Wednesday, 19 January 2022 at 21:49:12 UTC, Adam D Ruppe wrote:
I never use most of std.traits, they just complicate things.
Bleh idk, I wouldn't bother with it and loop through the
__traits instead.
Unless I'm missing something obvious this has to be a DMD bug,
because this prints nothing
On Wednesday, 19 January 2022 at 20:53:29 UTC, Adam D Ruppe wrote:
So you want to `__traits(child, system, this).run()` and it
should work - the traits child will re-attach a this value.
The error is actually coming from trying to use the result of
getSymbolsByUDA in the right part of the `sta
I'm trying to use getSymbolsByUDA in order to loop over all of
the members in a struct with a certain UDA, and then call a
function on the member. The plan is to use this to avoid looping
over an array of function pointers.
However, the compiler is giving a strange error and the
documentation
On Thursday, 5 August 2021 at 17:02:33 UTC, Tejas wrote:
On Thursday, 5 August 2021 at 16:28:35 UTC, Jack Stouffer wrote:
I need to generate plain C99 .h files from a D module's
extern(C) declarations, so that I can link a DMD generated .o
file with a C code base. Are there any automated tools
I need to generate plain C99 .h files from a D module's extern(C)
declarations, so that I can link a DMD generated .o file with a C
code base. Are there any automated tools which do this?
I know the compiler has C++ header generation, and there's tons
of tools which exist for importing C heade
On Friday, 27 April 2018 at 09:07:31 UTC, Pasqui23 wrote:
I want a library that offers an in-memory data structure,such
that I can write,for example:
cache.insert(key,value,expiry)
and I can retrieve the value with something like
cache[key],unless it has passed expiry seconds.
Can be done?W
On Friday, 15 December 2017 at 02:08:12 UTC, Nicholas Wilson
wrote:
See also
https://github.com/d-gamedev-team/gfm/tree/master/integers/gfm/integers
Thanks
On Thursday, 14 December 2017 at 23:33:34 UTC, Nicholas Wilson
wrote:
On Thursday, 14 December 2017 at 19:47:53 UTC, Jack Stouffer
wrote:
Clang has __int128. Is there anyway to use this with D with
LDC?
Not really as a plain type, although there is effort to get
[u]cent working. I could have
Clang has __int128. Is there anyway to use this with D with LDC?
On Monday, 17 April 2017 at 19:15:06 UTC, Nordlöw wrote:
What's the plan for the recent adding __equal overloads at
https://github.com/dlang/druntime/pull/1808/files
Is it only meant for runtime and phobos to be updated? Or does
user-libraries, such as container libraries, need to be updated
On Friday, 7 April 2017 at 17:06:31 UTC, Russel Winder wrote:
Simple Dub build of a Factorial example using Unit-Threaded for
testing. Works fine with ldc2 breaks with dmd.
Can you post the code your using?
On Friday, 10 March 2017 at 01:13:26 UTC, XavierAP wrote:
On Friday, 10 March 2017 at 00:48:39 UTC, Jack Stouffer wrote:
Don't know the history, but as recently as a week ago Andrei
has argued against such behavior has balkanizing the community.
What behavior? Anyway my question is answered, t
On Friday, 10 March 2017 at 00:42:35 UTC, XavierAP wrote:
On Thursday, 9 March 2017 at 23:55:35 UTC, Adam D. Ruppe wrote:
Just wrap it in a @trusted function.
I knew this answer already of course ;) but I take it as
implying that there is no other way.
Actually I really wonder why std.stdio
On Thursday, 9 March 2017 at 17:48:04 UTC, XavierAP wrote:
Andrei's 2010 book states that the default safety level can be
changed from @system to @safe by means of a -safe command line
switch, in the case of the DMD compiler. Now I've tried it and
it's not recognized.
Was this feature remove
On Wednesday, 23 November 2016 at 21:04:38 UTC, Christian Köstlin
wrote:
std.concurrency contains the register function to associate a
name with
a Tid. This is stored internally in an associative array
namesByTid.
I see no accessors for this. Is there a way to get to the
associated
names of a
On Monday, 20 February 2017 at 20:54:31 UTC, Jack Stouffer wrote:
On Monday, 20 February 2017 at 20:49:43 UTC, Johan Engelen
wrote:
...
Yeah, this is another regression caused by DIP1000.
Christ.
For the record, the current list of regressions caused by DIP1000
https://issues.dlang.org/sho
On Monday, 20 February 2017 at 20:49:43 UTC, Johan Engelen wrote:
...
Yeah, this is another regression caused by DIP1000.
Christ.
On Thursday, 2 February 2017 at 18:18:13 UTC, John Doe wrote:
Let's say you're trying to parse a file format like:
Name
http://example.com
123234
Foo Bar
http://dlang.org
88
with blocks separated by varying amount of blank lines.
-
import std.stdio;
void main(string[] args){
auto
On Saturday, 21 January 2017 at 18:38:22 UTC, Nestor wrote:
Hi friends,
Is there a way to "compile" d code to C, similar to what nim
does?
That would be cool for greater portability.
No, and this is actually a terrible idea. See
https://forum.dlang.org/post/n1vbos$11ov$1...@digitalmars.com
On Monday, 16 January 2017 at 15:32:33 UTC, Dlearner wrote:
Hey, quick question!
I'm messing around with std.random and noticed that you can
change the boundaries parameter to be either open or closed
intervals on either side. By default it is "[)". How do I
change these template parameters
On Sunday, 15 January 2017 at 13:08:52 UTC, drug007 wrote:
Thanks for answer. Looking forward for your PR.
https://github.com/dlang/phobos/pull/5036
On Sunday, 15 January 2017 at 11:47:06 UTC, drug007 wrote:
Is there a way to use Array in @nogc code:
```
import std.container.array : Array;
@nogc:
void main(string[ ] args)
{
Array!int ai;
ai ~= 1;
assert(ai[0] == 1);
}
```
fails:
```
main.d(8): Error: @nogc function 'D main' cannot c
On Sunday, 31 July 2016 at 17:48:48 UTC, BLM768 wrote:
writeln(n1.hashOf == n2.hashOf); // false = BAD!
Ok, yeah that is bad.
Next question: what's the fastest hashing implementation that
will provide the least collisions? Is there a hash implementation
that's perfered for AAs?
On Sunday, 31 July 2016 at 15:30:15 UTC, LaTeigne wrote:
On Sunday, 31 July 2016 at 15:21:01 UTC, Jack Stouffer wrote:
Is it really a problem? What are the pitfalls of defining one
but not the other?
iirc usage in an AA requires both.
But D provides a default toHash for every type if it's no
Is it really a problem? What are the pitfalls of defining one but
not the other?
On Wednesday, 20 July 2016 at 17:31:18 UTC, Ali Çehreli wrote:
making it impossible to access randomly
making it impossible to access randomly __correctly__, unless
you're safely assuming there's only ASCII in your string.
On Wednesday, 6 July 2016 at 16:58:45 UTC, chmike wrote:
In case you missed it
https://blog.twitch.tv/gos-march-to-low-latency-gc-a6fa96f06eb7#.emwja62y1
This should have been posted in General.
On Wednesday, 6 July 2016 at 15:38:00 UTC, Andrea Fontana wrote:
On Wednesday, 6 July 2016 at 14:55:51 UTC, Jonathan M Davis
wrote:
auto st =
SysTime.fromISOExtString("2011-03-02T15:30:00+01:00");
That's perfect. I didn't notice that static method. My fault!
Also, if you need to parse other
On Sunday, 3 July 2016 at 22:00:39 UTC, MMJones wrote:
I like the term var better than auto. Is there a way to alias
auto?
If you're thinking of var as in JS's var, they're not the same
thing.
Even if you could alias it I would advise against doing something
like that; assume your code will
On Sunday, 3 July 2016 at 17:15:32 UTC, Lodovico Giaretta wrote:
To avoid the ~= operator and reallocations of the cache array,
you could impose a max number of cache entries, preallocate the
array and use it as a circular buffer.
Here's a simple ring buffer I use, feel free to take it
struct
On Thursday, 9 June 2016 at 16:13:21 UTC, Jonathan Marler wrote:
I don't see that documentation anywhere on that page.
https://issues.dlang.org/show_bug.cgi?id=16148
On Wednesday, 25 May 2016 at 18:43:05 UTC, Steven Schveighoffer
wrote:
If parse can do it, to should as well.
I think it's a question of how the template constraints are
done. Please file an issue.
Found this: https://issues.dlang.org/show_bug.cgi?id=15800
On Wednesday, 25 May 2016 at 16:53:30 UTC, Steven Schveighoffer
wrote:
to should work wherever parse works (in fact, whenever you call
to!someType(someString), I believe it just forwards to parse).
This is not the case; to doesn't work with ranges:
auto str = "1234567".byCodeUnit;
auto
On Wednesday, 25 May 2016 at 15:34:45 UTC, Steven Schveighoffer
wrote:
parse consumes data from the string as it goes.
I know that, I'm asking why. This disallows the natural range
chaining and forces you to save to a variable before calling
parse even though the function works just as well w
On Tuesday, 24 May 2016 at 05:01:39 UTC, ag0aep6g wrote:
You're missing that `parse`'s parameter is `ref`.
Do you what the rationale behind this is? I just removed the ref
from the floating point from input range overload and it works
fine for strings.
On Tuesday, 24 May 2016 at 05:01:39 UTC, ag0aep6g wrote:
You're missing that `parse`'s parameter is `ref`.
`splitValue.front` is not an lvalue, so it can't be passed in a
ref parameter.
This works:
auto f = splitValue.front;
parse!int(f);
Thanks. DMD desperately needs bette
Consider the following code
-
import std.range;
import std.conv;
import std.utf;
import std.algorithm;
auto test(R)(R s)
{
auto value = s.byCodeUnit;
auto splitValue = value.splitter('.');
parse!int(splitValue.front);
}
void main()
{
test("1.8");
}
-
This fails
On Monday, 23 May 2016 at 08:59:31 UTC, moechofe wrote:
void delegate(string source,string dest) handler;
if(use_symlink) handler = delegate(string s,string d){
symlink(s,d);
}; else handler = delegate(string s,string d){
copy(s,d);
};
Boy that's a confusing way
On Monday, 16 May 2016 at 11:05:40 UTC, Nordlöw wrote:
Does Phobos contain any standard small-size-optimized (SSO)
array that starts with a stack array and union-converts into a
standard builtin D-array when grown beyond the size of the
stack array?
No.
If not has anybody put together one?
On Thursday, 31 March 2016 at 12:49:57 UTC, ag0aep6g wrote:
I get theses timings then:
auto-decoding 642 ms, 969 μs, and 1 hnsec
byCodeUnit 84 ms, 980 μs, and 3 hnsecs
And 643 / 85 ≅ 8.
Ok, so not as bad as 100x, but still not great by any means. I
think I will
On Wednesday, 30 March 2016 at 22:49:24 UTC, ag0aep6g wrote:
When byCodeUnit takes no time at all, isn't 1µs infinite times
slower, instead of 100 times? And I think byCodeUnits's 1µs is
so low that noise is going to mess with any ratios you make.
It's not that it's taking no time at all, it's
On Wednesday, 30 March 2016 at 05:16:04 UTC, H. S. Teoh wrote:
If we didn't have autodecoding, would be a simple matter of
searching for sentinel substrings. This also indicates that
most of the work done by autodecoding is unnecessary -- it's
wasted work since most of the string data is treat
On Tuesday, 29 March 2016 at 23:42:07 UTC, H. S. Teoh wrote:
Believe it or not, it was only last year (IIRC, maybe the year
before) that Walter "discovered" that Phobos does autodecoding,
and got pretty upset over it. If even Walter wasn't aware of
this for that long...
The link (I think thi
On Tuesday, 29 March 2016 at 23:15:26 UTC, Basile B. wrote:
I've seen you so many time as a reviewer on dlang that I belive
this Q is a joke.
Even if obviously nobody can know everything...
https://www.youtube.com/watch?v=l97MxTx0nzs
seriously you didn't know that auto decoding is on and that
On Monday, 28 March 2016 at 23:07:22 UTC, Jonathan M Davis wrote:
...
Thanks for the detailed responses. I think I'll compile this info
and put it in a blog post so people can just point to it when
someone else is confused.
On Monday, 28 March 2016 at 22:43:26 UTC, Anon wrote:
On Monday, 28 March 2016 at 22:34:31 UTC, Jack Stouffer wrote:
void main () {
import std.range.primitives;
char[] val = ['1', '0', 'h', '3', '6', 'm', '2', '8', 's'];
pragma(msg, ElementEncodingType!(typeof(val)));
pragma(msg,
void main () {
import std.range.primitives;
char[] val = ['1', '0', 'h', '3', '6', 'm', '2', '8', 's'];
pragma(msg, ElementEncodingType!(typeof(val)));
pragma(msg, typeof(val.front));
}
prints
char
dchar
Why?
Is there any way in dub to specify that a module should only be
linked and compiled for DMD and not for LDC?
I am using the Economic Modeling containers library, and because
it uses std.experimental.allocator, it can't be used with LDC
through dub. I have coded in such a way with static if's t
I want to have one of the parameters on a function be optional.
The problem is, is that it's a AA and D does not seem to support
empty AA literals. Observe:
string func(int a, int[int] b = []) {
return "mem1";
}
void main() {
func(1);
}
$ dmd test
test.d(8): Error: cannot implicitly c
On Tuesday, 1 March 2016 at 08:53:20 UTC, Adrian Matoga wrote:
struct Foo
{
string foo = "dog";
int bar = 42;
int baz = 31337;
}
void set(P, T)(ref P p, string name, auto ref T value)
{
foreach (mem; __traits(allMembers, P)) {
static if (is(typeof(
In Python, I can do this:
my_obj = Obj()
string_from_func = func()
setattr(my_obj, string_from_func, 100)
Say func() returns "member1" or "member2", the setattr would then
set either one of those to 100.
Is there any equivalent in D?
On Sunday, 21 February 2016 at 14:32:15 UTC, dextorious wrote:
Now, seeing as how my experience writing D is literally a few
hours, is there anything I did blatantly wrong? Did I miss any
optimizations? Most importantly, can the elegant operator
chaining style be generally made as fast as the e
On Monday, 21 December 2015 at 23:59:07 UTC, Jay Norwood wrote:
I'm trying to learn ndslice. It puzzles me why t3 compiles ok,
but t4 causes a compiler error in the example below. Should I
be able to slice a struct member that is an array?
import std.stdio;
import std.experimental.ndslice;
i
On Tuesday, 22 December 2015 at 00:21:16 UTC, Jay Norwood wrote:
import std.experimental.ndslice.iteration: transposed;
I don't use visualD so I can't help you there, but I wanted to
point out that this import is unnecessary.
On Wednesday, 16 December 2015 at 21:40:44 UTC, anonymous wrote:
The `.save` primitive of forward ranges must return the very
same type that the range has. But your
ReferenceBidirectionalRange!T.save returns a
ReferenceForwardRange!T, because it's inherited. That makes
isForwardRange!(Referenc
On Wednesday, 16 December 2015 at 20:43:02 UTC, Jack Stouffer
wrote:
unittest
{
static assert(isInputRange!(ReferenceInputRange!int)); //
works
static assert(isForwardRange!(ReferenceForwardRange!int));
// works
static
assert(isBidirectionalRange!(ReferenceBidirectionalRange!int));
I'm trying to add a ReferenceBidirectionalRange range type to
std.internal.test.dummyrange so I can test some range code I'm
writing, but I've hit a wall and I'm not sure why. For some
reason, the isBidirectionalRange check fails even though back and
popBack are present. Any help here would be
On Wednesday, 9 September 2015 at 01:35:26 UTC, Sebastiaan Koppe
wrote:
Thanks for your advice. But that is not what I asked for.
The question was, why doesn't this work anymore with the latest
(2.068.0 and 2.068.1) compiler:
```
auto ls =
File("../languages.json","r").byLineCopy().joiner.p
On Wednesday, 9 September 2015 at 01:35:26 UTC, Sebastiaan Koppe
wrote:
Thanks for your advice. But that is not what I asked for.
The question was, why doesn't this work anymore with the latest
(2.068.0 and 2.068.1) compiler:
```
auto ls =
File("../languages.json","r").byLineCopy().joiner.p
On Saturday, 26 September 2015 at 17:08:00 UTC, Nordlöw wrote:
Why is the following code not pure:
float x = 3.14;
import std.conv : to;
auto y = x.to!string;
???
Is there a reason for it not being pure? If not, this is a
serious problem as this is such a fundamental function.
On Monday, 21 September 2015 at 20:39:55 UTC, Jesse Phillips
wrote:
A static array has a constant length, so it is not possible to
popFront on a static array.
Making a dynamic array from it is easy, just slice it with []:
pragma(msg, isInputRange!(typeof(a[])));
pragma(msg, isForward
import std.range;
void main() {
int[6] a = [1, 2, 3, 4, 5, 6];
pragma(msg, isInputRange!(typeof(a)));
pragma(msg, isForwardRange!(typeof(a)));
pragma(msg, isRandomAccessRange!(typeof(a)));
}
$ dmd -run test.d
false
false
false
That's ridiculous. Do I have to wrap my static arra
On Monday, 21 September 2015 at 12:47:39 UTC, ponce wrote:
3. What is the minimum OS X version required by programs
created with LDC?
Tiger x86 version, I believe.
On Friday, 18 September 2015 at 02:29:55 UTC, Jack Stouffer wrote:
On Friday, 18 September 2015 at 02:24:44 UTC, Adam D. Ruppe
wrote:
Works for me. What version are you using? Might be the old one
wasn't actually marked nogc yet.
I'm using the git head, must be a regression.
Well apparently
On Friday, 18 September 2015 at 02:24:44 UTC, Adam D. Ruppe wrote:
Works for me. What version are you using? Might be the old one
wasn't actually marked nogc yet.
I'm using the git head, must be a regression.
The docs explicitly say that SwapStrategy.unstable is
non-allocating, but this code (which is for finding the
statistical mode of a range) will fail to compile.
auto mode(alias pred = "a == b", R)(R r) @nogc
if (is(ElementType!R : real) &&
isInputRange!R &&
!isInfinite!R)
{
pragma(msg, is(int[] : long[]));
false
Why?
On Sunday, 30 August 2015 at 02:42:30 UTC, Spacen Jasset wrote:
immutable(ElementEncodingType!(ElementType!Range))[]
buildPath(Range)(Range segments) if (isInputRange!Range &&
isSomeString!(ElementType!Range));
pure nothrow @safe immutable(C)[] buildPath(C)(const(C)[][]
paths...) if (isSomeChar
For reference:
OSX 10.10.5
GDB 7.9.1 (non apple; from homebrew)
yes, it is code signed
Compiling with dub: "dflags": ["-gc", "-gs"]
I would also like to preface this post by saying that everything
works fine in GDB on linux.
When finding that a bug in my program was a null poin
On Friday, 14 August 2015 at 00:06:33 UTC, Adam D. Ruppe wrote:
On Thursday, 13 August 2015 at 23:48:08 UTC, Jack Stouffer
wrote:
In my code, the list can have 20-30 different types of classes
in it all inheriting from the same interface, and it doesn't
make sense for all of those classes to im
On Thursday, 13 August 2015 at 22:49:15 UTC, Adam D. Ruppe wrote:
On Thursday, 13 August 2015 at 21:42:54 UTC, Jack Stouffer
wrote:
dynamically calling different methods on each object in the
list based on its type.
The cleanest OO way of doing that is to put the methods you
need in the inter
On Thursday, 13 August 2015 at 22:20:35 UTC, Justin Whear wrote:
foreach (item; parent_list) {
if (auto asA = cast(A)item) {
asA.method();
} else if (auto asB = cast(B)item) {
asB.method2();
}
}
On Thursday, 13 August 2015 at 22:20:35 UTC, Justin Whear wrote:
Thanks Justin and ru
On Thursday, 13 August 2015 at 20:28:33 UTC, Adam D. Ruppe wrote:
On Thursday, 13 August 2015 at 20:23:56 UTC, Jack Stouffer
wrote:
As far as I can tell, there is no way to know the actual type
of each of the objects in the list to be able to print:
Cast it to Object first, then do the typeid
Given:
interface Parent {
void method();
}
class A : Parent {
void method() {}
this() {}
}
class B : Parent {
void method() {}
void method2() {}
this() {}
}
void main() {
import std.stdio;
Parent[] parent_l
On Monday, 27 July 2015 at 20:12:10 UTC, John Colvin wrote:
Yes, but then core.sync.semaphore doesn't support being shared,
so...
Ok, so I made the code run by using __gshared instead of shared.
It seems really odd that a semaphore object doesn't support being
shared, this that a bug?
Here
Hi,
I am currently working through a book on the fundamentals of
computer concurrency and I wanted to do all of the exercises in
D. But I ran into a problem when I tried to have a global
semaphore:
/usr/local/Cellar/dmd/2.067.1/include/d2/core/sync/semaphore.di(35): Error:
constructor core.
On Friday, 26 June 2015 at 19:40:41 UTC, rsw0x wrote:
On Friday, 26 June 2015 at 19:26:57 UTC, Jack Stouffer wrote:
Thanks for the reply! I understand the reasoning now.
On Friday, 26 June 2015 at 18:46:03 UTC, Adam D. Ruppe wrote:
2) interfaces have an associated runtime cost, which ranges
wa
Thanks for the reply! I understand the reasoning now.
On Friday, 26 June 2015 at 18:46:03 UTC, Adam D. Ruppe wrote:
2) interfaces have an associated runtime cost, which ranges
wanted to avoid. They come with hidden function pointers and if
you actually use it through them, you can get a perform
I have been learning D over the past three weeks and I came to
the chapter in "Programming in D" on Ranges. And I am a little
confused on the choice to make Ranges based on the methods you
have in the struct, but not use a interface. With all of the
isInputRange!R you have to write everywhere,
82 matches
Mail list logo