On Monday, May 23, 2016 14:08:43 Jack Applegame via Digitalmars-d-learn wrote:
> On Monday, 23 May 2016 at 11:05:34 UTC, Jonathan M Davis wrote:
> > I don't know why you think that D violates its own rules
> > frequently though. It's not perfect, but it usually does follow
> > its own rules - and w
On Monday, 23 May 2016 at 11:05:34 UTC, Jonathan M Davis wrote:
I don't know why you think that D violates its own rules
frequently though. It's not perfect, but it usually does follow
its own rules - and when it doesn't, we fix it (though not
always as quickly as would be ideal).
The most PITA
On Monday, May 23, 2016 08:19:52 Jack Applegame via Digitalmars-d-learn wrote:
> On Sunday, 22 May 2016 at 13:08:19 UTC, Jonathan M Davis wrote:
> > Given how const and immutable work in D, having any portion of
> > them be treated as mutable, becomes highly problematic. It
> > could theoretically
On Sunday, 22 May 2016 at 13:08:19 UTC, Jonathan M Davis wrote:
Given how const and immutable work in D, having any portion of
them be treated as mutable, becomes highly problematic. It
could theoretically be done by having to mark such variables
with an attribute and mark such types with a sim
validity checking. I had the impression that this is the
principle used for the pure keyword.
I would vote against the introduction of the mutable keyword as
it exist in C++ because it is a half backed solution. First it
tells the compiler that this variable is modifiable at any time
by any
On Sunday, May 22, 2016 09:42:54 Jack Applegame via Digitalmars-d-learn wrote:
> On Saturday, 21 May 2016 at 21:49:23 UTC, Jonathan M Davis wrote:
> > Rebindable is in kind of a weird grey area. It involves a
> > union, not casting, and it's only ever mutating the class
> > reference, not the objec
On Sunday, 22 May 2016 at 09:42:54 UTC, Jack Applegame wrote:
I agree. But I think we need something that allows *logical*
const and immutable.
Strict binding constness to physical memory constancy is not
always necessary and sometimes even harmful.
http://wiki.dlang.org/DIP89
On Saturday, 21 May 2016 at 21:49:23 UTC, Jonathan M Davis wrote:
Rebindable is in kind of a weird grey area. It involves a
union, not casting, and it's only ever mutating the class
reference, not the object itself. Certainly, if it mutated the
object, it would be undefined behavior, but it's j
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.
A
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
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.
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 pu
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 (th
On Friday, May 20, 2016 21:35:27 ciechowoj via Digitalmars-d-learn wrote:
> On Friday, 20 May 2016 at 20:45:05 UTC, Jonathan M Davis wrote:
> > If you want something that's ref-counted and works in pure
> > code, const will _not_ work, because you can't legally alter
> > the ref-count.
>
> What abo
On Friday, 20 May 2016 at 20:45:05 UTC, Jonathan M Davis wrote:
If you want something that's ref-counted and works in pure
code, const will _not_ work, because you can't legally alter
the ref-count.
What about something like this (ignoring multi-threading issues):
struct RefCountPool {
siz
On Friday, May 20, 2016 19:33:49 Johan Engelen via Digitalmars-d-learn wrote:
> On Thursday, 19 May 2016 at 23:21:14 UTC, Jonathan M Davis wrote:
> > No. D's const and immutable provide no backdoors. Rather, they
> > provide strong guarantees. So, if a variable is const, then it
> > cannot be mutat
On Friday, May 20, 2016 18:23:26 Jack Applegame via Digitalmars-d-learn wrote:
> On Friday, 20 May 2016 at 17:28:55 UTC, Namespace wrote:
> > But you can cheat:
> You can just cast const away:
> struct A {
> int id = 0;
>
> this(int id) {
> this.id = id;
> }
>
> void change() const {
On Friday, May 20, 2016 18:41:04 ciechowoj via Digitalmars-d-learn wrote:
> On Thursday, 19 May 2016 at 23:21:14 UTC, Jonathan M Davis wrote:
> > On Thursday, May 19, 2016 20:44:54 ciechowoj via
> >
> > Digitalmars-d-learn wrote:
> >> Is there D equivalent of C++
On Thursday, 19 May 2016 at 23:21:14 UTC, Jonathan M Davis wrote:
No. D's const and immutable provide no backdoors. Rather, they
provide strong guarantees. So, if a variable is const, then it
cannot be mutated (even internally) except via a mutable
reference to the same data.
The "even inte
On Friday, 20 May 2016 at 18:42:44 UTC, Ali Çehreli wrote:
On 05/20/2016 10:28 AM, Namespace wrote:
> On Thursday, 19 May 2016 at 23:21:14 UTC, Jonathan M Davis
wrote:
>> On Thursday, May 19, 2016 20:44:54 ciechowoj via
Digitalmars-d-learn
>> wrote:
>>> Is there D equ
On Friday, 20 May 2016 at 18:23:26 UTC, Jack Applegame wrote:
On Friday, 20 May 2016 at 17:28:55 UTC, Namespace wrote:
But you can cheat:
You can just cast const away:
struct A {
int id = 0;
this(int id) {
this.id = id;
}
void ch
On 05/20/2016 10:28 AM, Namespace wrote:
> On Thursday, 19 May 2016 at 23:21:14 UTC, Jonathan M Davis wrote:
>> On Thursday, May 19, 2016 20:44:54 ciechowoj via Digitalmars-d-learn
>> wrote:
>>> Is there D equivalent of C++'s mutable keyword? Like the one that
&g
On Thursday, 19 May 2016 at 23:21:14 UTC, Jonathan M Davis wrote:
On Thursday, May 19, 2016 20:44:54 ciechowoj via
Digitalmars-d-learn wrote:
Is there D equivalent of C++'s mutable keyword? Like the one
that allows to modify a field of struct from constant method.
Or some alternative sol
On 05/20/2016 08:23 PM, Jack Applegame wrote:
You can just cast const away:
struct A {
int id = 0;
this(int id) {
this.id = id;
}
void change() const {
(cast() id)++;
}
}
That's not a valid D program, though.
On Friday, 20 May 2016 at 17:28:55 UTC, Namespace wrote:
But you can cheat:
You can just cast const away:
struct A {
int id = 0;
this(int id) {
this.id = id;
}
void change() const {
(cast() id)++;
}
}
void
On Thursday, 19 May 2016 at 23:21:14 UTC, Jonathan M Davis wrote:
On Thursday, May 19, 2016 20:44:54 ciechowoj via
Digitalmars-d-learn wrote:
Is there D equivalent of C++'s mutable keyword? Like the one
that allows to modify a field of struct from constant method.
Or some alternative sol
On Thursday, May 19, 2016 20:44:54 ciechowoj via Digitalmars-d-learn wrote:
> Is there D equivalent of C++'s mutable keyword? Like the one that
> allows to modify a field of struct from constant method. Or some
> alternative solution?
No. D's const and immutable provide no back
On Thursday, 19 May 2016 at 20:44:54 UTC, ciechowoj wrote:
Is there D equivalent of C++'s mutable keyword? Like the one
that allows to modify a field of struct from constant method.
Or some alternative solution?
A little personal experience. I wrote a tool that had certain
flags tha
On Thursday, 19 May 2016 at 20:44:54 UTC, ciechowoj wrote:
Is there D equivalent of C++'s mutable keyword? Like the one
that allows to modify a field of struct from constant method.
Or some alternative solution?
There isn't an equivalent of mutable keyword because D const
diff
Is there D equivalent of C++'s mutable keyword? Like the one that
allows to modify a field of struct from constant method. Or some
alternative solution?
30 matches
Mail list logo