On Thursday, 31 May 2018 at 01:12:34 UTC, Dr.No wrote:
is foo() is being called from a thread, how I am supposed to
keep cstring "alive"?
As Jonathan explained, you don't have to worry about it if foo()
itself doesn't assign the pointer to anything internally. That
will be the case for mos
On Thursday, May 31, 2018 01:12:34 Dr.No via Digitalmars-d-learn wrote:
> On Wednesday, 30 May 2018 at 20:43:48 UTC, Ali Çehreli wrote:
> > On 05/30/2018 01:09 PM, Dr.No wrote:
> > > consider a C function with this prototype:
> > >> void foo(const char *baa);
> > >
> > > Does it means I should do:
On Wednesday, May 30, 2018 22:16:28 aberba via Digitalmars-d-learn wrote:
> On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote:
> > On Sunday, May 27, 2018 16:28:56 Russel Winder via
> >
> > Digitalmars-d-learn wrote:
> >> On Sun, 2018-05-27 at 13:10 +, Adam D. Ruppe via
> >> Digita
On Wednesday, 30 May 2018 at 20:43:48 UTC, Ali Çehreli wrote:
On 05/30/2018 01:09 PM, Dr.No wrote:
> consider a C function with this prototype:
>> void foo(const char *baa);
>
> Does it means I should do:
>
>> string s = ...;
>> auto cstring = s.toStringz;
>> foo(cstring);
>
> rather just:
>
>>
On Wednesday, May 30, 2018 15:28:53 Ali Çehreli via Digitalmars-d-learn
wrote:
> On 05/30/2018 03:16 PM, aberba wrote:
> > On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote:
> >> On Sunday, May 27, 2018 16:28:56 Russel Winder via Digitalmars-d-learn
> >>
> >> wrote:
> >>> On Sun, 2018
On Wednesday, 30 May 2018 at 22:57:06 UTC, aberba wrote:
How will you approach this problem in D idiomatically?
Well, I never bother with "idiomatically", so I can't speak to
that, but a simple solution that would work is to realize that
what you're basically asking for here is a bitmap.
Ea
On Wednesday, 30 May 2018 at 22:57:06 UTC, aberba wrote:
I've been given a challenge to write texts using asterisks to
form the letters. D happen to have an unlimited amount of
idioms yet i'm out out ideas as to the simplest approach. Task
is to basically take a piece of text and write them as
On Wednesday, May 30, 2018 22:42:13 Q. Schroll via Digitalmars-d-learn
wrote:
> On Wednesday, 30 May 2018 at 21:02:07 UTC, Jonathan M Davis wrote:
> > On Wednesday, May 30, 2018 20:42:38 Q. Schroll via
> >
> > Digitalmars-d-learn wrote:
> >> It seems one cannot std.algorithm.mutation.move objects
I've been given a challenge to write texts using asterisks to
form the letters. D happen to have an unlimited amount of idioms
yet i'm out out ideas as to the simplest approach. Task is to
basically take a piece of text and write them as asterisks to the
console.
* *
* *
* *
On Wednesday, 30 May 2018 at 21:02:07 UTC, Jonathan M Davis wrote:
On Wednesday, May 30, 2018 20:42:38 Q. Schroll via
Digitalmars-d-learn wrote:
It seems one cannot std.algorithm.mutation.move objects
explicitly. Say I have a non-copyable type
[...]
It fails because move() cannot be executed at
On 05/30/2018 03:16 PM, aberba wrote:
On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote:
On Sunday, May 27, 2018 16:28:56 Russel Winder via Digitalmars-d-learn
wrote:
On Sun, 2018-05-27 at 13:10 +, Adam D. Ruppe via Digitalmars-d-learn
- Jonathan M Davis
Jonathan, which fon
On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote:
On Sunday, May 27, 2018 16:28:56 Russel Winder via
Digitalmars-d-learn wrote:
On Sun, 2018-05-27 at 13:10 +, Adam D. Ruppe via
Digitalmars-d-learn
- Jonathan M Davis
Jonathan, which font were you using in your DConf powerpo
The above idea can be emulated in code, abiet ugly and useless:
https://dpaste.dzfl.pl/bd118bc1910c
import std.stdio;
struct CT(A,B)
{
A v;
B t;
alias v this;
B opUnary(string s)() if (s == "~")
{
return t;
}
A opUnary(string s)() if
On Wednesday, 30 May 2018 at 21:27:44 UTC, Ali Çehreli wrote:
On 05/30/2018 02:19 PM, Malte wrote:
Why does this code complain at the last line about a missing
[] operator overload?
auto buffer = new char[6];
auto chunked = buffer.chunks(3);
chunked[1][2] = '!';
Same happens with wchar.
Dchar
On 05/30/2018 02:19 PM, Malte wrote:
Why does this code complain at the last line about a missing [] operator
overload?
auto buffer = new char[6];
auto chunked = buffer.chunks(3);
chunked[1][2] = '!';
Same happens with wchar.
Dchar and byte work as expected.
UTF-8 auto decoding strikes again
Why does this code complain at the last line about a missing []
operator overload?
auto buffer = new char[6];
auto chunked = buffer.chunks(3);
chunked[1][2] = '!';
Same happens with wchar.
Dchar and byte work as expected.
On Wednesday, May 30, 2018 20:42:38 Q. Schroll via Digitalmars-d-learn
wrote:
> It seems one cannot std.algorithm.mutation.move objects
> explicitly. Say I have a non-copyable type
>
> struct NoCopy
> {
> int payload; // some payload
> pure nothrow @nogc @safe @disable:
>
On Wednesday, 30 May 2018 at 15:46:36 UTC, Steven Schveighoffer
wrote:
On 5/30/18 10:49 AM, DigitalDesigns wrote:
Does it sound good?
class X
{
double x;
@property X foo(double y) { x = y; return this; }
@property X bar(double y) { x = y + 5; return this; }
}
void main()
{
X
It seems one cannot std.algorithm.mutation.move objects
explicitly. Say I have a non-copyable type
struct NoCopy
{
int payload; // some payload
pure nothrow @nogc @safe @disable:
this(this); // make it non copyable
}
that is being used in a compile-time function
On 05/30/2018 01:09 PM, Dr.No wrote:
> consider a C function with this prototype:
>> void foo(const char *baa);
>
> Does it means I should do:
>
>> string s = ...;
>> auto cstring = s.toStringz;
>> foo(cstring);
>
> rather just:
>
>> foo(s.toStringz);
>
> ?
It depends. cstring method above is no
The documentation says:
Important Note: When passing a char* to a C function, and the C
function keeps it around for any reason, make sure that you keep
a reference to it in your D code. Otherwise, it may become
invalid during a garbage collection cycle and cause a nasty bug
when the C code t
On 5/30/18 10:49 AM, DigitalDesigns wrote:
Does it sound good?
class X
{
double x;
@property X foo(double y) { x = y; return this; }
@property X bar(double y) { x = y + 5; return this; }
}
void main()
{
X x = new X();
x.foo(3).bar(4);
}
It sort of emulates UFCS but I'm
On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote:
[...]
Honestly, I'd suggest that folks never use in at this point.
There's zero benefit to it.
[...]
Exactly. If you intend const, just write const. If you intend
const scope, write const scope.
Does it sound good?
class X
{
double x;
@property X foo(double y) { x = y; return this; }
@property X bar(double y) { x = y + 5; return this; }
}
void main()
{
X x = new X();
x.foo(3).bar(4);
}
It sort of emulates UFCS but I'm not sure if it's more trouble
than it's
On Wednesday, 30 May 2018 at 10:31:27 UTC, Simen Kjærås wrote:
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
bei
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 Wednesday, 30 May 2018 at 10:07:35 UTC, Simen Kjærås wrote:
On Wednesday, 30 May 2018 at 09:58:16 UTC, biocyberman wrote:
[...]
This line:
writeln("got num: %s, of type: %s", num, typeof(num));
[...]
Problem solved. Thanks Simen!
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): Er
How do I add logging for this struct?
https://run.dlang.io/is/9N6N4o
If not possible, what's the alternative?
On Tuesday, 27 February 2018 at 14:32:54 UTC, King_DuckZ wrote:
... My problem is mixing D with C and C++ ...
you found already Dragos cmake-d, but not sure if you also know
Dragos talk about mixing D with C/C++.
If not, have a look:
https://gitlab.com/dcarp/MUCplusplus/tree/master/2016.01.2
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 l
On Tuesday, 27 February 2018 at 14:32:54 UTC, King_DuckZ wrote:
On Tuesday, 27 February 2018 at 09:20:21 UTC, Russel Winder
wrote:
[...]
Right, I stand corrected about Rust, though as you say there
are those who use it with CMake.
About cmake-d, there's this
https://github.com/dcarp/cmake-d/
32 matches
Mail list logo