On Wednesday, 18 May 2016 at 01:46:37 UTC, tsbockman wrote:
Shouldn't a union type always have an `alignof` at least as
great as the `alignof` for its largest member?
On x86, there's a difference between the type alignment and the
field alignment.
The type align of ulong and double are 8
On Saturday, 21 May 2016 at 01:09:42 UTC, Alex Parrill wrote:
On Friday, 20 May 2016 at 22:10:51 UTC, tsbockman wrote:
If that's not a satisfactory answer, please show some specific
examples of code that you don't know how to make work without
VK_NULL_HANDLE so that I can propose a workaround.
On Wednesday, 18 May 2016 at 01:46:37 UTC, tsbockman wrote:
Shouldn't a union type always have an `alignof` at least as
great as the `alignof` for its largest member?
Apparently not; it's actually DMD and LDC that are wrong here:
http://bugzilla.gdcproject.org/show_bug.cgi?id=226
On Saturday, 21 May 2016 at 01:53:21 UTC, Mike Parker wrote:
When binding to a C library, it's desirable to have as close to
the original C API as possible so that you *can* drop C
snippets and examples into D code and have them just work.
Obviously, 100% compatibility is not possible, but it
Unfortunately it is not possible to write this
import std.typecons;
class Info{...}
rebindable!Info x;
I get the following error message
source/app.d(11,3): Error: template std.typecons.rebindable
matches more than one template declaration:
/usr/include/dmd/phobos/std/typecons.d(1675,14):
Since I'm trying to implement a flyweight pattern, the opEqual
need only comparision of reference in my case.
By the way, what operation is the switch performing ? OpEqual or
is ?
On Wednesday, 18 May 2016 at 23:45:07 UTC, Alex Parrill wrote:
In C it's called a variable-length struct or object. I don't
think D implements them, but this could probably work:
Thanks!
On 05/21/2016 01:07 AM, chmike wrote:
> Unfortunately it is not possible to write this
>
> import std.typecons;
> class Info{...}
> rebindable!Info x;
You have a capitalization typo. Rebindable is a type template,
rebindable is a function template.
import std.typecons;
class Info{}
void
On Saturday, 21 May 2016 at 00:39:21 UTC, Jonathan M Davis wrote:
Well, if you actually tried marking functions with pure, you'd
see pretty fast that this won't work with pure. A function
that's marked with pure cannot access any global, mutable
state. It can only access what's passed to it
On 05/21/2016 12:42 PM, chmike wrote:
Rebindable!Info x1, x2 = Infos.one;
Rebindable!(immutable Info) x1, x2 = Infos.one;
On Saturday, 21 May 2016 at 14:39:59 UTC, pineapple wrote:
void clean(in void delegate(in T value) func){
this.clean((in T values[]) => {
foreach(value; values) func(value);
});
This doesn't do what you think it does. It passes a lambda that
*returns* that
On Saturday, 21 May 2016 at 09:43:38 UTC, Saurabh Das wrote:
I see that 'cent' and 'ucent' are reserved for future use but
not yet implemented. Does anyone have a working implementation
of these types?
Alternatively, is there an any effort towards implementation of
arbitrary-sized integers
On 05/21/2016 03:36 PM, chmike wrote:
Note however that it doesn't work with immutable. It only works with
constant. I guess this is because immutable is "stronger" than const. I
determined that only const was supported by looking at Rebindable's code.
Here is the code that finally works as I
On Saturday, 21 May 2016 at 08:24:19 UTC, Ali Çehreli wrote:
On 05/21/2016 01:07 AM, chmike wrote:
> Unfortunately it is not possible to write this
>
> import std.typecons;
> class Info{...}
> rebindable!Info x;
You have a capitalization typo. Rebindable is a type template,
rebindable is a
This thread is a followup of
https://forum.dlang.org/post/vuljzyufphsywzevu...@forum.dlang.org
with a refocused subject and question.
I'm looking for a mutable reference to a none mutable object to
implement the flyweight pattern. It is for a library and its user
interface. So I'm not
On 05/21/2016 02:17 PM, chmike wrote:
On Saturday, 21 May 2016 at 10:42:13 UTC, chmike wrote:
source/app.d(23,27): Error: cannot implicitly convert expression (one)
of type immutable(Obj) to app.Info
Apparently Rebindable doesn't support polymorphism. This is hopefully
fixable.
No, the
I wrote a pair of methods that looked like this:
void clean(in void delegate(in T value) func){
this.clean((in T values[]) => {
foreach(value; values) func(value);
});
}
void clean(in void delegate(in T values[]) func){
...
}
I was getting a
On 05/21/2016 04:39 PM, pineapple wrote:
But I don't understand why. Could someone clarify the difference between
the two?
Common mistake, because other languages (e.g. C#) use similar but
different syntax.
The `foo => bar` syntax doesn't use braces. When you add braces around
bar, that's
I see that 'cent' and 'ucent' are reserved for future use but not
yet implemented. Does anyone have a working implementation of
these types?
Alternatively, is there an any effort towards implementation of
arbitrary-sized integers in Phobos?
Thanks,
Saurabh
On Saturday, May 21, 2016 07:00:43 ciechowoj via Digitalmars-d-learn wrote:
> On Saturday, 21 May 2016 at 00:39:21 UTC, Jonathan M Davis wrote:
> > Well, if you actually tried marking functions with pure, you'd
> > see pretty fast that this won't work with pure. A function
> > that's marked with
On Saturday, 21 May 2016 at 13:17:11 UTC, ag0aep6g wrote:
On 05/21/2016 12:42 PM, chmike wrote:
Rebindable!Info x1, x2 = Infos.one;
Rebindable!(immutable Info) x1, x2 = Infos.one;
Indeed. Thanks. Reading the unit tests in the source code and the
implementation of Rebindable helped.
On Saturday, 21 May 2016 at 16:01:26 UTC, Stefan Koch wrote:
On Saturday, 21 May 2016 at 15:53:18 UTC, David wrote:
Hi,
I want to try to create a game using D. I'm a complete newbie
though (other than having C/C++ experience). Where would I
start? Does D have an openGL binding? I am assuming
Thanks Vit, Meta, and Yuxuan for your speedy help!
So 3 pieces to put together, function, const, and @property (and
i guess final for protection against subclasses).
On Saturday, 21 May 2016 at 18:33:53 UTC, Anonymouse wrote:
On Saturday, 21 May 2016 at 18:10:55 UTC, captain_fid wrote:
Please forgive if asked before. My google skills seemed to
fail me and didn't see any result from search.
My problem is simple (though not my understanding LOL).
struct D
On Saturday, May 21, 2016 09:43:38 Saurabh Das via Digitalmars-d-learn wrote:
> I see that 'cent' and 'ucent' are reserved for future use but not
> yet implemented. Does anyone have a working implementation of
> these types?
The keywords are reserved for future use not in current use. So, no,
On Saturday, May 21, 2016 17:15:16 Jack Applegame via Digitalmars-d-learn
wrote:
> On Friday, 20 May 2016 at 20:46:18 UTC, Jonathan M Davis wrote:
> > Casting away const and mutating is undefined behavior in D. No
> > D program should ever do it.
>
> Really? Mutating immutable is UB too, but look
Hi there. I'm a beginners, so my questions could be silly.
double x1 = 7.0;
double x2 = 3.0;
writeln(x1 / x2);
from this code i get:
2.3
this is ok but how can i get more digits? For example:
2.3.
thx :-)
On Saturday, 21 May 2016 at 21:40:36 UTC, Era Scarecrow wrote:
On Saturday, 21 May 2016 at 21:21:31 UTC, chaseratx wrote:
I'm learning D and I have a basic question.
I'm trying to write stderr to a file using open() (rather than
shell piping/redirection). It works for stdout but doesn't
On Saturday, 21 May 2016 at 15:53:18 UTC, David wrote:
Hi,
I want to try to create a game using D. I'm a complete newbie
though (other than having C/C++ experience). Where would I
start? Does D have an openGL binding? I am assuming I'll need
to leverage a good amount C APIs? Any list of
On Saturday, 21 May 2016 at 10:42:13 UTC, chmike wrote:
switch(x1)
{
case Infos.one: writeln("case Infos.one"); break;
default: writeln("default"); break;
}
You can generate fairly unique ids and use them in switch
statements like this: https://dpaste.dzfl.pl/873b5b4cf71e
On Saturday, 21 May 2016 at 15:53:18 UTC, David wrote:
Hi,
I want to try to create a game using D. I'm a complete newbie
though (other than having C/C++ experience). Where would I
start? Does D have an openGL binding? I am assuming I'll need
to leverage a good amount C APIs? Any list of
On Saturday, 21 May 2016 at 18:31:46 UTC, vit wrote:
On Saturday, 21 May 2016 at 18:10:55 UTC, captain_fid wrote:
Please forgive if asked before. My google skills seemed to
fail me and didn't see any result from search.
My problem is simple (though not my understanding LOL).
struct D {
On Saturday, 21 May 2016 at 21:21:31 UTC, chaseratx wrote:
I'm learning D and I have a basic question.
I'm trying to write stderr to a file using open() (rather than
shell piping/redirection). It works for stdout but doesn't
seem to work with stderr.
http://pastebin.com/KgzR9wAF
stdout is
On Thursday, 19 May 2016 at 06:20:24 UTC, Nikolay wrote:
You can look to my experement (see iarray.d):
https://bitbucket.org/sibnick/inplacearray.git
Thanks!
I'm learning D and I have a basic question.
I'm trying to write stderr to a file using open() (rather than
shell piping/redirection). It works for stdout but doesn't seem
to work with stderr.
http://pastebin.com/KgzR9wAF
stdout is written to the file, but stderr is not and outputs to
the
Hi,
I want to try to create a game using D. I'm a complete newbie
though (other than having C/C++ experience). Where would I start?
Does D have an openGL binding? I am assuming I'll need to
leverage a good amount C APIs? Any list of these that would be
useful it a game setting?
Obviously
On Saturday, 21 May 2016 at 15:53:18 UTC, David wrote:
Hi,
I want to try to create a game using D. I'm a complete newbie
though (other than having C/C++ experience). Where would I
start? Does D have an openGL binding? I am assuming I'll need
to leverage a good amount C APIs? Any list of
On Saturday, 21 May 2016 at 17:32:47 UTC, dan wrote:
Is it possible to have a class which has a variable which can
be seen from the outside, but which can only be modified from
the inside?
Something like:
class C {
int my_var = 3; // semi_const??
void do_something() { my_var = 4; }
}
On Saturday, 21 May 2016 at 17:32:47 UTC, dan wrote:
Is it possible to have a class which has a variable which can
be seen from the outside, but which can only be modified from
the inside?
Something like:
class C {
int my_var = 3; // semi_const??
void do_something() { my_var = 4; }
}
On Saturday, 21 May 2016 at 17:32:47 UTC, dan wrote:
Is it possible to have a class which has a variable which can
be seen from the outside, but which can only be modified from
the inside?
Something like:
class C {
int my_var = 3; // semi_const??
void do_something() { my_var = 4; }
}
On Saturday, 21 May 2016 at 13:36:02 UTC, chmike wrote:
static Info one()
{
static auto x = Info(new Obj("I'm one"));
return x;
}
static Info two()
{
static auto x = Info(new Obj("I'm two"));
return x;
}
FYI those are thread local
On Friday, 20 May 2016 at 20:46:18 UTC, Jonathan M Davis wrote:
Casting away const and mutating is undefined behavior in D. No
D program should ever do it.
Really? Mutating immutable is UB too, but look at
std.typecons.Rebindable.
Is it possible to have a class which has a variable which can be
seen from the outside, but which can only be modified from the
inside?
Something like:
class C {
int my_var = 3; // semi_const??
void do_something() { my_var = 4; }
}
And then in another file
auto c = new C();
c.my_var
Please forgive if asked before. My google skills seemed to fail
me and didn't see any result from search.
My problem is simple (though not my understanding LOL).
struct D {
int value;
bool opEquals()(bool value) const { return (value ==
value); }
}
D aD;
if (aD == 1) { // OK
}
On Saturday, 21 May 2016 at 18:10:55 UTC, captain_fid wrote:
Please forgive if asked before. My google skills seemed to fail
me and didn't see any result from search.
My problem is simple (though not my understanding LOL).
struct D {
int value;
bool opEquals()(bool value) const {
On Saturday, 21 May 2016 at 18:10:55 UTC, captain_fid wrote:
Please forgive if asked before. My google skills seemed to fail
me and didn't see any result from search.
My problem is simple (though not my understanding LOL).
struct D {
int value;
bool opEquals()(bool value) const {
On Saturday, 21 May 2016 at 10:42:13 UTC, chmike wrote:
source/app.d(23,27): Error: cannot implicitly convert
expression (one) of type immutable(Obj) to app.Info
Apparently Rebindable doesn't support polymorphism. This is
hopefully fixable.
source/app.d(43,5): Error: 'x1' must be of
On Saturday, 21 May 2016 at 21:54:43 UTC, Era Scarecrow wrote:
On Saturday, 21 May 2016 at 21:47:20 UTC, chaseratx wrote:
Thanks Era, but I am not trying to fix the range error. That
was put there intentionally to create stderr output.
I wonder, this sounds like a TLS (Thread Local Storage)
On 05/21/2016 12:56 PM, captain_fid wrote:
> On Saturday, 21 May 2016 at 18:33:53 UTC, Anonymouse wrote:
>> On Saturday, 21 May 2016 at 18:10:55 UTC, captain_fid wrote:
>>> Please forgive if asked before. My google skills seemed to fail me
>>> and didn't see any result from search.
>>>
>>> My
On Saturday, 21 May 2016 at 21:47:20 UTC, chaseratx wrote:
Thanks Era, but I am not trying to fix the range error. That
was put there intentionally to create stderr output. I'm
trying to figure out how to get ALL stderr output directed to a
file the same as if I had used a "2>error.log"
On 05/21/2016 07:15 PM, Jack Applegame wrote:
Really? Mutating immutable is UB too, but look at std.typecons.Rebindable.
Rebindable uses a union of a mutable and an immutable variant of the
type. No access to the mutable union member is provided, and it's never
dereferenced by Rebindable.
On Saturday, 21 May 2016 at 21:51:34 UTC, Jonathan M Davis wrote:
On Saturday, May 21, 2016 09:43:38 Saurabh Das via
Digitalmars-d-learn wrote:
I see that 'cent' and 'ucent' are reserved for future use but
not yet implemented. Does anyone have a working implementation
of these types?
The
On Saturday, 21 May 2016 at 21:54:43 UTC, Era Scarecrow wrote:
On Saturday, 21 May 2016 at 21:47:20 UTC, chaseratx wrote:
Thanks Era, but I am not trying to fix the range error. That
was put there intentionally to create stderr output. I'm
trying to figure out how to get ALL stderr output
On Saturday, 21 May 2016 at 22:08:15 UTC, Era Scarecrow wrote:
On Saturday, 21 May 2016 at 21:54:43 UTC, Era Scarecrow wrote:
On Saturday, 21 May 2016 at 21:47:20 UTC, chaseratx wrote:
Thanks Era, but I am not trying to fix the range error. That
was put there intentionally to create stderr
On Saturday, 21 May 2016 at 21:45:19 UTC, Rygel wrote:
Hi there. I'm a beginners, so my questions could be silly.
double x1 = 7.0;
double x2 = 3.0;
writeln(x1 / x2);
this is ok but how can i get more digits? For example:
2.3.
I'm not sure how to globally
On 05/21/2016 02:45 PM, Rygel wrote:
> Hi there. I'm a beginners, so my questions could be silly.
>
> double x1 = 7.0;
> double x2 = 3.0;
> writeln(x1 / x2);
>
> from this code i get:
>
> 2.3
>
> this is ok but how can i get more digits? For example:
>
> 2.3.
>
>
Ah, ok, got it. thx you all.
On Sunday, 22 May 2016 at 03:06:44 UTC, Mike Parker wrote:
As for 'const' and '@property', neither is strictly a
requirement to implement this idiom. Adding const means that
Oh, and the same holds true for final, of course. It's probably
what you want most of the time, but it isn't strictly
I have an idea for something. I know I can't be the only one to
think this way but I can't find very much information on it.
Basically, I want compile-time enforcement of semantic rules.
For one example--I asked previously here--if it was possible to
generate a compile-time warning or error
On Saturday, 21 May 2016 at 22:11:30 UTC, chaseratx wrote:
On Saturday, 21 May 2016 at 22:08:15 UTC, Era Scarecrow wrote:
On Saturday, 21 May 2016 at 21:54:43 UTC, Era Scarecrow wrote:
On Saturday, 21 May 2016 at 21:47:20 UTC, chaseratx wrote:
Thanks Era, but I am not trying to fix the range
On Saturday, 21 May 2016 at 19:17:00 UTC, dan wrote:
Thanks Vit, Meta, and Yuxuan for your speedy help!
So 3 pieces to put together, function, const, and @property
(and i guess final for protection against subclasses).
Minimally, there are two pieces to this: a private member
variable and a
61 matches
Mail list logo