On Sun, Jun 04, 2017 at 12:45:23AM +, Stanislav Blinov via
Digitalmars-d-learn wrote:
[...]
> No, it shouldn't. char* et al. are not string types in D.
> to!(char*)(string) just doesn't make sense.
If you need to convert between D strings and char*, wchar*, etc., e.g.,
for interfacing with C/
On Sat, Jun 03, 2017 at 10:38:31PM +, Mark via Digitalmars-d-learn wrote:
[...]
> Ok. So by using '==' it should compare the addresses of the objects?
[...]
No, `==` is for comparing the *contents* of the objects. You need to
implement opEquals() for the objects being compared in order to def
On Saturday, 3 June 2017 at 14:12:03 UTC, Russel Winder wrote:
From the manual page on std.path.buildPath:
writeln(buildPath("foo", "bar", "baz")); // "foo/bar/baz"
writeln(buildPath("/foo/", "bar/baz")); // "/foo/bar/baz"
writeln(buildPath("/foo", "/bar")); // "/bar"
I have no idea
On Saturday, 3 June 2017 at 23:36:18 UTC, Mike B Johnson wrote:
https://dlang.org/phobos/std_utf.html#toUTF16z
This didn't work. More errors than the first.
Works for me:
void main()
{
import std.conv;
import std.stdio;
import core.stdc.wchar_;
import core.stdc.stdio;
a
On 06/03/2017 04:36 PM, Mike B Johnson wrote:
On Saturday, 3 June 2017 at 23:09:56 UTC, Stanislav Blinov wrote:
On Saturday, 3 June 2017 at 22:54:22 UTC, Mike B Johnson wrote:
How to convert a string to wchar*?
C-style null-terminated wchar*?
https://dlang.org/phobos/std_utf.html#toUTF16z
On Saturday, 3 June 2017 at 23:32:44 UTC, Ali Çehreli wrote:
...
Ali
Awesome, that might be handy in the near future.
Thanks.
On Saturday, 3 June 2017 at 23:09:56 UTC, Stanislav Blinov wrote:
On Saturday, 3 June 2017 at 22:54:22 UTC, Mike B Johnson wrote:
How to convert a string to wchar*?
C-style null-terminated wchar*?
https://dlang.org/phobos/std_utf.html#toUTF16z
This didn't work. More errors than the first.
On 06/03/2017 03:38 PM, Mark wrote:
> Ok. So by using '==' it should compare the addresses of the objects?
That's the default behavior. You can change it with opEquals:
http://ddili.org/ders/d.en/object.html#ix_object.opEquals
I think you want to use the 'is' operator:
http://ddili.org/de
On Saturday, 3 June 2017 at 22:54:22 UTC, Mike B Johnson wrote:
How to convert a string to wchar*?
C-style null-terminated wchar*?
https://dlang.org/phobos/std_utf.html#toUTF16z
On Saturday, 3 June 2017 at 22:53:51 UTC, Stanislav Blinov wrote:
On Saturday, 3 June 2017 at 22:38:31 UTC, Mark wrote:
In the future I'll include a compilable example. I was having
problems with a class I made which is about 45 lines, that
might be a lot of code for a post.
You can use exte
On Saturday, 3 June 2017 at 22:52:42 UTC, Mark wrote:
Thanks again.
Nevermind, I got it.
How to convert a string to wchar*?
string s;
to!(wchar*)(s)
gives phobo's deduction problems.
\dmd2\windows\bin\..\..\src\phobos\std\conv.d(194): Error:
template std.conv.toImpl cannot deduce function from argument
types !(wchar*)(string), candidates are:
\dmd2\windows\bin\..\..\src\phobos\st
On Saturday, 3 June 2017 at 22:38:31 UTC, Mark wrote:
In the future I'll include a compilable example. I was having
problems with a class I made which is about 45 lines, that
might be a lot of code for a post.
You can use external resources such as:
https://d.godbolt.org/
https://dpaste.dzfl
On Saturday, 3 June 2017 at 22:38:31 UTC, Mark wrote:
...
Thanks.
Actually, I got another question,
how Can I obtain the actual memory address of a class?
I'll still need to solve the problem of taking ints/floats/reals
etc., as well as structs and classes and sending them right/left
in the
On Saturday, 3 June 2017 at 20:24:44 UTC, ag0aep6g wrote:
By default, they act the same. But you can change how `==`
behaves by overriding `opEquals`. You cannot override `is`.
Ok. So by using '==' it should compare the addresses of the
objects?
I think I didn't include the other file as
On Saturday, 3 June 2017 at 21:46:45 UTC, Stanislav Blinov wrote:
On Saturday, 3 June 2017 at 21:39:54 UTC, Moritz Maxeiner wrote:
It's always true, because I explicitly wrote *might*, not
*will*, to indicate that it depends on your use case. Your
example is a common use case where you can't sk
On Saturday, 3 June 2017 at 21:39:54 UTC, Moritz Maxeiner wrote:
On Saturday, 3 June 2017 at 21:16:08 UTC, Stanislav Blinov
wrote:
On Saturday, 3 June 2017 at 20:53:05 UTC, Moritz Maxeiner
wrote:
Quite, but if you backtrack to my initial statement, it was
about ptr not being/becoming null (im
On Saturday, 3 June 2017 at 21:16:08 UTC, Stanislav Blinov wrote:
On Saturday, 3 June 2017 at 20:53:05 UTC, Moritz Maxeiner wrote:
Quite, but if you backtrack to my initial statement, it was
about ptr not being/becoming null (implicitly) in the first
place, which *might* allow you to skip the
On Saturday, 3 June 2017 at 20:53:05 UTC, Moritz Maxeiner wrote:
On Saturday, 3 June 2017 at 20:25:22 UTC, Stanislav Blinov
wrote:
On Saturday, 3 June 2017 at 20:13:30 UTC, Moritz Maxeiner
wrote:
Calling std.algorithm.move is explicit programmer intent, I
consider that about as accidental as
On Saturday, 3 June 2017 at 20:25:22 UTC, Stanislav Blinov wrote:
On Saturday, 3 June 2017 at 20:13:30 UTC, Moritz Maxeiner wrote:
Calling std.algorithm.move is explicit programmer intent, I
consider that about as accidental as calling memcpy with a
source full of zeroes.
In any case, having t
On Saturday, 3 June 2017 at 20:13:30 UTC, Moritz Maxeiner wrote:
Calling std.algorithm.move is explicit programmer intent, I
consider that about as accidental as calling memcpy with a
source full of zeroes.
In any case, having that check in the destructor is fairly
cheap, so better safe than s
On 06/03/2017 10:02 PM, Mark wrote:
auto A = new Box();
auto B = new Box();
if(A.opEquals(B)) {}
gives the error
test.o:(.data.rel.ro+0x18): undefined reference to
`_D5Stack12__ModuleInfoZ'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
Your code works for me
On Saturday, 3 June 2017 at 20:02:13 UTC, Mark wrote:
On Saturday, 3 June 2017 at 19:57:47 UTC, Mark wrote:
Hello again.
I'm designing a template version of a BST.
Because of this, I want to be able to compare if two objects
of the same class type are references to the same anonymous
class o
On Saturday, 3 June 2017 at 20:02:13 UTC, Mark wrote:
On Saturday, 3 June 2017 at 19:57:47 UTC, Mark wrote:
Hello again.
I'm designing a template version of a BST.
Because of this, I want to be able to compare if two objects
of the same class type are references to the same anonymous
class o
On Saturday, 3 June 2017 at 19:55:30 UTC, ag0aep6g wrote:
On 06/03/2017 09:37 PM, Moritz Maxeiner wrote:
Of course, but AFAIK you'd need to explicitly assign it to an
object, so `ptr` won't null by accident, but only by explicit
programmer intent (same as overwriting the memory the object
live
On Saturday, 3 June 2017 at 05:21:13 UTC, 9il wrote:
On Friday, 2 June 2017 at 16:08:20 UTC, Zz wrote:
Hi,
Just tried migrating from std.experimental.ndslice to
mir-algorithm.
Is there a guide on how migrate old code?
I used the following imports before and using then with
ndslice.
impor
On Saturday, 3 June 2017 at 19:55:30 UTC, ag0aep6g wrote:
On 06/03/2017 09:37 PM, Moritz Maxeiner wrote:
Of course, but AFAIK you'd need to explicitly assign it to an
object, so `ptr` won't null by accident, but only by explicit
programmer intent (same as overwriting the memory the object
live
On Saturday, 3 June 2017 at 19:57:47 UTC, Mark wrote:
Hello again.
I'm designing a template version of a BST.
Because of this, I want to be able to compare if two objects of
the same class type are references to the same anonymous class
on the heap somewhere.
Example:
Not sure what happen
Hello again.
I'm designing a template version of a BST.
Because of this, I want to be able to compare if two objects of
the same class type are references to the same anonymous class on
the heap somewhere.
Example:
On 06/03/2017 09:37 PM, Moritz Maxeiner wrote:
Of course, but AFAIK you'd need to explicitly assign it to an object, so
`ptr` won't null by accident, but only by explicit programmer intent
(same as overwriting the memory the object lives in via things like
`memcpy`); and you can always screw th
On Saturday, 3 June 2017 at 19:21:58 UTC, ag0aep6g wrote:
On 06/03/2017 09:06 PM, Moritz Maxeiner wrote:
- null check in destructor: That's just because I forgot to
add it. If you add `@disable(this)` (disable the default
constructor), all elaborate constructors ensure it is not
null, and no m
On 06/03/2017 09:06 PM, Moritz Maxeiner wrote:
- null check in destructor: That's just because I forgot to add it. If
you add `@disable(this)` (disable the default constructor), all
elaborate constructors ensure it is not null, and no members can set it
to null, you might be able to skip the ch
On Saturday, 3 June 2017 at 17:40:32 UTC, Russel Winder wrote:
Would one be considered more idiomatic D, or is it a
question of different circumstances different approaches. The
differences are mainly in construction I believe.
Well, the differences I spot are:
- null check in destructor: That
Thanks to Moritz and Stanislav for their examples, most useful. There
are similarities (which I have just taken :-) but also some
differences. Would one be considered more idiomatic D, or is it a
question of different circumstances different approaches. The
differences are mainly in construction I
On Saturday, 3 June 2017 at 17:24:08 UTC, Russel Winder wrote:
So why isn't rdmd shipped as a separate thing if it can wrap
any of the three compilers?
it is... the link above is all there is to it, you simply compile
it. The docs also call it a download: http://dlang.org/rdmd.html
dmd just
On Sat, 2017-06-03 at 17:08 +, Adam D. Ruppe via Digitalmars-d-
learn wrote:
> On Saturday, 3 June 2017 at 05:04:24 UTC, Russel Winder wrote:
> > Not enough is made of rdmd. rdmd needs to be separated from dmd
> > so it works with gdc and ldc2.
>
> rdmd has always worked with them, at least w
On Saturday, 3 June 2017 at 05:04:24 UTC, Russel Winder wrote:
Not enough is made of rdmd. rdmd needs to be separated from dmd
so it works with gdc and ldc2.
rdmd has always worked with them, at least with their gdmd and
ldmd wrappers
https://github.com/dlang/tools/blob/master/rdmd.d#L46
On Saturday, 3 June 2017 at 16:22:33 UTC, Francis Nixon wrote:
When looking at std.variant I found the following line:
return q{
static if (allowed!%1$s && T.allowed!%1$s)
if (convertsTo!%1$s && other.convertsTo!%1$s)
return VariantN(get!%1$s %2$s other.get!%1$s);
}.form
On Saturday, 3 June 2017 at 16:22:33 UTC, Francis Nixon wrote:
When looking at std.variant I found the following line:
return q{
static if (allowed!%1$s && T.allowed!%1$s)
if (convertsTo!%1$s && other.convertsTo!%1$s)
return VariantN(get!%1$s %2$s other.get!%1$s);
}.form
On Saturday, 3 June 2017 at 16:22:33 UTC, Francis Nixon wrote:
When looking at std.variant I found the following line:
return q{
static if (allowed!%1$s && T.allowed!%1$s)
if (convertsTo!%1$s && other.convertsTo!%1$s)
return VariantN(get!%1$s %2$s other.get!%1$s);
}.form
When looking at std.variant I found the following line:
return q{
static if (allowed!%1$s && T.allowed!%1$s)
if (convertsTo!%1$s && other.convertsTo!%1$s)
return VariantN(get!%1$s %2$s other.get!%1$s);
}.format(tp, op);
I was wondering what exactly the % signs where doin
On 03/06/2017 4:43 PM, Lewis wrote:
On Saturday, 3 June 2017 at 09:28:03 UTC, rikki cattermole wrote:
A lot of this can be done by simply implementing shared libraries
fully on Windows. There is a reason why TypeInfo doesn't cross the dll
boundary right now. Sadly it isn't a high priority (and
On Saturday, 3 June 2017 at 09:28:03 UTC, rikki cattermole wrote:
A lot of this can be done by simply implementing shared
libraries fully on Windows. There is a reason why TypeInfo
doesn't cross the dll boundary right now. Sadly it isn't a high
priority (and it really really needs to be "just d
On Saturday, 3 June 2017 at 14:12:03 UTC, Russel Winder wrote:
I have no idea what drugs the person who chose that last one to
be correct semantics was on at the time, but it was some
seriously bad stuff.
Of all people, I certainly didn't expect you to stray so far from
the tone appropriate h
On Saturday, 3 June 2017 at 14:34:41 UTC, Nick Vitsas wrote:
In any case, do you think that `scope` should allow for such
code to compile? Since you can get the desired result using the
verbose version, I think you should also be able to using the
`lazy` construct.
I think so. There's even a
Hello,
I've been playing around with the idea of lazy evaluation for
function arguments [1] and I really like how it can be used to
simplify deep nested loops operating on structured data.
It also seems that you can get quite far without invoking the GC
using the `scope` keyword. I’ve been e
On 2017-06-03 16:22, David Nadlinger wrote:
We could also finally fix the frontend to get around this. At DConf
2015, Walter officially agreed that this is a bug that needs fixing. ;)
That would be nice.
--
/Jacob Carlborg
On Saturday, 3 June 2017 at 06:19:29 UTC, Jonathan M Davis wrote:
Assigning Nullable!Test.init is equivalent to setting the
internal value to Test.init and setting _isNull to false.
Eh? Does it mean Nullable is default initialized to some non-null
default value?
On 2017-06-03 16:12, Russel Winder via Digitalmars-d-learn wrote:
From the manual page on std.path.buildPath:
writeln(buildPath("foo", "bar", "baz")); // "foo/bar/baz"
writeln(buildPath("/foo/", "bar/baz")); // "/foo/bar/baz"
writeln(buildPath("/foo", "/bar")); // "/bar"
I have no i
On Saturday, 3 June 2017 at 14:19:00 UTC, Jacob Carlborg wrote:
Perhaps using the variadic template with a constraint on one
element trick will work. Ugly, but I think that will work.
We could also finally fix the frontend to get around this. At
DConf 2015, Walter officially agreed that this i
Jacob Carlborg wrote:
Perhaps using the variadic template with a constraint on one element
trick will work. Ugly, but I think that will work.
yeah. that's what Phobos does, for example.
On 2017-06-03 16:03, Nicholas Wilson wrote:
I think an alias template parameter will work here as aliases take
anything(types, literals, symbols).
No, it doesn't work for types:
void foo(alias a)() {}
void main()
{
foo!(int)();
}
Results in:
Error: template instance foo!int does not ma
On Saturday, 3 June 2017 at 06:19:29 UTC, Jonathan M Davis wrote:
[...]
thanks
On Saturday, 3 June 2017 at 13:17:46 UTC, Russel Winder wrote:
Is this a problem in D or a problem in DStep?
It's a limitation of DStep – for that use case, it would need to
transform one of the macro arguments into a template argument
rather than a runtime function parameter.
If you need t
From the manual page on std.path.buildPath:
writeln(buildPath("foo", "bar", "baz")); // "foo/bar/baz"
writeln(buildPath("/foo/", "bar/baz")); // "/foo/bar/baz"
writeln(buildPath("/foo", "/bar")); // "/bar"
I have no idea what drugs the person who chose that last one to be
correct sema
On Saturday, 3 June 2017 at 13:17:46 UTC, Russel Winder wrote:
A stripped down problem to avoid fluff. The C macro:
#define FLOB(t) (sizeof(t))
Can be used in another macro:
#define THINGY(a, b) (_THING(a, FLOB(b)))
We can use this as in:
THINGY(10, __u32)
Now the D Way says use
Russel Winder wrote:
Now the D Way says...
..use templates! ;-)
it is not really possible to guess what macro author means (to do that,
dstep should be able to actually *understand* the code), so it tries to do
what is used more often.
that is, it's dstep failed guess.
A stripped down problem to avoid fluff. The C macro:
#define FLOB(t) (sizeof(t))
Can be used in another macro:
#define THINGY(a, b) (_THING(a, FLOB(b)))
We can use this as in:
THINGY(10, __u32)
Now the D Way says use functions not macros. except that
size_t FLOB(T)(auto ref
On Saturday, 3 June 2017 at 09:41:58 UTC, aberba wrote:
On Friday, 2 June 2017 at 16:36:34 UTC, H. S. Teoh wrote:
On Fri, Jun 02, 2017 at 12:19:48PM +, Adam D. Ruppe via
Digitalmars-d-learn wrote:
On Friday, 2 June 2017 at 11:09:05 UTC, aberba wrote:
> 1. Get shared libs to work in D (the b
On Friday, 2 June 2017 at 16:36:34 UTC, H. S. Teoh wrote:
On Fri, Jun 02, 2017 at 12:19:48PM +, Adam D. Ruppe via
Digitalmars-d-learn wrote:
On Friday, 2 June 2017 at 11:09:05 UTC, aberba wrote:
> 1. Get shared libs to work in D (the best approach for all D
> code)
I have done very little
On 03/06/2017 10:03 AM, Mike B Johnson wrote:
On Saturday, 3 June 2017 at 00:02:54 UTC, Lewis wrote:
On Friday, 2 June 2017 at 20:47:31 UTC, Mike B Johnson wrote:
[...]
For sure. I actually want to post the source code at some point, but
the changes I made are very much set up specifically f
On Saturday, 3 June 2017 at 00:02:54 UTC, Lewis wrote:
On Friday, 2 June 2017 at 20:47:31 UTC, Mike B Johnson wrote:
[...]
For sure. I actually want to post the source code at some
point, but the changes I made are very much set up specifically
for this project. I'll sift through at some poi
On Saturday, 3 June 2017 at 08:01:14 UTC, Jonathan M Davis wrote:
On Saturday, June 03, 2017 06:41:44 Stanislav Blinov via
Digitalmars-d-learn wrote:
On Saturday, 3 June 2017 at 06:19:29 UTC, Jonathan M Davis
wrote:
> looking at what rt_finalize does, I don't see why it
> couldn't be nothrow. S
On Saturday, June 03, 2017 06:41:44 Stanislav Blinov via Digitalmars-d-learn
wrote:
> On Saturday, 3 June 2017 at 06:19:29 UTC, Jonathan M Davis wrote:
> > looking at what rt_finalize does, I don't see why it couldn't
> > be nothrow. So, unless I'm missing something, it seems like
> > that would b
On Friday, 2 June 2017 at 16:36:34 UTC, H. S. Teoh wrote:
On Fri, Jun 02, 2017 at 12:19:48PM +, Adam D. Ruppe via
Digitalmars-d-learn wrote:
[...]
[...]
This is not directly related to the OP's question, but recently
I wrote a program that, given a user-specified string,
transforms it in
65 matches
Mail list logo