On Thursday, 22 February 2018 at 00:34:59 UTC, kdevel wrote:
Is there a D equivalent of the C++ at method? I would like to
reformulate
repro2.d
---
void main ()
{
import std.stdio;
import std.container;
import std.range;
auto z = Array!char();
z.reserve(0xC000_);
On Thursday, 22 February 2018 at 04:16:44 UTC, Nick Sabalausky
(Abscissa) wrote:
Are there any tutorials or articles out there for "getting
started with converting a C++ codebase to D one module at a
time?" Or at the very least: tips, tricks, lessions learned,
from those who have come before.
Are there any tutorials or articles out there for "getting started with
converting a C++ codebase to D one module at a time?" Or at the very
least: tips, tricks, lessions learned, from those who have come before.
On 2/21/18 7:30 PM, SrMordred wrote:
But with a slice negative indexes are never allowed, even on a pointer.
youd have to do
(c-1)[0 .. 1];
Nice!
Thank you both!
In D Slice article it says "You can even use negative indexes!" so I
thought
that the [-1..x] should work too :)
Hah! I
But with a slice negative indexes are never allowed, even on a
pointer.
youd have to do
(c-1)[0 .. 1];
Nice!
Thank you both!
In D Slice article it says "You can even use negative indexes!"
so I thought
that the [-1..x] should work too :)
Is there a D equivalent of the C++ at method? I would like to
reformulate
repro2.d
---
void main ()
{
import std.stdio;
import std.container;
import std.range;
auto z = Array!char();
z.reserve(0xC000_);
z.capacity.writeln;
z.length.writeln;
for (uint u = 0; u <
On Thursday, 22 February 2018 at 00:13:43 UTC, SrMordred wrote:
string x = "123";
auto c = x.ptr;
c++;
writeln(c[-1]); // 1
That's only happening because pointers bypass range checks.
writeln(c[-1..0]); //BOOM Range violation
But with a slice negative indexes are never allowed, even on a
On Thursday, 22 February 2018 at 00:13:43 UTC, SrMordred wrote:
string x = "123";
auto c = x.ptr;
c++;
writeln(c[-1]); // 1
writeln(c[-1..0]); //BOOM Range violation
Can I do this / Bug / some mistake ?
youd have to do
(c-1)[0 .. 1];
string x = "123";
auto c = x.ptr;
c++;
writeln(c[-1]); // 1
writeln(c[-1..0]); //BOOM Range violation
Can I do this / Bug / some mistake ?
On Wednesday, 21 February 2018 at 22:22:55 UTC, Meta wrote:
(I'm not sure if the available compiler implementations
actually enforce this)
Yes it does, example
```
enum s = q{€};
```
gives: `Error: character 0x20ac is not a valid token`
On Wednesday, 21 February 2018 at 22:22:55 UTC, Meta wrote:
Mixins have to be full declarations.
They need to be full declarations, full statements, or full
expressions, depending on the context where they appear.
string s = mixin("teste");
so that is a full expression and thus
On Wednesday, 21 February 2018 at 22:11:04 UTC, Jean-Louis Leroy
wrote:
Here's what I am trying to do:
mixin template MakeFun(string ID, int X)
{
int mixin(ID)() { return X; }
}
mixin MakeFun!("one", 1); // int one() { return 1; }
Alas I get:
makefunc.d(3): Error: no identifier for
Here's what I am trying to do:
mixin template MakeFun(string ID, int X)
{
int mixin(ID)() { return X; }
}
mixin MakeFun!("one", 1); // int one() { return 1; }
Alas I get:
makefunc.d(3): Error: no identifier for declarator `int`
makefunc.d(3): Error: found `{` when expecting `;`
On 2/21/18 1:46 PM, Jean-Louis Leroy wrote:
I am trying to figure out a crispier syntax for templatized open
methods. I am stumbling on this (see comments):
// dmd -run conflict.d
int foo();
struct Foo {
static int foo(int x) { return x; }
}
alias foo = Foo.foo; // overload with an alias
On Wednesday, 21 February 2018 at 20:27:29 UTC, Steven
Schveighoffer wrote:
On 2/21/18 1:46 PM, Jean-Louis Leroy wrote:
[...]
I think because one is a function, which is allowed to be
overloaded, the other is a symbol.
But clearly, there are some liberties taken when you are
overloading
I am trying to figure out a crispier syntax for templatized open
methods. I am stumbling on this (see comments):
// dmd -run conflict.d
int foo();
struct Foo {
static int foo(int x) { return x; }
}
alias foo = Foo.foo; // overload with an alias - OK
int bar(T)();
int bar(T)(T x) { return
On 2/21/18 1:45 AM, thorstein wrote:
Hi,
I'm going circles... ;) I read a string that contains an array of
unknown dimension like:
a = [1,2,3,4] or
a = [[1,2],[3,4]] or
a = [[[1,2],[3,4]],[[5,6],[7,8]]]
With that I want to perform specified operations e.g. also provided on
command line.
On 2/21/18 6:24 AM, Jiyan wrote:
I think i found my solution: is it __xdtor? :P
Yes, that is the function that will run *recursively* all the
destructors (just __dtor runs the destructor method if you provided
one). But I'd recommend as the others did, using destroy.
-Steve
On 2/20/18 9:59 PM, Nicholas Wilson wrote:
FYI, File is a reference counted FILE* so theres not really any point of
heap allocating it.
More FYI, the reference counted payload is actually allocated on the C
heap :) So you are wasting a lot of effort to do something that is
already done.
On Wednesday, 21 February 2018 at 14:29:31 UTC, Simen Kjærås
wrote:
On Wednesday, 21 February 2018 at 14:11:10 UTC, ParticlePeter
wrote:
struct Foo(T) {
T bar;
this(S)(S s) {
bar = convert(s);
}
}
auto foo = Foo!int(some_float);
this works because S is deduced as
On 2/20/18 2:52 PM, Steven Schveighoffer wrote:
On 2/20/18 2:00 PM, bachmeier wrote:
Someone has posted a question on our subreddit. Would be nice if he
could get an answer:
https://www.reddit.com/r/d_language/comments/7yxwvm/why_do_my_threads_write_to_the_wrong_file/
I responded. Looks to
On Wednesday, 21 February 2018 at 14:42:56 UTC, Simen Kjærås
wrote:
On Wednesday, 21 February 2018 at 14:29:38 UTC, ixid wrote:
I do not understand what is happening here, I tried to wrote
what I thought would be the answer. If someone could explain
that would be great. I wrote this code:
On Wednesday, 21 February 2018 at 11:41:18 UTC, Diederik de Groot
wrote:
Removing the pragma(lib, "curl") seems to fix the issue on DFly
(and FreeBSD). Updated the pull request.
I guess pragma(lib, xxx) needs a little bit of attention to see
what causes it not to work.
something to do with
On Wednesday, 21 February 2018 at 14:29:38 UTC, ixid wrote:
I do not understand what is happening here, I tried to wrote
what I thought would be the answer. If someone could explain
that would be great. I wrote this code:
struct Foo2(T, S) {
T bar;
this(S s) {
bar = s.to!T;
}
}
On Wednesday, 21 February 2018 at 14:11:10 UTC, ParticlePeter
wrote:
struct Foo(T) {
T bar;
this(S)(S s) {
bar = convert(s);
}
}
auto foo = Foo!int(some_float);
this works because S is deduced as typeof(some_float), but how
would I instantiate the struct without relying on auto
On Wednesday, 21 February 2018 at 14:11:10 UTC, ParticlePeter
wrote:
struct Foo(T) {
T bar;
this(S)(S s) {
bar = convert(s);
}
}
auto foo = Foo!int(some_float);
this works because S is deduced as typeof(some_float), but how
would I instantiate the struct without relying on auto
struct Foo(T) {
T bar;
this(S)(S s) {
bar = convert(s);
}
}
auto foo = Foo!int(some_float);
this works because S is deduced as typeof(some_float), but how
would I instantiate the struct without relying on auto deduction?
Suppose we would have this kind of constructor where auto
On Wednesday, 21 February 2018 at 12:07:47 UTC, ketmar wrote:
`p.destroy` will call the dtors for you.
So it is the same function but I prefer to always write it:
.destroy(p);
yes, a leading dot. This ensures you call the top-level destroy
function instead of any members which may not do
Jiyan wrote:
Hi :),
What i thought was that when i create a struct dynamically i can just
deconstruct it with __dtor lets say:
struct U {...}
struct S {... private U _member;}
S* p;
p = cast(S*)malloc(S.sizeof);
// just run that if it compiles, for simplicity
// we dont use
On Tuesday, 20 February 2018 at 03:59:06 UTC, psychoticRabbit
wrote:
On Monday, 19 February 2018 at 12:01:31 UTC, Jonathan M Davis
wrote:
ok... so I decided to dig into it a little further.
seems the problem relates to a single line, in dget.d
pragma(lib, "curl");
I just commented out
On Wednesday, 21 February 2018 at 11:12:01 UTC, Jiyan wrote:
Hi :),
What i thought was that when i create a struct dynamically i
can just deconstruct it with __dtor lets say:
struct U {...}
struct S {... private U _member;}
S* p;
p = cast(S*)malloc(S.sizeof);
// just run that if it
Hi :),
What i thought was that when i create a struct dynamically i can
just deconstruct it with __dtor lets say:
struct U {...}
struct S {... private U _member;}
S* p;
p = cast(S*)malloc(S.sizeof);
// just run that if it compiles, for simplicity
// we dont use __traits(compiles, ...)
On Wednesday, 21 February 2018 at 10:43:14 UTC, 0x wrote:
Gotta save this too.
[BTW how do I post a thumbs up emoji]
On 21/02/2018 10:43 AM, 0x wrote:
On Wednesday, 21 February 2018 at 10:24:39 UTC, ketmar wrote:
0x wrote:
[...]
and that is exactly what slices are for! ;-)
you are probably better to use `const(char)[]`, tho. like this:
// don't store `s`, as it's contents may change
On Wednesday, 21 February 2018 at 10:24:39 UTC, ketmar wrote:
0x wrote:
[...]
and that is exactly what slices are for! ;-)
you are probably better to use `const(char)[]`, tho. like this:
// don't store `s`, as it's contents may change after exiting
of `myfunc`
// (this
On Wednesday, 21 February 2018 at 09:21:58 UTC, 0x wrote:
What is the equivalent of C++17 std::string_view (an object
that can refer to a constant contiguous sequence of char-like
objects with the first element of the sequence at position
zero) in D?
PS: I'm getting back to D after
On 21/02/2018 10:41 AM, 0x wrote:
On Wednesday, 21 February 2018 at 09:21:58 UTC, 0x wrote:
What is the equivalent of C++17 std::string_view (an object that can
refer to a constant contiguous sequence of char-like objects with the
first element of the sequence at position zero)
On Wednesday, 21 February 2018 at 10:22:56 UTC, rikki cattermole
wrote:
On 21/02/2018 10:17 AM, 0x wrote:
On Wednesday, 21 February 2018 at 09:21:58 UTC, 0x
wrote:
What is the equivalent of C++17 std::string_view (an object
that can refer to a constant contiguous sequence of
On Wednesday, 21 February 2018 at 10:23:23 UTC, Jonathan M Davis
wrote:
As I said in my previous response, read this article:
https://dlang.org/articles/d-array-article.html
Sorry, I didn't see this before I replied.
Had I, I wouldn't have done that.
string sv = "some string";
then _zero_
0x wrote:
On Wednesday, 21 February 2018 at 09:21:58 UTC, 0x wrote:
What is the equivalent of C++17 std::string_view (an object that can
refer to a constant contiguous sequence of char-like objects with the
first element of the sequence at position zero) in D?
PS: I'm
On 21/02/2018 10:17 AM, 0x wrote:
On Wednesday, 21 February 2018 at 09:21:58 UTC, 0x wrote:
What is the equivalent of C++17 std::string_view (an object that can
refer to a constant contiguous sequence of char-like objects with the
first element of the sequence at position zero)
On Wednesday, February 21, 2018 10:17:55 0x via Digitalmars-d-learn
wrote:
> On Wednesday, 21 February 2018 at 09:21:58 UTC, 0x wrote:
> > What is the equivalent of C++17 std::string_view (an object
> > that can refer to a constant contiguous sequence of char-like
> > objects with
On Wednesday, 21 February 2018 at 09:21:58 UTC, 0x wrote:
What is the equivalent of C++17 std::string_view (an object
that can refer to a constant contiguous sequence of char-like
objects with the first element of the sequence at position
zero) in D?
PS: I'm getting back to D after
On Wednesday, February 21, 2018 09:21:58 0x via Digitalmars-d-learn
wrote:
> What is the equivalent of C++17 std::string_view (an object that
> can refer to a constant contiguous sequence of char-like objects
> with the first element of the sequence at position zero) in D?
>
> PS: I'm
On Wednesday, 21 February 2018 at 09:21:58 UTC, 0x wrote:
What is the equivalent of C++17 std::string_view (an object
that can refer to a constant contiguous sequence of char-like
objects with the first element of the sequence at position
zero) in D?
PS: I'm getting back to D after
On Wednesday, 21 February 2018 at 09:21:58 UTC, 0x wrote:
What is the equivalent of C++17 std::string_view (an object
that can refer to a constant contiguous sequence of char-like
objects with the first element of the sequence at position
zero) in D?
PS: I'm getting back to D after
On 21/02/2018 9:21 AM, 0x wrote:
What is the equivalent of C++17 std::string_view (an object that can
refer to a constant contiguous sequence of char-like objects with the
first element of the sequence at position zero) in D?
PS: I'm getting back to D after years (since DMD 1 days). A
What is the equivalent of C++17 std::string_view (an object that
can refer to a constant contiguous sequence of char-like objects
with the first element of the sequence at position zero) in D?
PS: I'm getting back to D after years (since DMD 1 days). A lot
changes since v1.0.
On Wednesday, 21 February 2018 at 06:45:14 UTC, thorstein wrote:
Hi,
I'm going circles... ;) I read a string that contains an array
of unknown dimension like:
a = [1,2,3,4] or
a = [[1,2],[3,4]] or
a = [[[1,2],[3,4]],[[5,6],[7,8]]]
With that I want to perform specified operations e.g. also
49 matches
Mail list logo