On Friday, 30 March 2018 at 02:30:01 UTC, Chris Katko wrote:
What I'm trying to do is through this experimental API, is both
eliminate the user needing to call a clean-up function
explicitly, and, make the "right way" to use the API
basically... the only way... to use it.
The way I have
On Friday, March 30, 2018 02:30:01 Chris Katko via Digitalmars-d-learn
wrote:
> void start_draw_calls(BITMAP target_bitmap); //locks onto a
> resource
> void end_draw_calls(); //frees previous resource lock
>
> void my_function()
> {
> //...
>
> start_draw_calls(target_bitmap)
void start_draw_calls(BITMAP target_bitmap); //locks onto a
resource
void end_draw_calls(); //frees previous resource lock
void my_function()
{
//...
start_draw_calls(target_bitmap) //whether this is a function,
or class, lambda, or a "using"?
{
draw_call1();
On Thursday, 29 March 2018 at 20:26:59 UTC, kdevel wrote:
What is the lifetime of the first loop's variable i?
It lives as long as the delegate.
What about this example:
``` bug2.d
import std.stdio;
void main ()
{
int delegate () [] dg;
foreach (i; 0..2) {
int *j;
if (i
On 03/29/2018 02:23 PM, Cym13 wrote:
On Thursday, 29 March 2018 at 20:29:39 UTC, aerto wrote:
how i can convert Hello world! to hex 48656c6c6f20776f726c6421 ??
Maybe something like:
void main() {
// Those look like lots of imports but most of those are very
common anyway
import
On Thursday, 29 March 2018 at 20:29:39 UTC, aerto wrote:
how i can convert Hello world! to hex 48656c6c6f20776f726c6421
??
---
import std.format, std.stdio;
void main()
{
writeln("Hello World!".format!("%(%02X%)"));
}
---
https://run.dlang.io/is/acz7kV
On Thursday, March 29, 2018 18:50:39 Chris M. via Digitalmars-d-learn wrote:
> On Thursday, 29 March 2018 at 18:07:50 UTC, Jonathan M Davis
>
> wrote:
> > On Thursday, March 29, 2018 17:41:15 Chris M. via
> >
> > Digitalmars-d-learn wrote:
> >> [...]
> >
> > In general, the correct way to deal
On Thursday, 29 March 2018 at 20:29:39 UTC, aerto wrote:
how i can convert Hello world! to hex 48656c6c6f20776f726c6421
??
Maybe something like:
void main() {
// Those look like lots of imports but most of those are very
common anyway
import std.digest: toHexString;
import
On Thursday, 29 March 2018 at 20:05:35 UTC, ag0aep6g wrote:
On Thursday, 29 March 2018 at 19:02:51 UTC, kdevel wrote:
On Thursday, 29 March 2018 at 15:16:07 UTC, Ivan Kazmenko
wrote:
[...]
int delegate () [] guns;
foreach (i; 0..2) guns ~= () => i;
foreach (i; 0..2)
how i can convert Hello world! to hex 48656c6c6f20776f726c6421 ??
On Thursday, 29 March 2018 at 19:02:51 UTC, kdevel wrote:
On Thursday, 29 March 2018 at 15:16:07 UTC, Ivan Kazmenko wrote:
[...]
int delegate () [] guns;
foreach (i; 0..2) guns ~= () => i;
foreach (i; 0..2) writeln (guns[i] ()); // 1 and 1, why?
Isn't this undefined
On Thursday, 29 March 2018 at 15:16:07 UTC, Ivan Kazmenko wrote:
import std.stdio;
void main () {
int delegate () [] funs;
funs ~= () => 0;
funs ~= () => 1;
foreach (i; 0..2) writeln (funs[i] ()); // 0 and 1 as expected
int delegate () [] guns;
On Thursday, 29 March 2018 at 18:07:50 UTC, Jonathan M Davis
wrote:
On Thursday, March 29, 2018 17:41:15 Chris M. via
Digitalmars-d-learn wrote:
[...]
In general, the correct way to deal with a shared object is to
protect access to it with a mutex and then within that
protected section, you
On Thursday, 29 March 2018 at 15:38:14 UTC, ag0aep6g wrote:
<...> With immutable, this is certainly a problem.
https://issues.dlang.org/show_bug.cgi?id=2043
Wow, such history for the bug!
Two possible workarounds:
int delegate () [] iuns;
foreach (i; 0..2) iuns ~= (j) { return () =>
On Thursday, March 29, 2018 17:41:15 Chris M. via Digitalmars-d-learn wrote:
> I'm working with mysql-native for a project, and have been using
> a single, shared Connection
> (http://semitwist.com/mysql-native-docs/v2.2.0/mysql/connection/Connection
> .html) among multiple threads. The issue here
I'm working with mysql-native for a project, and have been using
a single, shared Connection
(http://semitwist.com/mysql-native-docs/v2.2.0/mysql/connection/Connection.html) among multiple threads. The issue here is that since it's shared, I can't use certain functions such as exec() or close()
On Thursday, 29 March 2018 at 15:16:07 UTC, Ivan Kazmenko wrote:
So, why do delegates of guns[] and huns[] all return 1, and how
to correctly reproduce the behavior of funs[] while populating
it in a loop?
A delegate is a function with a pointer to the stack frame where
it was created. It
On Wednesday, 5 May 2010 at 22:42:19 UTC, Robert Clipsham wrote:
.ptr is only available for arrays. Internally, (dynamic) arrays
in D look like this:
struct {
size_t length;
T* ptr;
}
Thanks for this!! (I know this topic is old).
But it made me understand why I found that this
On 03/29/2018 05:16 PM, Ivan Kazmenko wrote:
int delegate () [] guns;
foreach (i; 0..2) guns ~= () => i;
foreach (i; 0..2) writeln (guns[i] ()); // 1 and 1, why?
Because there's only variable `i`. All delegates refer to that same one.
With `i` being mutable, this could maybe
Here's a simplified example of what I want to achieve.
I first create funs, an array of two delegates.
I want funs[0] to always return 0 and funs[1] to always return 1.
By assigning the constants directly (see the code below), I
achieve exactly that.
Now, I want to use a loop to assign the
On Thursday, 29 March 2018 at 09:16:11 UTC, dangbinghoo wrote:
On Thursday, 29 March 2018 at 09:13:27 UTC, dangbinghoo wrote:
On Thursday, 29 March 2018 at 09:02:16 UTC, Nicholas Wilson
wrote:
On Thursday, 29 March 2018 at 08:47:50 UTC, dangbinghoo wrote:
[...]
try
[...]
thanks for
On Tuesday, 27 March 2018 at 15:37:11 UTC, SimonN wrote:
On Tuesday, 27 March 2018 at 15:28:40 UTC, jmh530 wrote:
static if (isMutable!T)
bag[0] = rhs;
else
bag = [rhs];
I like this idea. I'd even take it a step futher:
When T is a pointer or class
On Sunday, 18 March 2018 at 18:45:23 UTC, Steven Schveighoffer
wrote:
unittest
{
auto foo = new Foo;
assert(foo.internalbuffer.empty); // note, this is a private
symbol.
}
I don't understand why you would want a private symbol in a
*documented* unittest, the reader of the
On Thursday, 29 March 2018 at 09:13:27 UTC, dangbinghoo wrote:
On Thursday, 29 March 2018 at 09:02:16 UTC, Nicholas Wilson
wrote:
On Thursday, 29 March 2018 at 08:47:50 UTC, dangbinghoo wrote:
[...]
try
[...]
thanks for your reply, but it will also fail, the compiler just
gives me :
On Thursday, 29 March 2018 at 09:02:16 UTC, Nicholas Wilson wrote:
On Thursday, 29 March 2018 at 08:47:50 UTC, dangbinghoo wrote:
* #define SPI_MSGSIZE(N) \
N)*(sizeof (struct spi_ioc_transfer))) < (1 <<
_IOC_SIZEBITS)) \
? ((N)*(sizeof (struct spi_ioc_transfer))) : 0)
On Thursday, 29 March 2018 at 08:47:50 UTC, dangbinghoo wrote:
* #define SPI_MSGSIZE(N) \
N)*(sizeof (struct spi_ioc_transfer))) < (1 <<
_IOC_SIZEBITS)) \
? ((N)*(sizeof (struct spi_ioc_transfer))) : 0)
*/
extern (D) size_t SPI_MSGSIZE(size_t N)
{
return ((N *
On Thursday, 29 March 2018 at 08:47:50 UTC, dangbinghoo wrote:
hi,
I'm doing a D binding myself to , and has
some problems to wrap the C macros.
[...]
PS: if I just _IOW!(char[])... it compiles, but does it mean it's
unsafe? thanks!
hi,
I'm doing a D binding myself to , and has
some problems to wrap the C macros.
```
import core.sys.posix.sys.ioctl;
...
/* IOCTL commands */
enum SPI_IOC_MAGIC = 'k';
/**
* Orginal C macros.
*
* #define SPI_MSGSIZE(N) \
N)*(sizeof (struct spi_ioc_transfer))) < (1 <<
On Wednesday, 28 March 2018 at 20:09:24 UTC, Johan Engelen wrote:
On Wednesday, 28 March 2018 at 17:03:07 UTC, Seb wrote:
dub supports dflags and lflags in the config file. lflags are
the linker commands.
Please read the thread.
`lflags` is for passing flags to the _linker_ (i.e. those
On Thursday, 29 March 2018 at 04:16:55 UTC, Adam D. Ruppe wrote:
On Thursday, 29 March 2018 at 04:12:38 UTC, Norm wrote:
Is there a way to do this in D, or does it require special
"create" functions for every struct that has a RAII-like
struct as a member?
You'll have to do it all the way up
30 matches
Mail list logo