Re: Properties

2009-01-08 Thread bearophile
Alexander Pánek: > Guripe. Gripe gripe. GRIPE. Is this the second (redundant) system to vote for the most hated bugs? Bye, bearophile

Re: Properties

2009-01-08 Thread Daniel Keep
bearophile wrote: Alexander Pánek: Guripe. Gripe gripe. GRIPE. Is this the second (redundant) system to vote for the most hated bugs? Bye, bearophile Maybe we need a bot to monitor bugs' GPS [1]. You can never have too many redundant systems, afterall! -- Daniel P.S. Gripe gripe

Re: foreach ... else statement

2009-01-08 Thread Rioshin an'Harthen
"Walter Bright" kirjoitti viestissä news:gk1dag$pt...@digitalmars.com... I keep thinking I should put on a "Compiler Construction" seminar! A net-seminar, please, so that those of us who want to attend actually can.

Re: Optimal struct layout template?

2009-01-08 Thread Don
Andrei Alexandrescu wrote: Don wrote: Denis Koroskin wrote: On Thu, 18 Dec 2008 01:38:32 +0300, Sergey Gromov Thu, 18 Dec 2008 00:21:58 +0300, Denis Koroskin wrote: On Thu, 18 Dec 2008 00:12:18 +0300, Sergey Gromov Tue, 16 Dec 2008 10:09:41 +0100, Don wrote: struct Foo { double, int } // 12

Re: Properties

2009-01-08 Thread Michiel Helvensteijn
dsimcha wrote: > Yeah, this has been mentioned in the past before. The most obvious way to > make it work w/o any breaking or significantly bulk-adding changes would > be to define foo.length += 8 to mean foo = foo.length() + 8, or > foo.length++ mean foo = > foo.length + 1. This would be pure s

Suggestion: module opcall

2009-01-08 Thread bobef
Hello all, I want to suggest adding module opCall to D (to D1 as well please :). Please excuse me if has been suggested before. Something like this: module mymodule.trace; static char[] opCall() { return "whatever"; } module mymodule.main; void main() { mymodule.trace(); } The need for

Re: Properties

2009-01-08 Thread Mike James
Gripe, Gripe, Gripe. Gripe, Gripe, Gripe, Wonderful Gripe...

Re: Properties

2009-01-08 Thread Don
dsimcha wrote: == Quote from BCS (a...@pathlink.com)'s article Reply to Vishaal, Properties, such as array.length, should return lvalues to allow: a.length += 8; or other similar statements. I think there is a (long standing) bug report about that one. Maybe if enough people gripe about it it

Re: Properties

2009-01-08 Thread Nick Sabalausky
"Michiel Helvensteijn" wrote in message news:gk4oi2$14t...@digitalmars.com... > dsimcha wrote: > >> Yeah, this has been mentioned in the past before. The most obvious way >> to >> make it work w/o any breaking or significantly bulk-adding changes would >> be to define foo.length += 8 to mean fo

Re: foreach ... else statement

2009-01-08 Thread Nick Sabalausky
"Rioshin an'Harthen" wrote in message news:gk4kfh$ri...@digitalmars.com... > "Walter Bright" kirjoitti viestissä > news:gk1dag$pt...@digitalmars.com... >> I keep thinking I should put on a "Compiler Construction" seminar! > > A net-seminar, please, so that those of us who want to attend actuall

Re: Properties

2009-01-08 Thread Michiel Helvensteijn
Nick Sabalausky wrote: > 1. Like in C#, you shouldn't need to define paramater lists for "set" and > "get". They're always going to be the same. In the case of "set", it's > always going to be just the one param, and it'll be the new value, so just > make a special predefined var. Something like:

Re: Properties

2009-01-08 Thread Ary Borenszweig
Michiel Helvensteijn wrote: Nick Sabalausky wrote: 1. Like in C#, you shouldn't need to define paramater lists for "set" and "get". They're always going to be the same. In the case of "set", it's always going to be just the one param, and it'll be the new value, so just make a special predefine

Re: Properties

2009-01-08 Thread Michiel Helvensteijn
Ary Borenszweig wrote: >>> get { return this.len; } >>> set { this.len = value; } // "value" (like in C#), or "$" or something >>> like that >> >> I have to disagree. By that logic, we would abolish parameter-names >> altogether and access formal parameters by number. set has a parameter, >> and

Re: Suggestion: module opcall

2009-01-08 Thread bearophile
bobef Wrote: > The need for this is because often a module happens to be named as the > functionality it contains and you have to write the stuff two times.< A design bug in the D1 module system is that when you import foo normally you import in the namespace both the module name and the names i

