On Sunday, 24 September 2017 at 19:52:52 UTC, bitwise wrote:
On Sunday, 24 September 2017 at 17:11:26 UTC, Haridas wrote:
In the following code, Bar is an element of struct Foo. Is
there a way to avoid a call to ~Bar when ~Foo is getting
executed?
Don't construct it to begin with.
struct B
On Thursday, 23 February 2017 at 09:52:26 UTC, Arun
Chandrasekaran wrote:
I'm trying to write an RAII wrapper on Linux.
I understand struct in D doesn't have default constructor (for
.init reasons).
I don't want to use `scope`.
Is there an elegant way to achieve this in D?
static opCall()
On Thursday, 6 October 2016 at 09:17:08 UTC, pineapple wrote:
On Wednesday, 5 October 2016 at 19:30:01 UTC, Jonathan M Davis
wrote:
Would just like to point out that this is design weirdness on
Phobos' part - the library I've been writing does not have
this problem.
It doesn't even make conce
On Tuesday, 4 October 2016 at 20:05:15 UTC, TheGag96 wrote:
I was writing some code today and ran into this oddity that I'd
never come across before:
import std.algorithm : sort;
int[10] arr = [0, 3, 4, 6, 2, 1, 1, 4, 6, 9];
thing.sort();
This doesn't compile. Obviously the .sort p
On Tuesday, 7 June 2016 at 22:09:58 UTC, Alex Parrill wrote:
Not necessarily, You chased that rabbit quite far! The data
your reading could contain sensitive information only used at
compile time and not meant to embed. For example, the file
could contain login and password to an SQL database t
On Monday, 18 April 2016 at 15:59:11 UTC, Steven Schveighoffer
wrote:
I wonder if it makes a difference for layout. So for example:
struct T
{
struct
{
int x;
ubyte y;
}
ubyte z;
}
If there is padding inserted between y and z.
There isn't. T.init.z.offsetof - T.init.y.
On Tuesday, 29 March 2016 at 10:06:43 UTC, Adrian Matoga wrote:
(...)
Another version that doesn't misbehave if first and second are of
different lengths:
import std.meta : AliasSeq;
template RR(A...) {
template With(B...) {
static if (A.length == 0 || B.length
On Tuesday, 29 March 2016 at 09:33:40 UTC, Voitech wrote:
Hi, i want to join two or more tupples in to one, with mixing
the indexes like roundRobin but in compile time.
unittest{
import std.meta;
alias first=AliasSeq!(int, string,bool);
alias second=AliasSeq!("abc","def","ghi");
alias third=...
On Wednesday, 2 March 2016 at 20:39:57 UTC, Adam D. Ruppe wrote:
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote:
Is it by design or is it a bug?
And, if it is by design, what is the reason for that?
That's by design. It allows you to override names from a
template mixin
On Wednesday, 2 March 2016 at 14:36:59 UTC, Daniel Kozak wrote:
OK maybe this one:
template AddField(T) {
T b;
this(Args...)(T b, auto ref Args args)
{
this.b = b;
this(args);
}
this(int a) {
this.a = a;
}
}
struct Bar {
int a;
mixin Add
On Wednesday, 2 March 2016 at 12:48:47 UTC, Daniel Kozak wrote:
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote:
(...)
You can use string mixins:
template AddField(T) {
enum AddField = T.stringof ~ ` b;
this(Args...)(` ~ T.stringof ~ ` b, auto ref Args args
I can do this:
struct Foo {
int a;
string b;
this(int a) { this.a = a; }
this(Args...)(string b, auto ref Args args) { this.b = b;
this(args); }
}
unittest {
auto foo1 = Foo(5);
auto foo2 = Foo("foo", 15);
}
However, the following code is invalid:
mix
On Tuesday, 1 March 2016 at 08:53:20 UTC, Adrian Matoga wrote:
static if (is(Q : T)) {
Oops, should be T : Q
On Tuesday, 1 March 2016 at 05:05:40 UTC, Jack Stouffer wrote:
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
On Saturday, 30 January 2016 at 00:16:21 UTC, Ali Çehreli wrote:
> https://issues.dlang.org/show_bug.cgi?id=15623
As I noted on the bug report, they are work when moved from
module scope to inside a function (e.g. main()). At least
there's that workaround...
Ali
Thanks a lot! Now I can con
On Friday, 29 January 2016 at 23:44:56 UTC, Basile B. wrote:
Haven't you seen my answer about constraint ?
If you put a constraint on your function template then invalid
instantiations are rejected. I mean... this language feature is
not just ornamental...
What do you think constraints are u
On Friday, 29 January 2016 at 16:36:01 UTC, Steven Schveighoffer
wrote:
On 1/29/16 10:28 AM, Adrian Matoga wrote:
Code:
struct HasFoo { void foo() {} }
struct NoFoo {}
struct CallsFoo(T) {
T t;
void bar() { t.foo(); }
}
static assert(is(CallsFoo!HasFoo));
alias Bar = CallsFoo
Code:
struct HasFoo { void foo() {} }
struct NoFoo {}
struct CallsFoo(T) {
T t;
void bar() { t.foo(); }
}
static assert(is(CallsFoo!HasFoo));
alias Bar = CallsFoo!HasFoo;
static assert(is(CallsFoo!NoFoo)); // (1)
//alias Baz = CallsFoo!NoFoo; // (2)
This compil
On Tuesday, 26 January 2016 at 01:09:50 UTC, Igor wrote:
Is there any examples that shows how to properly allocate an
object of a class type with the new allocators and then release
it when desired?
There's an example of class object allocation in the
std.experimental.allocator docs:
// Dyn
On Monday, 21 December 2015 at 21:32:55 UTC, Jakob Jenkov wrote:
My server uses "poll" for that.
Okay, how does that work? How do I use "poll" in D?
Link?
Code example?
The same as in C [1].
Just change
#include
to
import core.sys.posix.poll;
[1] http://linux.die.net/man/2/poll
On Thursday, 10 December 2015 at 11:36:20 UTC, Suliman wrote:
Vibed have method get for user session
http://vibed.org/api/vibe.http.session/SessionStore
I set user name for session like this:
req.session.set("username", "admin");
But I can't understand how to get user name from it:
abstract s
On Thursday, 1 October 2015 at 08:21:35 UTC, Panke wrote:
I tried it on Windows today using the latest DMD installer, all
default logger and settings.
I get: safe function [...].logImplf cannot call system function
'std.format.formattedWrite!(MsgRange, char,
Result!()).formattedWrite'
How d
On Wednesday, 24 June 2015 at 08:58:10 UTC, Stefan wrote:
On Wednesday, 24 June 2015 at 08:33:29 UTC, Adrian Matoga wrote:
On Wednesday, 24 June 2015 at 08:30:29 UTC, Adrian Matoga
wrote:
input.byLine() yields char[]'s as range elements, while props
is (correctly) indexed by strings
On Wednesday, 24 June 2015 at 08:30:29 UTC, Adrian Matoga wrote:
input.byLine() yields char[]'s as range elements, while props
is (correctly) indexed by strings, i.e. immutable(char)[].
Ooops, more precisely it's because of the second argument of
add() being string, but the solu
On Wednesday, 24 June 2015 at 08:18:52 UTC, Stefan wrote:
I tried to refactor some existing code to use more of the
functional patterns/style (map, filter, reduce, ..).
The task is to read in some sort of a simple property file and
present the result as an associative array.
My attempt is:
imp
On Monday, 22 June 2015 at 06:09:48 UTC, Assembly wrote:
Does D has built-in stack structure (if so, which module?) or
should I implement it myself?
AFAIK there's no built-in, but std.array.Appender could be easily
wrapped in an interface that makes thinking of it as stack easier:
struct Sta
010-10-31 03:13, bearophile wrote:
Adrian Matoga:
I would appreciate if somebody explained to me why this code:
static void function(int a)[] foo = [ function (int a) { } ];
causes the following compile error:
test.d(2): Error: non-constant expression __funcliteral1
When you ask for questions like t
Hello,
I would appreciate if somebody explained to me why this code:
static void function(int a)[] foo = [ function (int a) { } ];
causes the following compile error:
test.d(2): Error: non-constant expression __funcliteral1
(DMD 2.050, Windows7)
TIA
--
Adrian
The following code fails to compile:
double sim(Document doc, string query)
{
alias Tuple!(double, "wij", double, "wiq") Weights;
Document q = Document.fromString(query);
Weights[] wi;
foreach (s; StrFilt(query))
wi ~= Weights(doc.termFreq(s) * i
29 matches
Mail list logo