In C and C++ you often use bitfields to control devices with memory
mapped hardware control and data words. So for example:
typedef struct some_device {
unsigned int flob: 3;
unsigned int adob: 2;
unsigned int: 3;
unsigned int data: 8;
} some_device;
Clearly D has no bitfields. I
On Wednesday, 14 June 2017 at 08:10:57 UTC, Russel Winder wrote:
but the bitfields mixin template appears to do more than add
all the bit twiddling functions to emulate the bitfields. This
would appear a priori to not allow for actual memory mapped
devices using it, or am I missing something?
On 06/14/2017 03:47 AM, Steven Schveighoffer wrote:
The fundamental difference is that const and immutable share a
characteristic that mutable doesn't -- you can't mutate the data.
(... through the reference at hand.)
const and mutable share this: The data may be mutated from elsewhere.
Mutab
Why doesn't this work? The Test!Duck type has a void quack()
method but the compiler says it is not implemented.
import std.stdio;
interface IDuck
{
void quack();
}
class Test(T) : IDuck
{
T data;
alias data this;
}
struct Duck
{
void quack()
{
writeln("Quack");
Balagopal Komarath wrote:
Why doesn't this work? The Test!Duck type has a void quack() method but
the compiler says it is not implemented.
'cause `alias this` is *not* a tool that can be used to emulate
inheritance. no, `quack` is NOT impemented. `alias this` won't
automagically paste the co
https://dpaste.dzfl.pl/b66fffa3bc8d
On 06/14/2017 01:06 PM, drug wrote:
https://dpaste.dzfl.pl/b66fffa3bc8d
It's always a bug when dmd segfaults.
On Wednesday, 14 June 2017 at 09:41:49 UTC, ketmar wrote:
Balagopal Komarath wrote:
Why doesn't this work? The Test!Duck type has a void quack()
method but the compiler says it is not implemented.
'cause `alias this` is *not* a tool that can be used to emulate
inheritance. no, `quack` is NOT
Balagopal Komarath wrote:
On Wednesday, 14 June 2017 at 09:41:49 UTC, ketmar wrote:
Balagopal Komarath wrote:
Why doesn't this work? The Test!Duck type has a void quack() method but
the compiler says it is not implemented.
'cause `alias this` is *not* a tool that can be used to emulate
inh
14.06.2017 14:25, ag0aep6g пишет:
It's always a bug when dmd segfaults.
filed https://issues.dlang.org/show_bug.cgi?id=17502
On Tuesday, 13 June 2017 at 19:29:26 UTC, Gary Willoughby wrote:
Is it possible for the `result` variable in the following code
to be returned as an immutable type if it's created by adding
two immutable types?
Why do you even want that? Such plain data structure is
implicitly convertible to
On Wednesday, 14 June 2017 at 09:41:49 UTC, ketmar wrote:
Balagopal Komarath wrote:
Why doesn't this work? The Test!Duck type has a void quack()
method but the compiler says it is not implemented.
'cause `alias this` is *not* a tool that can be used to emulate
inheritance. no, `quack` is NOT
Mike B Johnson wrote:
I don't think it has to do with pasting code.
d.Quack() is well defined through the alias. Inheritance requires that a
Quack() exists, and it does, through the alias.
The compiler could easily create an implementation wrapper that uses the
alias this.
this is called
On Wednesday, 14 June 2017 at 11:40:02 UTC, ketmar wrote:
interfaces *require* a full-featured class, with VMT, and some
hidden pointers to support hidden interface machinery.
I don't think that is the problem here. The type Test!Duck is a
class and that type is the one implementing the interf
On Wednesday, 14 June 2017 at 12:35:05 UTC, Mike B Johnson wrote:
void main()
{
Test!Duck d;
d.quack();
}
which, unfortunately causes a segmentation fault ;)
I think that is because you are not initializing d using new
Test!Duck();
On 6/14/17 4:10 AM, Russel Winder via Digitalmars-d-learn wrote:
In C and C++ you often use bitfields to control devices with memory
mapped hardware control and data words. So for example:
typedef struct some_device {
unsigned int flob: 3;
unsigned int adob: 2;
unsigned int: 3;
u
On 6/14/17 5:34 AM, Balagopal Komarath wrote:
Why doesn't this work? The Test!Duck type has a void quack() method but
the compiler says it is not implemented.
import std.stdio;
interface IDuck
{
void quack();
}
class Test(T) : IDuck
{
T data;
alias data this;
}
struct Duck
{
v
On Wednesday, 14 June 2017 at 08:10:57 UTC, Russel Winder wrote:
This would appear a priori to not allow for actual memory
mapped devices using it, or am I missing something?
I believe the only case where it might matter is if the device
was sensitive to the read/write size (1/2/4 bytes). Othe
On 2017-06-14 11:04, Rene Zwanenburg wrote:
I've casted void buffers to structs containing bitfields to read
pre-existing binary files, and that worked just fine. I don't see why it
would be different for memory mapped devices. What do yo mean by 'do more'?
This bitfield discussion came up in
Balagopal Komarath wrote:
On Wednesday, 14 June 2017 at 11:40:02 UTC, ketmar wrote:
interfaces *require* a full-featured class, with VMT, and some hidden
pointers to support hidden interface machinery.
I don't think that is the problem here. The type Test!Duck is a class and
that type is the
On Wednesday, 14 June 2017 at 09:34:27 UTC, Balagopal Komarath
wrote:
Why doesn't this work? The Test!Duck type has a void quack()
method but the compiler says it is not implemented.
import std.stdio;
interface IDuck
{
void quack();
}
class Test(T) : IDuck
{
T data;
alias data thi
Why isn't
bool c = a[] == 4;
allowed when
a[] = b[] + 4;
is?
given that
int[] a, b;
On Wednesday, 14 June 2017 at 21:15:32 UTC, Nordlöw wrote:
Why isn't
bool c = a[] == 4;
allowed when
a[] = b[] + 4;
is?
given that
int[] a, b;
That's just how it is. There are a lot of array-wise operations
that *could* be implemented in the language but aren't.
On Wednesday, 14 June 2017 at 21:04:55 UTC, basile b. wrote:
The way to do that in D is with mixins:
That is an interesting solution.
However, my original goal was to figure out whether one can make
struct types behave polymorphically (Which is not mentioned in my
original question). I know
On Wednesday, 14 June 2017 at 22:29:08 UTC, Balagopal Komarath
wrote:
On Wednesday, 14 June 2017 at 21:04:55 UTC, basile b. wrote:
The way to do that in D is with mixins:
That is an interesting solution.
However, my original goal was to figure out whether one can
make struct types behave pol
There are two arrays of string [] mas1, mas2; Size of each about
5M lines. By the size they different, but lines in both match for
95%. It is necessary to find all lines in an array of mas2 which
differ from mas1. The principal criterion - speed. There are the
8th core processor and it is good
26 matches
Mail list logo