I wouldn't have thought of "this" representing an lvalue. However, the
following absurdity compiles and executes flawlessly. Just don't
uncomment the assignment to y.i!
class Yikes
{
int i;
this() { this = null; }
}
void main()
{
auto y = new Yikes();
// y.i = 0;
}
Is this a
JMRyan:
> Is this a bug in the compiler (v.2.047)? Am I missing something in
> thinking it shouldn't be?
I think it's not a bug. It's not a common need, but a method may way want to
swap this with another. In Phobos this is done on a struct, see:
http://www.dsource.org/projects/phobos/browser/t
On Friday 03 September 2010 13:22:51 JMRyan wrote:
> I wouldn't have thought of "this" representing an lvalue. However, the
> following absurdity compiles and executes flawlessly. Just don't
> uncomment the assignment to y.i!
>
> class Yikes
> {
> int i;
> this() { this = null; }
> }
>
On 9/3/10 16:03 CDT, bearophile wrote:
JMRyan:
Is this a bug in the compiler (v.2.047)? Am I missing something in
thinking it shouldn't be?
I think it's not a bug. It's not a common need, but a method may way want to
swap this with another. In Phobos this is done on a struct, see:
http://www
On Friday 03 September 2010 14:22:46 Andrei Alexandrescu wrote:
> On 9/3/10 16:03 CDT, bearophile wrote:
> > JMRyan:
> >> Is this a bug in the compiler (v.2.047)? Am I missing something in
> >> thinking it shouldn't be?
> >
> > I think it's not a bug. It's not a common need, but a method may way
On 9/3/10 16:33 CDT, Jonathan M Davis wrote:
Still, I don't know how you could make it a true rvalue.
It's very simple - make "this" the result of a hypothetical function call.
Andrei
On Friday 03 September 2010 14:38:27 Andrei Alexandrescu wrote:
> On 9/3/10 16:33 CDT, Jonathan M Davis wrote:
> > Still, I don't know how you could make it a true rvalue.
>
> It's very simple - make "this" the result of a hypothetical function call.
>
> Andrei
Ah, that would do it. Though you w
Andrei Alexandrescu:
> For classes this must be an rvalue.
OK. Why?
Bye,
bearophile
On 9/3/10 17:16 CDT, bearophile wrote:
Andrei Alexandrescu:
For classes this must be an rvalue.
OK. Why?
If you could change this from within a method you'd pretty much ruin
everything about object orientation.
Andrei
On Friday 03 September 2010 15:18:25 Andrei Alexandrescu wrote:
> On 9/3/10 17:16 CDT, bearophile wrote:
> > Andrei Alexandrescu:
> >> For classes this must be an rvalue.
> >
> > OK. Why?
>
> If you could change this from within a method you'd pretty much ruin
> everything about object orientatio
On Sep 4, 10 05:22, Andrei Alexandrescu wrote:
On 9/3/10 16:03 CDT, bearophile wrote:
JMRyan:
Is this a bug in the compiler (v.2.047)? Am I missing something in
thinking it shouldn't be?
I think it's not a bug. It's not a common need, but a method may way
want to swap this with another. In Ph
On Saturday 04 September 2010 01:32:03 KennyTM~ wrote:
> On Sep 4, 10 05:22, Andrei Alexandrescu wrote:
> > On 9/3/10 16:03 CDT, bearophile wrote:
> >> JMRyan:
> >>> Is this a bug in the compiler (v.2.047)? Am I missing something in
> >>> thinking it shouldn't be?
> >>
> >> I think it's not a bug.
On 9/4/10 3:32 CDT, KennyTM~ wrote:
On Sep 4, 10 05:22, Andrei Alexandrescu wrote:
On 9/3/10 16:03 CDT, bearophile wrote:
JMRyan:
Is this a bug in the compiler (v.2.047)? Am I missing something in
thinking it shouldn't be?
I think it's not a bug. It's not a common need, but a method may way
On 09/04/2010 10:41 AM, Steven Schveighoffer wrote:
Andrei Alexandrescu Wrote:
On 9/3/10 16:03 CDT, bearophile wrote:
JMRyan:
Is this a bug in the compiler (v.2.047)? Am I missing something in
thinking it shouldn't be?
I think it's not a bug. It's not a common need, but a method may way wa
Andrei Alexandrescu Wrote:
> On 9/3/10 16:03 CDT, bearophile wrote:
> > JMRyan:
> >> Is this a bug in the compiler (v.2.047)? Am I missing something in
> >> thinking it shouldn't be?
> >
> > I think it's not a bug. It's not a common need, but a method may way want
> > to swap this with another.
Andrei Alexandrescu wrote in
news:i5rovm$1q4...@digitalmars.com:
>
> For classes this must be an rvalue.
>
> Andrei
I reported this as issue 4819.
Does this mean assigning to fields won't be an option anymore when using this?
E.g.:
class Foo
{
int x;
int y;
void changeXY(int x, int y)
{
this.x = x;
this.y = y;
}
}
On Sun, Sep 5, 2010 at 6:09 PM, JMRyan wrote:
> Andrei Alexandrescu wrote in
> news:i5ro
Gmail likes to eat my code for some reason, it just ate two closing
parantheses.. lol.
On Mon, Sep 6, 2010 at 12:02 AM, Andrej Mitrovic
wrote:
> Does this mean assigning to fields won't be an option anymore when using this?
>
> E.g.:
>
> class Foo
> {
> int x;
> int y;
>
> void changeXY(
On Sunday 05 September 2010 15:02:10 Andrej Mitrovic wrote:
> Does this mean assigning to fields won't be an option anymore when using
> this?
>
> E.g.:
>
> class Foo
> {
> int x;
> int y;
>
> void changeXY(int x, int y)
> {
> this.x = x;
> this.y = y;
> }
> }
Ok, thanks. I never liked the "lvalue rvalue" names.. For example
http://en.wikipedia.org/wiki/Value_%28computer_science%29
l-value, non-lvalue, rvalue, nonlvalue.. bleh. It's the same thing as
when I see "mutable, non-immutable, non-mutable, immutable" sprinkled
with a few tripple negatives all a
On 09/05/2010 05:02 PM, Andrej Mitrovic wrote:
Does this mean assigning to fields won't be an option anymore when using this?
E.g.:
class Foo
{
int x;
int y;
void changeXY(int x, int y)
{
this.x = x;
this.y = y;
}
}
No, guys, most everything will be
Andrei:
> If you can write (new Foo).x = x, then you can also write this.x = x. Try it
> now!
See my bug reports/enhancement requests (about three days ago in a program of
mine I have added a bug that enhancement 4407 is able to avoid):
Arguments and attributes with the same name
http://d.purem
++ on that bug report.
On a similar note, today I was rewriting a dsource class example
because I wanted to show that you can use "this.name" to assign to
fields that have the same name as a parameter. And then I accidentally
made this mistake when writing a different method:
class Foo
{
stri
Andrej Mitrovic:
> ++ on that bug report.
Then vote for it :-)
Bye,
bearophile
Done. I only have 5 votes left though.
This is no democracy!! :p
On Mon, Sep 6, 2010 at 12:58 PM, bearophile wrote:
> Andrej Mitrovic:
>> ++ on that bug report.
>
> Then vote for it :-)
>
> Bye,
> bearophile
>
25 matches
Mail list logo