@bearophile - Unless I'm missing something, alas, no. Neither A
nor B is a subtype of the other. In particular, in the real code
one is a CartesianVector and the other a PolarVector. For what
it's worth, 'foo' is actually opBinary addition.
Thanks for the thought though.
Mark Isaacson:
Accordingly, I no longer need an answer to my second question
unless someone knows of a more idiomatic way to get the same
results.
Is the "alias this" useful in this case?
Bye,
bearophile
Did some thinking: Realized that the appropriate mechanism to
express that A and B are two ways of representing the same thing
is to do so via opCast. I had not considered this option
carefully initially as I am translating someone else's C++ code
to D and hoped that they had used the appropria
I have just discovered that the postblit constructor is not able
to be invoked like a "normal" constructor, or, as one would
manually do so in C++ with a copy constructor. Accordingly I have
a couple questions:
1) What are the various ways to invoke the postblit constructor?
I have not tested
On Friday, 2 May 2014 at 21:29:51 UTC, Mark Isaacson wrote:
Auto ref parameters seem to be just what I need. Thanks! I'd
still be curious if anyone has additional information regarding
the rationale at play (I'm spoiled, reading TDPL and having
each decision explained in text).
The C++ way wa
Hi there,
I currently try to write a simple math-parser in D.
However.. something isn't working and I just can't figure out what's the
problem.
(I'm relative new to D, and this is my first test to write a parser/lexer)
I'm pretty sure it's a simple layer-8-problem, but I always overlook it.
Auto ref parameters seem to be just what I need. Thanks! I'd
still be curious if anyone has additional information regarding
the rationale at play (I'm spoiled, reading TDPL and having each
decision explained in text).
On Fri, 02 May 2014 16:32:54 -0400, Vlad Levenfeld
wrote:
Dunno why I didn't try it earlier, but splitting it across lines like
y += 1;
y %= 2;
assert (y == 1);
works. So, bug, then?
Yes.
-Steve
Dunno why I didn't try it earlier, but splitting it across lines
like
y += 1;
y %= 2;
assert (y == 1);
works. So, bug, then?
Can anyone explain to me why this test passes? I have read
through the Types page on the dlang website and can't find
anything that would explain this. Is it a bug or am I doing it
wrong?
uint x = 0;
(x += 1) %= 2;
assert (x == 1);
ubyte y = 0;
(y += 1)
I logged this bug a while ago:
https://issues.dlang.org/show_bug.cgi?id=10291
On Friday, 2 May 2014 at 10:06:43 UTC, ref2401 wrote:
Is it a bug or is there a reason for such behaviour?
is(CommonType!(OriginalType!T1, OriginalType!T2)
... ?
I need it to be variadic.
I cracked it:
import std.typetuple: staticMap;
import std.traits: CommonType, OriginalType;
alias CommonOriginalType(T...) =
CommonType!(staticMap!(OriginalType, T));
/per
On 02/05/14 20:03, Joseph Rushton Wakeling via Digitalmars-d-learn wrote:
On 02/05/14 19:24, "Nordlöw" via Digitalmars-d-learn wrote:
Do I have to use recursion (like in CommonType) to implement this or is there a
better way?
Won't it work to use,
is(CommonType!(OriginalType!T1, OriginalTy
On 02/05/14 19:24, "Nordlöw" via Digitalmars-d-learn wrote:
Do I have to use recursion (like in CommonType) to implement this or is there a
better way?
Won't it work to use,
is(CommonType!(OriginalType!T1, OriginalType!T2)
... ?
In order to make
https://github.com/nordlow/justd/blob/master/enums.d
more type-safe (restrict type arguments to EnumUnion) I need a
type trait, say,
CommonOriginalType(E...)
Do I have to use recursion (like in CommonType) to implement this
or is there a better way?
See also:
http://forum
artur
Collision detection should now be complete.
https://github.com/nordlow/justd/blob/master/enums.d
Superb!
On 05/02/14 17:27, Meta via Digitalmars-d-learn wrote:
> On Friday, 2 May 2014 at 15:18:06 UTC, Artur Skawina via Digitalmars-d-learn
> wrote:
>> On 05/02/14 15:38, "Nordlöw" via Digitalmars-d-learn wrote:
>>>
>>> template MemberNamesUnion(E...) if (allSatisfy!(isEnum, E))
>>> {
>>> bool[strin
On Friday, 2 May 2014 at 15:18:06 UTC, Artur Skawina via
Digitalmars-d-learn wrote:
On 05/02/14 15:38, "Nordlöw" via Digitalmars-d-learn wrote:
template MemberNamesUnion(E...) if (allSatisfy!(isEnum, E))
{
bool[string] allMembers; // used to detect member
collisions
mixin({
On Friday, 2 May 2014 at 10:42:40 UTC, yazd wrote:
On Thursday, 1 May 2014 at 17:31:52 UTC, Nordlöw wrote:
Here you go, https://github.com/yazd/elf-d.
Thanks!
Anytime. By the way, if you need more stuff out of it or help,
post an issue on github. I think I'll be able to help a bit
more. Bu
On 05/02/14 15:38, "Nordlöw" via Digitalmars-d-learn wrote:
>
> template MemberNamesUnion(E...) if (allSatisfy!(isEnum, E))
> {
> bool[string] allMembers; // used to detect member collisions
> mixin({
> string r = "enum MemberNamesUnion { ";
> foreach (T; E) {
>
I seem to have partially solved the problem myself. It seems that
when using the Unittest target makes the linker look in to the
/bin/Unittest directory even though project can be build using a
different target. (right click the solution -> options ->
configurations -> Configuration Mappings) I
So that leaves me with using an array of bool and rank() then,
I guess...
Correction: I mean array of strings and find.
On Friday, 2 May 2014 at 14:36:16 UTC, Meta wrote:
On Friday, 2 May 2014 at 13:38:39 UTC, Nordlöw wrote:
enums.d(25,46): Error: static variable allMembers cannot be
read at compile time
enums.d(25,21):while evaluating: static assert("a" in
allMembers)
Is there a solution to this probl
On Friday, 2 May 2014 at 13:38:39 UTC, Nordlöw wrote:
enums.d(25,46): Error: static variable allMembers cannot be
read at compile time
enums.d(25,21):while evaluating: static assert("a" in
allMembers)
Is there a solution to this problem?
Associative arrays are not CTFE-able.
On Friday, 2 May 2014 at 12:45:44 UTC, Nordlöw wrote:
I'd be verbose. It's an uncommon operation, bound to surprise
a reader
a bit.It's better to type a few more letters.
See update.
I did not try to compile it, but what happens if the enum
elements
have the same name ? The same min/max/val
I'd be verbose. It's an uncommon operation, bound to surprise a
reader
a bit.It's better to type a few more letters.
See update.
I did not try to compile it, but what happens if the enum
elements
have the same name ? The same min/max/values ?
Like this:
enum E1 { a, b, c }
alias E111 = jo
On Fri, May 2, 2014 at 12:59 PM, "Nordlöw"
wrote:
> Some final questions:
>
> - Is join a good naming for this? Is chain better?
> - Is it better to be verbose with joinEnums?
I'd be verbose. It's an uncommon operation, bound to surprise a reader
a bit.It's better to type a few more letters.
I
Maybe not add -L+somelib.lib
Hello all,
I just started learning D and I thought it would be a good idea
to port the Reactive Extensions to D. So far so good, I have been
using Xamarin Studio in combination with Mono-D on Windows 7 and
DMD 2.065.0.
Even though unit testing is baked in to the language I wanted to
set up
Its up: https://github.com/nordlow/justd/blob/master/enums.d
artur
Thx!
Here's my final version that compiles and run:
import std.stdio: writeln;
import traits_ex: isEnum;
import std.typetuple: allSatisfy;
/** Join/Chain/Concatenate/Unite Enums $(D E1), $(D E2), ... into
$(D E).
See also:
http://forum.dlang.org/thread/f9vc6p$1b7k$1...@digitalmars
I'm trying to impose limits upon myself to, well, learn.
Currently I'm exploring ways to avoid allocations -- but my
program is running in three threads with considerable amounts of
message passing between them.
Unless I'm misinterpreting my callgraph,
std.concurrency.MessageBox contains a st
On Thursday, 1 May 2014 at 17:31:52 UTC, Nordlöw wrote:
Here you go, https://github.com/yazd/elf-d.
Thanks!
Anytime. By the way, if you need more stuff out of it or help,
post an issue on github. I think I'll be able to help a bit more.
But if this library is to move forward, the API will n
On Friday, 2 May 2014 at 10:23:03 UTC, Andrej Mitrovic via
Digitalmars-d-learn wrote:
Ouch, ouch, ouch! What's happening is that the 'clear' Appender
method
is only compiled-in if the data is mutable, otherwise you end up
calling the object.clear UFCS function. So don't use clear here.
I don't
On Friday, 2 May 2014 at 08:17:09 UTC, Mark Isaacson wrote:
I'm in the process of learning/practicing D and I noticed
something that seems peculiar coming from a C++ background:
If I compile and run:
void fun(const ref int x) {
//Stuff
}
unittest {
fun(5); //Error! Does not compile
}
I g
On 5/2/14, ref2401 via Digitalmars-d-learn
wrote:
> class MyClass {
> Appender!string _stringBuilder;
>
> this() {
> _stringBuilder = Appender!string(null);
> _stringBuilder.clear();
Ouch, ouch, ouch! What's happening is that the 'clear' Appender method
is
class MyClass {
Appender!string _stringBuilder;
this() {
_stringBuilder = Appender!string(null);
_stringBuilder.clear();
}
@property string str() {
return _stringBuilder.data;
}
void append(string s)
I'm in the process of learning/practicing D and I noticed
something that seems peculiar coming from a C++ background:
If I compile and run:
void fun(const ref int x) {
//Stuff
}
unittest {
fun(5); //Error! Does not compile
}
I get the specified error in my unit test. I understand that the
On Friday, 2 May 2014 at 06:07:48 UTC, evilrat wrote:
On Thursday, 1 May 2014 at 22:23:22 UTC, Ga wrote:
And I am getting a "error LNK2019: unresolved external symbol
GetDeviceCaps referenced in function _Dmain"
have you linked gdi32.lib?
Thanks a lot, I wasn't sure what to link with, I must
39 matches
Mail list logo