Re: Properties

2009-01-08 Thread Ary Borenszweig
Michiel Helvensteijn wrote: Ary Borenszweig wrote: get { return this.len; } set { this.len = value; } // "value" (like in C#), or "$" or something like that I have to disagree. By that logic, we would abolish parameter-names altogether and access formal parameters by number. set has a paramete

Re: Properties

2009-01-08 Thread Michiel Helvensteijn
Ary Borenszweig wrote: >>> It's very different. A setter has a very specific meaning: set some >>> value. That's why it's called "value". Another name could be the name of >>> the property ("len") or something like "newLen". Which other name would >>> you use? >> >> It's not for me to say. It sho

Re: Properties

2009-01-08 Thread Chad J
Michiel Helvensteijn wrote: > Nick Sabalausky wrote: > >> 2. You shouldn't have to manually define a private var to go along with >> the property. In languages with real properties, the following idiom is >> used constantly: >> >> private int _var; >> public property int var { >>get { return _

Re: Properties

2009-01-08 Thread Nick Sabalausky
"Michiel Helvensteijn" wrote in message news:gk5b4m$2ek...@digitalmars.com... > Nick Sabalausky wrote: > >> 1. Like in C#, you shouldn't need to define paramater lists for "set" and >> "get". They're always going to be the same. In the case of "set", it's >> always going to be just the one param,

Re: Properties

2009-01-08 Thread Nick Sabalausky
"Michiel Helvensteijn" wrote in message news:gk5f80$2la...@digitalmars.com... > Ary Borenszweig wrote: > It's very different. A setter has a very specific meaning: set some value. That's why it's called "value". Another name could be the name of the property ("len") or someth

Re: Properties

2009-01-08 Thread bearophile
Chad J: > public property int var > { > get { return var; } > set { var = $; } > } > > public property int foo > { > get { return foo; } > set { foo = $; } > } I think I have suggested something similar, time ago. The default situations you have shown may enjoy an even shorter sy

Re: foreach ... else statement

2009-01-08 Thread BCS
Reply to Walter, Robert Fraser wrote: Walter Bright wrote: I keep thinking I should put on a "Compiler Construction" seminar! *cough* NWCPP *cough* I'd like to do a paid one . BTW, Bartosz has graciously offered the Jan NWCPP speaking engagement to me. I'll be talking about mixins and t

Re: Properties

2009-01-08 Thread Nick Sabalausky
"Chad J" wrote in message news:gk5fch$2ld...@digitalmars.com... > Michiel Helvensteijn wrote: >> Nick Sabalausky wrote: >> >>> 2. You shouldn't have to manually define a private var to go along with >>> the property. In languages with real properties, the following idiom is >>> used constantly: >

Re: Properties

2009-01-08 Thread Michiel Helvensteijn
Nick Sabalausky wrote: >> Perhaps the implicit declaration "value" (or whatever *you* would call >> it) inadvertently overshadows a member variable with that name. That >> could result in a bug that would be pretty hard to find. >> > > Overshadowing is already a potential issue anyway, with or wi

Re: Properties

2009-01-08 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:gk5fo7$2m8...@digitalmars.com... > "Michiel Helvensteijn" wrote in message > news:gk5b4m$2ek...@digitalmars.com... >> Nick Sabalausky wrote: >> >>> 1. Like in C#, you shouldn't need to define paramater lists for "set" >>> and >>> "get". They're always go

Re: Properties

2009-01-08 Thread Nick Sabalausky
"bearophile" wrote in message news:gk5grh$2o8...@digitalmars.com... > Chad J: >> public property int var >> { >> get { return var; } >> set { var = $; } >> } >> >> public property int foo >> { >> get { return foo; } >> set { foo = $; } >> } > > I think I have suggested something s

Re: Suggestion: module opcall

2009-01-08 Thread Bill Baxter
On Fri, Jan 9, 2009 at 2:33 AM, bearophile wrote: > bobef Wrote: >> The need for this is because often a module happens to be named as the >> functionality it contains and you have to write the stuff two times.< > > A design bug in the D1 module system is that when you import foo normally you >

Re: Properties

2009-01-08 Thread Nick Sabalausky
"Michiel Helvensteijn" wrote in message news:gk5h9r$2p7...@digitalmars.com... > Nick Sabalausky wrote: > >>> Perhaps the implicit declaration "value" (or whatever *you* would call >>> it) inadvertently overshadows a member variable with that name. That >>> could result in a bug that would be pret

