On Wed, 01 Feb 2012 01:14:38 +0100, Nicolas Silva nical.si...@gmail.com
wrote:
Oh, my bad, sorry, when I tried the code i showed in the other mail, I
had forgotten the parenthesis on the call to refA() (like if it was an
attribute).
Once fixed it works for me.
f1.refA() = 24; //ok
f1.refA =
On Sat, 04 Feb 2012 15:04:50 +0100, Vidar Wahlberg cani...@exent.net
wrote:
This code does not compile:
Bar.d:6: Error: function expected before (), not module Struct of type
void
Bar.d:6: Error: constructor Foo.Foo.this (Struct s) is not callable
using argument types (_error_)
Why is
On Sat, 04 Feb 2012 18:18:22 +0100, F i L witte2...@gmail.com wrote:
Why/where should I use contracts vs debug statements? Is it completely
arbitrary? If so, I wonder if contracts syntax is even needed:
int foo(int bar)
in
{
assert(bar != 0);
}
body
{
On Sat, 04 Feb 2012 12:38:30 +0100, Vidar Wahlberg cani...@exent.net
wrote:
Good day.
I know inheritance is a misleading word as there's no such thing when
it comes to structs, but I couldn't think of a better description for
this problem:
Let's say I got a struct for a location on a
On Sat, 04 Feb 2012 13:55:55 +0100, Vidar Wahlberg cani...@exent.net
wrote:
On 2012-02-04 13:06, Simen Kjærås wrote:
It seems that what you want is alias this:
Thank you both, that's exactly what I needed.
Leeching a bit more on the thread:
Going back to the method:
int somethingNifty
On Sun, 05 Feb 2012 11:58:40 +0100, Vidar Wahlberg cani...@exent.net
wrote:
Also, is this really ambiguous? Are there any cases where you can have a
module name followed by a parentheses, i.e. module(?
Not that I know.
I cannot seem to recreate this error message. Which version of the
On Tue, 14 Feb 2012 16:39:37 +0100, Joshua Reusch yos...@arkandos.de
wrote:
Hello,
why does this assertion fail:
assert(float.nan == float.nan);
there is the std.math.isNaN function which works correctly, but why can
I not just use the comparison ?
Thanks, Joshua
My favorite
On Wed, 22 Feb 2012 23:16:41 +0100, Blake Anderton rbander...@gmail.com
wrote:
Why doesn't this work? I'm assuming I'm not fully understanding how
alias this interacts with ranges (i.e. the range isn't being reset
after count is finished with it), but I'm not sure how to fix this
either:
On Wed, 07 Mar 2012 01:41:22 +0100, Jonathan M Davis jmdavisp...@gmx.com
wrote:
It really takes very little for something to be impure, and optimizations
often do it, because they end up using low-level constructs which aren't
pure
- some of which could be but aren't and others which
On Thu, 08 Mar 2012 00:21:36 +0100, Comrad
comrad.karlov...@googlemail.com wrote:
1 struct A
2 {
3 double[2] _x;
4 }
5
6 @property ref double y(ref A a) {return a._x[1];}
7
8 void main()
9 {
10 A a1;
11 a1.y=2.;
12 }
dmd test.d gives me:
Error: no
On Mon, 12 Mar 2012 19:20:07 +0100, Andrej Mitrovic
andrej.mitrov...@gmail.com wrote:
On 3/12/12, Ali Çehreli acehr...@yahoo.com wrote:
Let's please also see the exact error message. an error message that
seems to indicate that DMD is looking for a global identifier is not
clear to mortals
On Thu, 15 Mar 2012 14:34:19 +0100, Jay Norwood j...@prismnet.com wrote:
I also found mention of a c++ compiler that someone states can compile
c++ and output C. Kind of weird, but maybe compiling D to expanded D
would not be such a stretch.
That's how early C++ compilers worked.
On Sat, 17 Mar 2012 17:27:21 +0100, Tongzhou Li zhangsong...@hotmail.com
wrote:
I'm learning D, and trying to convert My C++ code into D:
http://pastebin.com/eCz9DdZ3
I wrote: auto stack = SList!(Tuple!(double, char))();
But I got an error
Error: function
On Sun, 18 Mar 2012 08:34:19 +0100, Tongzhou Li zhangsong...@hotmail.com
wrote:
On Sunday, 18 March 2012 at 06:15:16 UTC, Ali Çehreli wrote:
Every template instantiation of a set of template parameters becomes a
distinct type than any other set of template parameters.
In other words,
On Sun, 25 Mar 2012 22:45:57 +0200, bls bizp...@orange.fr wrote:
How do I call opDispatch(string name, E...)(E elements) ?
What I want to archive is to call f.i. fm.list with an arbitrary number
of arguments without using
fm.list(1, abc, 4L, 3.33);
Instead I would prefer
fm.list = (1, abc,
On Thu, 29 Mar 2012 22:15:41 +0200, simendsjo simend...@gmail.com wrote:
If you look at the struct, it uses the type U in, among others, the
union.
The only place I could see U referenced is in the first static if, but I
cannot recreate this behavior:
void main() {
static if(is(int X
On Fri, 30 Mar 2012 15:03:49 +0200, simendsjo simend...@gmail.com wrote:
On Fri, 30 Mar 2012 01:09:06 +0200, Simen Kjærås
simen.kja...@gmail.com wrote:
On Thu, 29 Mar 2012 22:15:41 +0200, simendsjo simend...@gmail.com
wrote:
If you look at the struct, it uses the type U in, among others
On Fri, 30 Mar 2012 19:52:50 +0200, simendsjo simend...@gmail.com wrote:
On Fri, 30 Mar 2012 17:13:25 +0200, Simen Kjærås
simen.kja...@gmail.com wrote:
Indeed. The thing is - U is basically *set* by the isExpression. It says
'yes, there is such a U, so I'll add it to the local scope
On Sat, 31 Mar 2012 15:20:42 +0200, simendsjo simend...@gmail.com wrote:
Seems __traits doesn't have a __traits(getMemberType, T, name).
Now I'm doing the following:
T t; // instance to use in getMember
alias typeof( __traits(getMember, t, name) ) MemberType;
Is this the only way to get the
On Wed, 04 Apr 2012 12:06:33 +0200, Jacob Carlborg d...@me.com wrote:
On 2012-04-04 04:11, Jonathan M Davis wrote:
foreach(i; 0 .. 5)
is more efficient only because it has _nothing_ to do with arrays.
Generalizing
the syntax wouldn't help at all, and if it were generalized, it would
On Wed, 04 Apr 2012 14:21:01 +0200, Jacob Carlborg d...@me.com wrote:
On 2012-04-04 14:16, Simen Kjærås wrote:
And what do we do with 3..$?
Hmm, that's a good point. The best I can think of for now is to
translate that to:
range(3, size_t.max)
Or something like:
struct range
On Wed, 04 Apr 2012 14:16:54 +0200, Simen Kjærås simen.kja...@gmail.com
wrote:
On Wed, 04 Apr 2012 12:06:33 +0200, Jacob Carlborg d...@me.com wrote:
On 2012-04-04 04:11, Jonathan M Davis wrote:
foreach(i; 0 .. 5)
is more efficient only because it has _nothing_ to do with arrays
On Wed, 04 Apr 2012 15:29:58 +0200, Jacob Carlborg d...@me.com wrote:
On 2012-04-04 15:01, Simen Kjærås wrote:
Actually, I've thought a little about this. And apart from the tiny
idiosyncrasy of $, a..b as a more regular type can bring some
interesting enhancements to the language.
Consider
On Thu, 28 Feb 2013 16:22:49 +0100, D-ratiseur
thisadressdoesntex...@nowhere.fr wrote:
Hello, Is it possible for an ASM function to be inlined in D?
Nope.
--
Simen
On Sat, 02 Mar 2013 11:02:08 +0100, simendsjo simend...@gmail.com wrote:
invariant is called when a method enters. This creates problems if the
constructor calls a setter:
import std.exception;
struct S {
private int _i;
public:
this(int i) {
this.i = i;
}
@property void
On Wed, 06 Mar 2013 22:06:42 +0100, ixid nuacco...@gmail.com wrote:
The underscores in values such as 1_000_000 aid readability but DMD
doesn't see anything wrong with any placement of underscores as long as
they follow a number. Is there any reason to allow uses like 1_00_000,
which are
On Sun, 07 Apr 2013 01:19:54 +0200, Timothee Cour
thelastmamm...@gmail.com wrote:
[Good Stuff™]
Like bearophile said, this has been discussed numerous times before. A DIP
really should be written. (Perhaps you would do the honors?)
Two previous posts on the topic:
On 17.11.2013 21:29, Jay Norwood wrote:
I'm reading a SystemC lecture which describes use of operator
overloading of comma in their syntax to support concatenation.
So, for example, they support the data operations below
sc_uint4 a, b, d, e;
sc_unit8 c;
c = (a, b);
(d, e) = c;
As I understand
On 2013-12-01 04:46, Craig Dillabaugh wrote:
Since questions about calling C from D seem to be popular today, I
thought I would throw this one out there.
I am trying to call a C function which takes as parameters several
arrays of doubles. It is valid to have some arrays passed a NULL
pointers
On 09.12.2013 23:03, seany wrote:
yet another array question :
I have defined :
alias string[] surrealNum_segments;
alias string[string] surrealNum_segments_withID;
surrealNum_segments_withID BAR;
Is there a built in function FOO, such that i could also write:
FOO(surrealNum_segments) BAR;
I'm trying to create a function that repeats a function call N times.
The exact use case is generating an N-dimensional tuple:
import std.typetuple;
import std.typecons;
template Repeat(size_t n, T...) {
static if (n == 1) {
alias Repeat = T;
} else static if (n) {
On 2014-04-02 20:48, monarch_dodra wrote:
On Wednesday, 2 April 2014 at 19:54:38 UTC, monarch_dodra wrote:
On Wednesday, 2 April 2014 at 19:02:29 UTC, Simen Kjærås wrote:
Better ideas, please?
--
Simen
I only skimmed through your post, but have you tried taking a look at
adjoin? Preferably
I'm creating a Checked!T struct for integral values. The version attached
works
for the most part, but some parts confuse me, namely that the following
operations do not set the overflow flag:
uint.max + 1
ulong.max + 1
int.min - 1
uint.min - 1
long.min - 1
ulong.min - 1
uint.max 1
long.max
On Thu, 10 Nov 2011 18:56:37 +0100, Steven Schveighoffer
schvei...@yahoo.com wrote:
On Thu, 10 Nov 2011 12:24:30 -0500, Simen Kjærås
simen.kja...@gmail.com wrote:
I'm creating a Checked!T struct for integral values. The version
attached
works
for the most part, but some parts confuse me
On Fri, 11 Nov 2011 19:19:03 +0100, Simon s.d.hamm...@gmail.com wrote:
On 10/11/2011 18:46, Simen Kjærås wrote:
On Thu, 10 Nov 2011 18:56:37 +0100, Steven Schveighoffer
schvei...@yahoo.com wrote:
On Thu, 10 Nov 2011 12:24:30 -0500, Simen Kjærås
simen.kja...@gmail.com wrote:
I'm creating
On Wed, 16 Nov 2011 21:00:16 +0100, Steven Schveighoffer
schvei...@yahoo.com wrote:
On Wed, 16 Nov 2011 14:26:57 -0500, Timon Gehr timon.g...@gmx.ch wrote:
On 11/16/2011 02:22 PM, Steven Schveighoffer wrote:
On Tue, 15 Nov 2011 13:45:02 -0500, Timon Gehr timon.g...@gmx.ch
wrote:
Note
On Fri, 25 Nov 2011 10:34:12 +0100, Christophe
trav...@phare.normalesup.org wrote:
Andrej Mitrovic , dans le message (digitalmars.D.learn:30764), a écrit :
import core.thread;
import std.stdio;
struct Foo
{
int field;
void test()
{
writeln(field: , field);
}
}
void
On Sat, 26 Nov 2011 17:22:58 +0100, Kagamin s...@here.lot wrote:
Tried to create a stronger version of size_t which will not interoperate
with int and long
http://codepad.org/47OB3nJi
But for some reason can't compare struct to int using opEquals and
opCmp. How to fix it? And should it?
On Thu, 01 Dec 2011 18:50:48 +0100, Adam a...@anizi.com wrote:
Ok, starting to feel like I'm missing something obvious...
The abstract keyword in the language reference states:
Functions declared as abstract can still have function bodies. This
is so that even though they must be overridden,
On Thu, 01 Dec 2011 19:19:49 +0100, Adam a...@anizi.com wrote:
I can see the case for a grand-child, but if a class does not provide
a definition for an abstract member, is that class not, by
association, abstract?
Of course. That's what I said. Or meant, at any rate.
Classes become
On Sat, 03 Dec 2011 10:26:09 +0100, David Nadlinger s...@klickverbot.at
wrote:
On 12/3/11 1:43 AM, simendsjo wrote:
On 02.12.2011 23:28, Jonathan M Davis wrote:
There's also been at least a couple of cases where people
have worked on unit libraries and discussed them in the main
newsgroup,
On Fri, 16 Dec 2011 14:00:11 +0100, Joshua Reusch yos...@arkandos.de
wrote:
Hello,
is there a way to say something like
---
int a, b;
AliasTuple!(a, b) = tuple(4,5);
assert(a == 4 b == 5);
---
without having to write an own AliasTuple template ? I want to use it
for functions returning
On Fri, 16 Dec 2011 14:00:11 +0100, Joshua Reusch yos...@arkandos.de
wrote:
Hello,
is there a way to say something like
---
int a, b;
AliasTuple!(a, b) = tuple(4,5);
assert(a == 4 b == 5);
---
without having to write an own AliasTuple template ? I want to use it
for functions returning
On Mon, 19 Dec 2011 17:17:43 +0100, clk c...@clksoft.com wrote:
Hello,
I'm new to this mailing list. I'm trying to learn D to eventually use
it in production code.
I'm a little bit intimidated by the fact that the topics in the d-learn
list look rather advanced to a newbie like me.
I have 3
On Mon, 02 Jan 2012 15:02:30 +0100, Joshua Reusch yos...@arkandos.de
wrote:
Is it possible to create a template turning any value into a lvalue?
This would be helpful if a function expects a reference but you dont
need the result of the change:
///decode(S)(in S str, ref size_t index);
On Tue, 03 Jan 2012 16:35:29 +0100, Heywood Floyd soul...@gmail.com
wrote:
Hello!
I have some structs
struct A { int a; }
struct B { int b, c; }
and I'd like to be able to enumerate them (preferrably as integers)
based on their names. I've no idea how this would look, but
some
On Sun, 08 Jan 2012 18:54:13 +0100, Ben Davis ent...@cantab.net wrote:
Hi,
Is there a reason 'ref' is disallowed for local variables? I want to
write something like:
MapTile[] map; // It's a struct
ref MapTile tile=map[y*w+x];
tile.id=something;
tile.isWall=true;
My actual case is more
On Mon, 09 Jan 2012 22:33:28 +0100, Juan Campanas joh...@bells.com wrote:
On Monday, 9 January 2012 at 21:14:05 UTC, Robert Clipsham wrote:
Are exceptions in safe D possible? I started trying to make my code
@safe (there's no reason why it can't be as far as I'm aware), but I
hit the
On Fri, 13 Jan 2012 22:21:52 +0100, Philippe Sigaud
philippe.sig...@gmail.com wrote:
There is an 'Examples' section where I show what can be done with
templates and there I
'borrowed' some code posted here, with attribution. I already exchanged
with Andrej
Mitrovic (thanks!), but also took
On Tue, 17 Jan 2012 00:10:41 +0100, Philippe Sigaud
philippe.sig...@gmail.com wrote:
On Mon, Jan 16, 2012 at 17:36, Simen Kjærås simen.kja...@gmail.com
wrote:
The extended enum example does not compile, because you've removed the
unittest{} block around the the tests. I'd say the code
On Mon, 30 Jan 2012 13:58:38 +0100, sami s...@hotmail.com wrote:
when i do that auto x = [1, ha];
i have an error Error: incompatible types for ((1) ? (hgh)): 'int' and
'string'
if there any method to combine different data type?
You might want to check out std.variant. It's Variant type
On Tue, 31 Jan 2012 16:42:52 +0100, Zachary Lund ad...@computerquip.com
wrote:
On Tuesday, 31 January 2012 at 15:19:00 UTC, Trass3r wrote:
However, I cannot, by default, scope my custom allocations.
Any ideas?
std.typecons.scoped
I looked into this and I'm unsure of its exact use. It
On Wednesday, 9 May 2018 at 10:16:22 UTC, Melvin wrote:
class SomeNode : GodotScript!Node
{
@Signal void testSignal(float a, long b);
// The declaration above would trigger the generation of
this line
void testSignal(float a, long b) {
owner.emitSignal("testSignal", a, b); }
On Friday, 27 April 2018 at 13:27:45 UTC, Timoses wrote:
Bumped across another problem : /
```
import std.stdio;
enum menum { A, B, C }
void main()
{
foo(menum.A);
}
void foo(menum e)
{
writeln(instantiateWith!Temp(e));
}
auto instantiateWith(alias Fn, T)(T x)
if (is(T == enum))
On Friday, 4 May 2018 at 13:02:08 UTC, NewUser wrote:
How can I use the following c structure from d.
struct Item
{
int id;
};
struct Group
{
int i;
int item_count;
struct Item items[];
};
tried defining items[] as both "Item[] items" and "Item* items"
in d, it compiles okay but
On Saturday, 19 May 2018 at 18:44:42 UTC, IntegratedDimensions
wrote:
On Saturday, 19 May 2018 at 18:19:35 UTC, IntegratedDimensions
wrote:
Is there any way to create an int24 type that behaves just
like any other built in type without having to reimplement
everything?
In fact, what I'd like
On Thursday, 24 May 2018 at 07:47:54 UTC, Andrea Fontana wrote:
Is this a bug or am I missing something?
https://run.dlang.io/is/OGHJYX
Andrea
This line:
mixin("alias tmp = " ~ s ~ ";");
There's no mention of Symbol in there. If you change it to this:
mixin("alias tmp =
On Tuesday, 12 June 2018 at 11:04:40 UTC, bauss wrote:
[snip]
void test(T)()
{
pragma(msg, (getBar!T).baz());
pragma(msg, (getBar!T).helloworld());
import std.stdio;
mixin((getBar!T).baz());
mixin((getBar!T).helloworld());
}
[snip]
Is there a way to avoid having to write
On Friday, 15 June 2018 at 10:53:35 UTC, uknys wrote:
On Friday, 15 June 2018 at 07:27:22 UTC, Simen Kjærås wrote:
[snip]
Yeah I saw that Algebraic doesn't work at compile time, then I
thought of using an Interface with one function (execute()) and
making Hello and Toto as classes
On Thursday, 14 June 2018 at 19:15:38 UTC, uknys wrote:
Hello,
I wanted to know if such code was possible :
alias Operation = Algebraic!(/* All type that implements X UDA
*/)
struct X
{
int opcode;
Operation h;
}
@X(0x01, Hello(3))
@X(0x02, Hello(4))
struct Hello
{
int Hello;
}
On Tuesday, 29 May 2018 at 21:19:01 UTC, DigitalDesigns wrote:
https://dpaste.dzfl.pl/67691db19ce8
Simplified:
interface A
{
import std.meta : AliasSeq;
alias a = AliasSeq!(__traits(getMember, B, "foo"));
void foo();
}
class B : A
{
void foo() { }
}
It seems the compiler is
On Wednesday, 30 May 2018 at 09:58:16 UTC, biocyberman wrote:
How do I add logging for this struct?
https://run.dlang.io/is/9N6N4o
If not possible, what's the alternative?
This line:
writeln("got num: %s, of type: %s", num, typeof(num));
Gives this error message:
onlineapp.d(7):
On Monday, 28 May 2018 at 20:13:49 UTC, DigitalDesigns wrote:
I do not think this is a problem in D. Infinite recursion can
always be terminated with appropriate means.
1. Use attributes. methods in class A should be marked as being
for the interface. When added to the interface they will not
On Sunday, 3 June 2018 at 14:57:37 UTC, DigitalDesigns wrote:
On Sunday, 3 June 2018 at 09:52:01 UTC, Malte wrote:
You might want to have a look at
https://wiki.dlang.org/Dynamic_typing
This sounds very similar to what you are doing. I never really
looked into it, because I prefer to know
On Tuesday, 5 June 2018 at 09:36:22 UTC, Gopan wrote:
void main()
{
immutable n = __ctfe ? 1 : 2;
int[n] a;
assert(a.length == n); // fails, wat
}
That's gotta be a bug - that should give a 'variable n cannot be
read at compile time' error. The fact that n is immutable
shouldn't
On Wednesday, 6 June 2018 at 06:25:49 UTC, DaggetJones wrote:
Hi, I'm wondering how I should approach supplying
functions/delegates around in D. I have option of using classes
where the function exists inside the class and to provide
different functionality different classes are created.
On Sunday, 27 May 2018 at 17:42:15 UTC, Sobaya wrote:
I'd like to get symbols that have an UDA.
But when the member is private, it is not obtained.
And I found a comment saying "Filtering inaccessible members"
in the source.
Why is it necessary to filter out private members?
Since the
On Monday, 28 May 2018 at 09:59:50 UTC, DigitalDesigns wrote:
Implementing interfaces can be a pain but are necessary.
I like to use abstract classes and provide a base
implementation. It would be cool if I could use D's awesome
meta features to extract the interface from the abstract class
On Saturday, 2 June 2018 at 22:09:49 UTC, Neia Neutuladh wrote:
On Saturday, 2 June 2018 at 21:44:39 UTC, greatsam4sure wrote:
Sorry for the typo
is it possible to define infix function in D
3.min(5)// 3: where min is a function, works in D
3 min 5 // does not work.
thanks in advance
This
On Sunday, 1 July 2018 at 09:46:55 UTC, Timoses wrote:
Would be nice if std.meta.ApplyLeft did the job here.. Is there
no way of achieving that?
[snip]
Would have to find a way to determine whether Template would
resolve to a function or not. Can't find anything in Traits[1]
or std.traits[2].
On Sunday, 1 July 2018 at 22:04:05 UTC, Robert M. Münch wrote:
On 2018-07-01 09:05:56 +, Robert M. Münch said:
This one look nasty...
And it was... the problem was, that I kept D allocated pointers
in C code without informing the GC that the memory can't be
collected nor moved.
On Monday, 25 June 2018 at 09:36:45 UTC, Martin Tschierschke
wrote:
I am not sure that I understood it right, but there is a way to
detect the status of a parameter:
My question was different, but I wished to get a ctRegex! or
regex used depending on the expression:
import
On Saturday, 30 June 2018 at 21:11:54 UTC, Anonymouse wrote:
I have a template that I want to provide easy aliases for,
where the aliases includes (partially applies?) a template
parameter.
void fooImpl(char token, T)(const T line)
{
// ...
}
alias quoteFoo(T) = fooImpl!('"', T);
alias
On Thursday, 26 April 2018 at 16:10:16 UTC, Timoses wrote:
Is it possible to use a template to place the "static foreach"
looping to find the correct enum value into? Like I am trying
in the initial "draft" GetMenum?
As the compiler says, the value of `e` is not known at
compile-time. In
On Thursday, 11 January 2018 at 12:32:54 UTC, Per Nordlöw wrote:
Is this an ok implementation:
enum bool isNogc(alias fun) = (isCallable!fun &&
(functionAttributes!fun &
FunctionAttribute.nogc));
@safe pure nothrow @nogc unittest
{
On Thursday, 11 January 2018 at 11:21:08 UTC, tipdbmp wrote:
string push_stuff(char[] buf, int x) {
if (x == 1) {
buf ~= 'A';
buf ~= 'B';
buf ~= 'C';
return cast(string) buf[0 .. 3];
}
else {
buf ~= 'A';
buf ~= 'B';
return
On Thursday, 11 January 2018 at 08:59:01 UTC, Chirs Forest wrote:
I'm using std.variant.Variant to hold a value of unknown type
(not a string, could be a numeric type or a container holding
multiple numeric types). I'm trying to retrieve this value with
.get!T but I need the type to do that...
On Thursday, 4 January 2018 at 15:50:35 UTC, Vino wrote:
Hi All,
Request your help, on how o find the single type of a tuple
return type function, eg,
auto Fn (){
Array!string a;
Array!int b;
Array!ulong c;
return tuple(a, b, c);
}
if we use "ReturnType!Fn" it gives us the output as
On Saturday, 6 January 2018 at 23:25:58 UTC, Ali Çehreli wrote:
Is 'static foreach' sufficient for all needs or is there any
value for regular foreach over compile-time sequences?
There is, as far as I've seen, there's nothing old
foreach-over-tuple can do that new-style static foreach can't.
On Monday, 15 January 2018 at 13:55:57 UTC, Nordlöw wrote:
Why do I get errors like
template instance remove!((_) => _ == 1) cannot use local
'__lambda5' as parameter to non-global template remove()(in K
key)
for
x.remove!(_ => _ == 1);
but not for
x.remove!"a == 11";
?
How are
On Monday, 15 January 2018 at 15:24:50 UTC, Marc wrote:
I just thought that filter() could be evaluated at compile time
too, as others function that I've used so far. Sometimes I
don't know if a native function can be evaluated at compile
time until I do enum x = func();
Yeah, it takes some
On Friday, 19 January 2018 at 11:02:01 UTC, tipdbmp wrote:
The following seems to work in C++, but errors in D, why is
that?
int foo(int* num) {
{
static int x = 10;
x += 1;
*num += x;
}
{
static int x = 20; // error: foo.x is already defined
in
On Saturday, 20 January 2018 at 14:31:59 UTC, Sobaya wrote:
How can I wrap function whose arguments contain both ref and
normal like 'func' ?
With normal 'Args', x is not increased because x is copied when
passed to opDispatch.
If I write 'ref Args' in opDispatch's argument, it fails
because
On Sunday, 14 January 2018 at 22:07:22 UTC, Marc wrote:
thanks, can i use it at compile time as well?
enum isMutableString(string field) =
is(typeof(__traits(getMember, >C, field)) == string);
static foreach(field; [FieldNameTuple!C].filter!(f =>
isMutableString!(f))) {
On Friday, 12 January 2018 at 00:16:07 UTC, aliak wrote:
Hi, so basically is there a way to:
void func(alias pred = null, Range)(Range range) {
// 1) check if pred(ElementType!Range.init,
ElementType!Range.init) is equality
// 2) check if isUnary!pred
// 3) check if isBinary!pred
}
On Friday, 26 January 2018 at 14:16:04 UTC, aliak wrote:
It basically steps through in a stride and sets the checkpoints
to false.
C++:
template N>
void mark(It begin, It end, N step) {
assert(begin != end)
*begin = false;
while (end - begin > step) {
begin = begin + step;
On Friday, 26 January 2018 at 20:08:19 UTC, Dechcaudron wrote:
So I'm trying to get this to compile:
```
static foreach (alias member; getSymbolsByUDA!(typeof(this),
Serialize))
serializeMember!member(bundle);
```
And I'm getting the following error: value of 'this' is not
On Friday, 26 January 2018 at 15:33:03 UTC, aliak wrote:
On Friday, 26 January 2018 at 14:35:25 UTC, Meta wrote:
On Friday, 26 January 2018 at 14:16:04 UTC, aliak wrote:
1) I've seen some phobos code checking for assignability like
this:
is(typeof(range.front = false))
... is that an
On Friday, 26 January 2018 at 20:43:05 UTC, Fra Mecca wrote:
What should I do now?
I am undecided between:
- commenting on the bug tracker and close the bug
- link the pr 6056 on the bug tracker
- leaving it be
Leaving a comment on the bug with a link to the PR, and marking
the bug resolved
On Tuesday, 30 January 2018 at 14:01:00 UTC, bauss wrote:
unittest {
auto a = foo(); // This should fail, because a is
never used.
No it shouldn't. It is assigned to a variable, as the constraint
said.
// This should also fail, because b is never used actually
used
On Tuesday, 30 January 2018 at 17:41:53 UTC, jsako wrote:
So what's considered the best alternative to void pointers in D
if you don't want to use objects? Make a tagged Union of all
possible datatypes in the struct? Have a Byte array and cast
that instead of a void pointer? Some sort of magic
On Wednesday, 31 January 2018 at 01:45:57 UTC, H. S. Teoh wrote:
.headConst
.headMutable. :p Head-const is something we generally want to
avoid.
--
Simen
On Thursday, 1 February 2018 at 11:51:11 UTC, aliak wrote:
Is there a way to do this:
import std.stdio;
void main()
{
alias f = (a) => (b) => a * b;
f(2)(3).writeln;
}
The problem here is the outer lambda doesn't know what type the
inner lambda is. We can rewrite this a bit:
auto
On Monday, 29 January 2018 at 09:23:55 UTC, Sobaya wrote:
I found a strange behavior.
class A {
void opAssign(int v) {}
}
class Test {
A a;
this() {
a = new A(); // removing this causes compile error.
a = 3; // cannot implicitly convert expression `3` of
`int` to
On Monday, 29 January 2018 at 11:36:26 UTC, aliak wrote:
You don't want to mutate const elements anyway. It would be
breaking a promise that other parts of the program may be
depending on. I would return a filtered-out range:
Right, I want to mutate the range though, not the elements. So
On Thursday, 1 February 2018 at 18:58:15 UTC, H. S. Teoh wrote:
However, if we go back to the idea of tail-const, we could
potentially eliminate the need for casts and also avoid
breaking immutable. Basically, the problem with writing
const(RefCounted!T) is that it's a one-way street: on the
On Wednesday, 31 January 2018 at 01:45:57 UTC, H. S. Teoh wrote:
I haven't thought through it carefully, but if .headConst is a
viable solution to the head-const problem, then conceivably we
could also extend it to deal with immutable payloads too. Then
we could go from, say,
Is there a way to get a compile error when returning a temporary
from a function and then not assigning it to a variable or
passing it to a different function? E.g:
struct S {
int[] a;
void morph() {}
}
@warnOnDiscard
S foo() {
return S([1,2,3]);
}
unittest {
auto a = foo();
On Tuesday, 30 January 2018 at 11:36:25 UTC, Jonathan M Davis
wrote:
[nope]
Thanks. It's what I thought, though not what I wanted.
IIRC, the Weka guys wanted to be able to have attributes tell
the compiler stuff so that it could yell at the programmer when
appropriate, so I think that there
On Friday, 2 February 2018 at 14:29:34 UTC, H. S. Teoh wrote:
Its semantics are not broken; it's just harder to use. Due to
const transitivity, it's an all-or-nothing deal. .tailConst
gives us the middle ground.
If the semantics of const means that users will have to write
.tailConst all
1 - 100 of 363 matches
Mail list logo