On Thu, Jan 18, 2018 at 03:50:15AM +, arturg via Digitalmars-d-learn wrote:
> On Wednesday, 17 January 2018 at 17:37:07 UTC, H. S. Teoh wrote:
> > On Wed, Jan 17, 2018 at 05:31:03PM +, Azi Hassan via
> > Digitalmars-d-learn wrote:
> > > The D tour for structs uses a syntax similar to that o
On Thursday, 18 January 2018 at 02:30:17 UTC, Rubn wrote:
On Wednesday, 17 January 2018 at 22:30:11 UTC, rumbu wrote:
code like "m = n < 0 ? -n : n" doesn't worth a wrapper
That code is worth a wrapper, it's called "abs"...
m = abs(n);
Well, since I'm in the learn forum and you seem to have
On Tuesday, 16 January 2018 at 09:04:18 UTC, Sönke Ludwig wrote:
Am 10.01.2018 um 15:40 schrieb Andres Clari:
Hi, I have an app that uses vibe tasks, fibers and timers
extensively, and I found an issue only for debug builds, when
canceling a timer. However the code in question works just
fine
On Thursday, 18 January 2018 at 04:16:18 UTC, Laeeth Isharc wrote:
Am I missing something, or should extern(C++) just work for
binding to gcc C++ on Linux. It works fine for primitives but
fails for pointer type arguments. Extern "C" works fine.
Does D know how to mangle function names based
Am I missing something, or should extern(C++) just work for
binding to gcc C++ on Linux. It works fine for primitives but
fails for pointer type arguments. Extern "C" works fine.
Does D know how to mangle function names based on pointer types?
I have created matching types on both sides.
T
On Wednesday, 17 January 2018 at 17:37:07 UTC, H. S. Teoh wrote:
On Wed, Jan 17, 2018 at 05:31:03PM +, Azi Hassan via
Digitalmars-d-learn wrote:
The D tour for structs uses a syntax similar to that of C++ in
order to initialize a Person struct : Person p(30, 180). Is
this syntax supported i
On Wednesday, 17 January 2018 at 22:30:11 UTC, rumbu wrote:
code like "m = n < 0 ? -n : n" doesn't worth a wrapper
That code is worth a wrapper, it's called "abs"...
m = abs(n);
On Wednesday, 17 January 2018 at 23:15:33 UTC, Jiyan wrote:
I want to convert from ints implicit to a struct type, so for
example:
I'm not sure what your actual use case is, but based on the
example, you can just template `useV`.
import std.stdio;
struct use
{
int x;
i
On 01/17/2018 03:15 PM, Jiyan wrote:
> Hello,
>
> I want to convert from ints implicit to a struct type, so for example:
>
> struct use
> {
> int x;
>
> int toInt()
> {
> return x;
> }
>
> use fromInt(int v)
> {
> return use(v);
> }
>
>
On 01/17/2018 11:30 PM, rumbu wrote:
1. Why do I need explicitely to promote my byte to int in order to
assign it to an ulong?
2.077: ulong u = -b; 2.088: ulong u = -cast(int)b;
Those two snippets are not equivalent.
When b = byte.min, the 2.077 snippet gives u = 18446744073709551488,
while
On 01/17/2018 02:30 PM, rumbu wrote:
> 1. Why do I need explicitely to promote my byte to int in order to
> assign it to an ulong?
> 2.077: ulong u = -b; 2.088: ulong u = -cast(int)b;
You're not assigning your byte to ulong; you're assigning the expression
-b to ulong. -b is discovered to have
Hello,
I want to convert from ints implicit to a struct type, so for
example:
struct use
{
int x;
int toInt()
{
return x;
}
use fromInt(int v)
{
return use(v);
}
alias toInt this; // implicit con
On Wednesday, 17 January 2018 at 22:01:57 UTC, Johan Engelen
wrote:
```
struct GSharedVariable(AddrSpace as, T)
{
static __gshared T val;
alias val this;
}
alias Global(T) = GSharedVariable!(AddrSpace.Global, T);
Global!float bar1; // __gshared
```
Only 1 value per T though. ;)
On Wednesday, 17 January 2018 at 21:12:07 UTC, Rubn wrote:
On Wednesday, 17 January 2018 at 20:30:07 UTC, rumbu wrote:
And here is why is bothering me:
auto max = isNegative ? cast(Unsigned!T)(-T.min) :
cast(Unsigned!T)T.max);
The generic code above (which worked for all signed integral
typ
On Friday, 12 January 2018 at 04:25:25 UTC, Nicholas Wilson wrote:
Is there a way to make __gshared part of an alias?
Hi Nick, how about this?
```
struct GSharedVariable(AddrSpace as, T)
{
static __gshared T val;
alias val this;
}
alias Global(T) = GSharedVariable!(AddrSpace.Global,
On Wednesday, 17 January 2018 at 20:30:07 UTC, rumbu wrote:
And here is why is bothering me:
auto max = isNegative ? cast(Unsigned!T)(-T.min) :
cast(Unsigned!T)T.max);
The generic code above (which worked for all signed integral
types T in 2.077) must be rewritten like this in 2.078:
stati
On 01/17/2018 09:30 PM, rumbu wrote:
And here is why is bothering me:
auto max = isNegative ? cast(Unsigned!T)(-T.min) : cast(Unsigned!T)T.max);
The generic code above (which worked for all signed integral types T in
2.077) must be rewritten like this in 2.078:
static if (T.sizeof >= 4)
On Wednesday, 17 January 2018 at 20:30:07 UTC, rumbu wrote:
And here is why is bothering me:
auto max = isNegative ? cast(Unsigned!T)(-T.min) :
cast(Unsigned!T)T.max);
The generic code above (which worked for all signed integral
types T in 2.077) must be rewritten like this in 2.078:
stati
And here is why is bothering me:
auto max = isNegative ? cast(Unsigned!T)(-T.min) :
cast(Unsigned!T)T.max);
The generic code above (which worked for all signed integral
types T in 2.077) must be rewritten like this in 2.078:
static if (T.sizeof >= 4)
auto max = isNegative ? cast(Unsigned
On Wednesday, 17 January 2018 at 13:36:26 UTC, Marc wrote:
I was looking for a library to use SQLite with D, found this
(https://code.dlang.org/packages/sqlite-d) but it has no
documentation or code example. I looked into files in the
source code and wrote this:
Database db = Database(name);
On Wednesday, 17 January 2018 at 19:54:50 UTC, ag0aep6g wrote:
On 01/17/2018 08:40 PM, rumbu wrote:
This started in the last DMD version (2.078):
byte b = -10;
ulong u = b < 0 ? -b : b;
//Deprecation: integral promotion not done for `-b`, use
'-transition=intpromote' switch or `-cast(int)(b)
On 01/17/2018 08:40 PM, rumbu wrote:
This started in the last DMD version (2.078):
byte b = -10;
ulong u = b < 0 ? -b : b;
//Deprecation: integral promotion not done for `-b`, use
'-transition=intpromote' switch or `-cast(int)(b)
Why do I need a to promote a byte to int to obtain an ulong? E
This started in the last DMD version (2.078):
byte b = -10;
ulong u = b < 0 ? -b : b;
//Deprecation: integral promotion not done for `-b`, use
'-transition=intpromote' switch or `-cast(int)(b)
Why do I need a to promote a byte to int to obtain an ulong? Even
in the extreme case where b is by
On Wed, Jan 17, 2018 at 05:31:03PM +, Azi Hassan via Digitalmars-d-learn
wrote:
> The D tour for structs uses a syntax similar to that of C++ in order
> to initialize a Person struct : Person p(30, 180). Is this syntax
> supported in D ? Running that part of the code neither works on the
> pla
On Wed, Jan 17, 2018 at 01:36:26PM +, Marc via Digitalmars-d-learn wrote:
> I was looking for a library to use SQLite with D, found this
> (https://code.dlang.org/packages/sqlite-d) but it has no documentation
> or code example. I looked into files in the source code and wrote
> this:
>
> > Da
The D tour for structs uses a syntax similar to that of C++ in
order to initialize a Person struct : Person p(30, 180). Is this
syntax supported in D ? Running that part of the code neither
works on the playground nor on my machine (dmd v2.076.0).
On Wednesday, January 17, 2018 10:44:24 Nicholas Wilson via Digitalmars-d-
learn wrote:
> On Wednesday, 17 January 2018 at 07:53:24 UTC, Jonathan M Davis
>
> wrote:
> > I don't know what you're doing, and maybe __gshared is the
> > appropriate solution for what you're trying to do, but in
> > gener
I was looking for a library to use SQLite with D, found this
(https://code.dlang.org/packages/sqlite-d) but it has no
documentation or code example. I looked into files in the source
code and wrote this:
Database db = Database(name);
auto table = db.table(tableName);
auto rows = table.findRow
On Wednesday, 17 January 2018 at 13:19:42 UTC, Nordlöw wrote:
Why isn't polymorphic down-casts such as in the following
pattern matching on sub-class
class Base {}
class Sub : Base {}
@safe unittest
{
auto base = new Base();
if (auto sub = cast(Sub)base)
{
// use sub
}
Why isn't polymorphic down-casts such as in the following pattern
matching on sub-class
class Base {}
class Sub : Base {}
@safe unittest
{
auto base = new Base();
if (auto sub = cast(Sub)base)
{
// use sub
}
}
allowed in safe D?
On Wednesday, 17 January 2018 at 07:53:24 UTC, Jonathan M Davis
wrote:
I don't know what you're doing, and maybe __gshared is the
appropriate solution for what you're trying to do, but in
general, if you're not trying to bind to a C global variable,
you should be using shared, and using __gshar
On Wednesday, 17 January 2018 at 07:40:36 UTC, Joakim wrote:
Are you sure about this? I thought such module-scope selective
imports were supposed to be private by default since Martin's
fixes for bug 314, which is why you submitted pull 5584. Bug
17630 is about something different, that selec
32 matches
Mail list logo