Re: dmd platform support - poll

2009-01-08 Thread K.Wilson
Walter Bright Wrote: > Nick Sabalausky wrote: > > I guess there was confusion about DMD support for a particular host > > platform > > vs a particular target platform. If DMD does't even run or work correctly > > on > > 64-bit machines, even in 32-bit mode, (I don't know, as I don't use them)

Re: dmd platform support - poll

2009-01-08 Thread K.Wilson
Walter Bright Wrote: > Nick Sabalausky wrote: > > I guess there was confusion about DMD support for a particular host > > platform > > vs a particular target platform. If DMD does't even run or work correctly > > on > > 64-bit machines, even in 32-bit mode, (I don't know, as I don't use them)

Re: Optimal struct layout template?

2009-01-08 Thread Robert Fraser
Don wrote: Andrei Alexandrescu wrote: Don wrote: Denis Koroskin wrote: On Thu, 18 Dec 2008 01:38:32 +0300, Sergey Gromov Thu, 18 Dec 2008 00:21:58 +0300, Denis Koroskin wrote: On Thu, 18 Dec 2008 00:12:18 +0300, Sergey Gromov Tue, 16 Dec 2008 10:09:41 +0100, Don wrote: struct Foo { double,

Re: Properties

2009-01-08 Thread Chad J
Nick Sabalausky wrote: > It's a DRY violation. I agree, good call.

Re: Properties

2009-01-08 Thread Yigal Chripun
Nick Sabalausky wrote: "bearophile" wrote in message news:gk5grh$2o8...@digitalmars.com... Chad J: public property int var { get { return var; } set { var = $; } } public property int foo { get { return foo; } set { foo = $; } } I think I have suggested something similar,

Re: Properties

2009-01-08 Thread Nick Sabalausky
"Yigal Chripun" wrote in message news:gk5t92$fu...@digitalmars.com... > Nick Sabalausky wrote: >> "bearophile" wrote in message >> news:gk5grh$2o8...@digitalmars.com... >>> Chad J: public property int var { get { return var; } set { var = $; } } publi

Re: Optimal struct layout template?

2009-01-08 Thread Andrei Alexandrescu
Don wrote: Andrei Alexandrescu wrote: Don wrote: Denis Koroskin wrote: On Thu, 18 Dec 2008 01:38:32 +0300, Sergey Gromov Thu, 18 Dec 2008 00:21:58 +0300, Denis Koroskin wrote: On Thu, 18 Dec 2008 00:12:18 +0300, Sergey Gromov Tue, 16 Dec 2008 10:09:41 +0100, Don wrote: struct Foo { double,

Re: foreach ... else statement

2009-01-08 Thread Walter Bright
BCS wrote: Reply to Walter, Robert Fraser wrote: Walter Bright wrote: I keep thinking I should put on a "Compiler Construction" seminar! *cough* NWCPP *cough* I'd like to do a paid one . BTW, Bartosz has graciously offered the Jan NWCPP speaking engagement to me. I'll be talking about

Re: foreach ... else statement

2009-01-08 Thread Walter Bright
Nick Sabalausky wrote: "Rioshin an'Harthen" wrote in message news:gk4kfh$ri...@digitalmars.com... "Walter Bright" kirjoitti viestissä news:gk1dag$pt...@digitalmars.com... I keep thinking I should put on a "Compiler Construction" seminar! A net-seminar, please, so that those of us who want to

Re: Properties

2009-01-08 Thread Miles
Nick Sabalausky wrote: > A property setter is ALWAYS going to return nothing and Both the getter and the setter should return an rvalue. Properties exist so that they are interchangeable with real member variables. Something that is possible with member variables MUST also be possible with propert

Re: Suggestion: module opcall

2009-01-08 Thread bearophile
Bill Baxter: >I think this problem you refer to only applies to modules without package >names. I.e. "module Foo" containing "class Foo". Things seem to work ok if >you have "module x.Foo" with "class Foo" inside.< Right. But why settle with a half-backed module system when there are more lo

Re: Properties

2009-01-08 Thread Miles
Chad J wrote: > I actually like the idea. > > (...) > > int nTimesVarRead = 0; > > public property int var > { > get > { > nTimesVarRead++; > return internalValue; > } > > set { internalValue = $; } > } That defeats one of the purposes of properties. A property

Re: Properties

2009-01-08 Thread Bill Baxter
On Fri, Jan 9, 2009 at 9:59 AM, Miles <...@___.> wrote: > Nick Sabalausky wrote: >> A property setter is ALWAYS going to return nothing and > > Both the getter and the setter should return an rvalue. Properties exist > so that they are interchangeable with real member variables. Partly

Re: Suggestion: module opcall

2009-01-08 Thread Bill Baxter
On Fri, Jan 9, 2009 at 10:23 AM, bearophile wrote: > Bill Baxter: > >>I think this problem you refer to only applies to modules without package >>names. I.e. "module Foo" containing "class Foo". Things seem to work ok if >>you have "module x.Foo" with "class Foo" inside.< > > Right. But why se

Re: Properties

2009-01-08 Thread Nick Sabalausky
"Miles" <...@___.> wrote in message news:gk67hr$17d...@digitalmars.com... > Nick Sabalausky wrote: >> A property setter is ALWAYS going to return nothing and > > Both the getter and the setter should return an rvalue. Properties exist > so that they are interchangeable with real member

Re: Properties

2009-01-08 Thread Nick Sabalausky
"Bill Baxter" wrote in message news:mailman.343.1231465331.22690.digitalmar...@puremagic.com... > On Fri, Jan 9, 2009 at 9:59 AM, Miles <...@___.> wrote: >> Nick Sabalausky wrote: >>> A property setter is ALWAYS going to return nothing and >> >> Both the getter and the setter should r

Re: Properties

2009-01-08 Thread Bill Baxter
On Fri, Jan 9, 2009 at 10:58 AM, Nick Sabalausky wrote: > "Bill Baxter" wrote in message > news:mailman.343.1231465331.22690.digitalmar...@puremagic.com... >> On Fri, Jan 9, 2009 at 9:59 AM, Miles <...@___.> wrote: >>> Nick Sabalausky wrote: A property setter is ALWAYS going to r

Re: Properties

2009-01-08 Thread Miles
Bill Baxter wrote: > On Fri, Jan 9, 2009 at 9:59 AM, Miles <...@___.> wrote: >> Both the getter and the setter should return an rvalue. Properties exist >> so that they are interchangeable with real member variables. > > Partly, but also properties exist to provide encapsulation of pri

Re: Properties

2009-01-08 Thread Bill Baxter
On Fri, Jan 9, 2009 at 11:01 AM, Miles <...@___.> wrote: > Bill Baxter wrote: >> On Fri, Jan 9, 2009 at 9:59 AM, Miles <...@___.> wrote: >>> Both the getter and the setter should return an rvalue. Properties exist >>> so that they are interchangeable with real member variabl

Why isn't ++x an lvalue in D?

2009-01-08 Thread Bill Baxter
Another thread just reminded me of something I use frequently in C++ that doesn't work in D because ++x is not an lvalue: int x,N; ... ++x %= N; So is there some deep reason for not making it an lvalue like in C++? --bb

Re: Properties

2009-01-08 Thread Miles
Nick Sabalausky wrote: > True, but my main point was, however the language ends up handling the > details of property getters/setters, it's not going to be as general as > ordinary functions, and thus certain aspects of the syntax can/should be > simplified. In this case, simplifying would be m

Re: Properties

2009-01-08 Thread Nick Sabalausky
"Miles" <...@___.> wrote in message news:gk68q1$19g...@digitalmars.com... > Chad J wrote: >> I actually like the idea. >> >> (...) >> >> int nTimesVarRead = 0; >> >> public property int var >> { >> get >> { >> nTimesVarRead++; >> return internalValue; >> } >

Re: Properties

2009-01-08 Thread Nick Sabalausky
"Miles" <...@___.> wrote in message news:gk6f9p$1jv...@digitalmars.com... > Nick Sabalausky wrote: >> True, but my main point was, however the language ends up handling the >> details of property getters/setters, it's not going to be as general as >> ordinary functions, and thus certai

Re: Why isn't ++x an lvalue in D?

2009-01-08 Thread Weed
Bill Baxter пишет: > Another thread just reminded me of something I use frequently in C++ > that doesn't work in D because ++x is not an lvalue: > >int x,N; > ... >++x %= N; > > So is there some deep reason for not making it an lvalue like in C++? > ++x is x+=1 in D: void main() {

Re: Suggestion: module opcall

2009-01-08 Thread Nick Sabalausky
- Original Message - From: "Bill Baxter" Newsgroups: digitalmars.D To: "digitalmars.D" Sent: Thursday, January 08, 2009 8:49 PM Subject: Re: Suggestion: module opcall > On Fri, Jan 9, 2009 at 10:23 AM, bearophile > wrote: >> Bill Baxter: >> >>>I think this problem you refer to only ap

Re: foreach ... else statement

2009-01-08 Thread Nick Sabalausky
"Walter Bright" wrote in message news:gk6150$n6...@digitalmars.com... > Nick Sabalausky wrote: >> "Rioshin an'Harthen" wrote in message >> news:gk4kfh$ri...@digitalmars.com... >>> "Walter Bright" kirjoitti viestissä >>> news:gk1dag$pt...@digitalmars.com... I keep thinking I should put on

Re: Why isn't ++x an lvalue in D?

2009-01-08 Thread Bill Baxter
2009/1/9 Weed : > Bill Baxter пишет: >> Another thread just reminded me of something I use frequently in C++ >> that doesn't work in D because ++x is not an lvalue: >> >>int x,N; >> ... >>++x %= N; >> >> So is there some deep reason for not making it an lvalue like in C++? >> > > ++x is x

Re: Why isn't ++x an lvalue in D?

2009-01-08 Thread Weed
Bill Baxter пишет: > 2009/1/9 Weed : >> Bill Baxter пишет: >>> Another thread just reminded me of something I use frequently in C++ >>> that doesn't work in D because ++x is not an lvalue: >>> >>>int x,N; >>> ... >>>++x %= N; >>> >>> So is there some deep reason for not making it an lvalu

Re: Why isn't ++x an lvalue in D?

2009-01-08 Thread Bill Baxter
On Fri, Jan 9, 2009 at 2:22 PM, Weed wrote: > Bill Baxter пишет: >> 2009/1/9 Weed : >>> Bill Baxter пишет: Another thread just reminded me of something I use frequently in C++ that doesn't work in D because ++x is not an lvalue: int x,N; ... ++x %= N; >>>

Re: Why isn't ++x an lvalue in D?

2009-01-08 Thread Weed
Weed пишет: > Bill Baxter пишет: >> 2009/1/9 Weed : >>> Bill Baxter пишет: Another thread just reminded me of something I use frequently in C++ that doesn't work in D because ++x is not an lvalue: int x,N; ... ++x %= N; So is there some deep reason fo

Re: Why isn't ++x an lvalue in D?

2009-01-08 Thread Bill Baxter
On Fri, Jan 9, 2009 at 2:43 PM, Weed wrote: > Weed пишет: >> Bill Baxter пишет: >>> 2009/1/9 Weed : Bill Baxter пишет: > Another thread just reminded me of something I use frequently in C++ > that doesn't work in D because ++x is not an lvalue: > >int x,N; > ...

Re: Properties

2009-01-08 Thread Chad J
Miles wrote: > > Both the getter and the setter should return an rvalue. Properties exist > so that they are interchangeable with real member variables. Something > that is possible with member variables MUST also be possible with > properties, in a transparent way for any code outside the class.

Re: Why isn't ++x an lvalue in D?

2009-01-08 Thread Nick Sabalausky
"Weed" wrote in message news:gk6n29$218...@digitalmars.com... > Bill Baxter ?: >> 2009/1/9 Weed : >>> Bill Baxter ?: Another thread just reminded me of something I use frequently in C++ that doesn't work in D because ++x is not an lvalue: int x,N; ...

Re: Why isn't ++x an lvalue in D?

2009-01-08 Thread Weed
Bill Baxter пишет: > On Fri, Jan 9, 2009 at 2:22 PM, Weed wrote: >> Bill Baxter пишет: >>> 2009/1/9 Weed : Bill Baxter пишет: > Another thread just reminded me of something I use frequently in C++ > that doesn't work in D because ++x is not an lvalue: > >int x,N; > .

Re: Why isn't ++x an lvalue in D?

2009-01-08 Thread Weed
Nick Sabalausky пишет: > "Weed" wrote in message > news:gk6n29$218...@digitalmars.com... >> Bill Baxter ?: >>> 2009/1/9 Weed : Bill Baxter ?: > Another thread just reminded me of something I use frequently in C++ > that doesn't work in D because ++x is not an lvalue: > >>

Re: Why isn't ++x an lvalue in D?

2009-01-08 Thread Weed
Bill Baxter пишет: > On Fri, Jan 9, 2009 at 2:43 PM, Weed wrote: >> Weed пишет: >>> Bill Baxter пишет: 2009/1/9 Weed : > Bill Baxter пишет: >> Another thread just reminded me of something I use frequently in C++ >> that doesn't work in D because ++x is not an lvalue: >> >>