September 10, 2001 Re: Ambiguities? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Cohen | Ben Cohen wrote:
> How about using 2 dots instead of one?
>
> int i = X..size;
Or how about, hmmmm .... hmmmm, .. brackets!
int i = X.size();
- sometimes we're spinning in a circle, and don't even notice it's round.
|
September 10, 2001 Re: Ambiguities? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Axel Kittenberger | Axel Kittenberger wrote:
> Ben Cohen wrote:
>
> > How about using 2 dots instead of one?
> >
> > int i = X..size;
>
> Or how about, hmmmm .... hmmmm, .. brackets!
>
> int i = X.size();
>
> - sometimes we're spinning in a circle, and don't even notice it's round.
Now we run into problems with properties if X is a class and size() is a
gettor for that class... :(
Not an easy problem to solve, it seems.
I kind of like the
..
syntax myself.
|
September 11, 2001 Re: Ambiguities? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russ Lewis | I've been thinking of the ::, sort of like in C++ it means "use the global version". x = ::foo; // use global foo Russ Lewis wrote in message <3B9D14D3.D0491D6F@deming-os.org>... >Axel Kittenberger wrote: > >> Ben Cohen wrote: >> >> > How about using 2 dots instead of one? >> > >> > int i = X..size; >> >> Or how about, hmmmm .... hmmmm, .. brackets! >> >> int i = X.size(); >> >> - sometimes we're spinning in a circle, and don't even notice it's round. > >Now we run into problems with properties if X is a class and size() is a >gettor for that class... :( > >Not an easy problem to solve, it seems. > >I kind of like the > .. >syntax myself. > > |
September 11, 2001 Re: Ambiguities? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russ Lewis | Russ Lewis wrote: > > Axel Kittenberger wrote: > > > Ben Cohen wrote: > > > > > How about using 2 dots instead of one? > > > > > > int i = X..size; > > > > Or how about, hmmmm .... hmmmm, .. brackets! > > > > int i = X.size(); > > > > - sometimes we're spinning in a circle, and don't even notice it's round. > > Now we run into problems with properties if X is a class and size() is a > gettor for that class... :( > > Not an easy problem to solve, it seems. Just don't make classes with methods that have the same name as properties. No ambiguity there. The problem was with struct that were originally designed in C. Either our name could not match the C API or would collide with D properties. C didn't have class or member functions and we aren't even binary compatible with C++. It's still sub-optimal, but it fixes the serious problem. > I kind of like the > .. > syntax myself. char[5] a ="01234"; int b = 0; int size = 5; a[b..size]; // What do ya think happens? First 4 or first 5? Dan |
September 11, 2001 Re: Ambiguities? | ||||
---|---|---|---|---|
| ||||
Posted in reply to a | In article <3B9D8704.50B5A32@b.c>, "a" <a@b.c> wrote:
>> I kind of like the
>> ..
>> syntax myself.
>
> char[5] a ="01234";
> int b = 0;
> int size = 5;
> a[b..size]; // What do ya think happens? First 4 or first 5?
>
> Dan
Yes, that's the main problem with this syntax, namely that it clashes with range notation. But there is no particular reason why we have to use two dots for ranges (other than it's what Pascal uses).
We could use *three* dots for ranges, but that would get confusing:
a[b..size];
vs.
a[b...size];
I was going to suggest using two minuses but it might be problematic, at least for programmers if not the compiler:
a[b--size];
I think Python uses colons for ranges, which may work better (unless you'd prefer them for properties):
a[b:size];
|
September 11, 2001 Re: Ambiguities? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | In article <9njv6d$jp9$1@digitaldaemon.com>, "Walter" <walter@digitalmars.com> wrote: > I've been thinking of the ::, sort of like in C++ it means "use the global version". > > x = ::foo; // use global foo > Does this clash with use of : for properties? |
September 12, 2001 Re: Ambiguities? | ||||
---|---|---|---|---|
| ||||
Posted in reply to a |
a wrote:
>
> Russ Lewis (maybe?) wrote:
> > I kind of like the
> > ..
> > syntax myself.
>
> char[5] a ="01234";
> int b = 0;
> int size = 5;
> a[b..size]; // What do ya think happens? First 4 or first 5?
line 3, error, reserved word used as identifier. :)
-Russell B
|
September 14, 2001 Re: Ambiguities? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Cohen | Ben Cohen wrote in message <9nkkrl$110k$1@digitaldaemon.com>... >In article <9njv6d$jp9$1@digitaldaemon.com>, "Walter" <walter@digitalmars.com> wrote: > >> I've been thinking of the ::, sort of like in C++ it means "use the global version". >> >> x = ::foo; // use global foo >Does this clash with use of : for properties? No, : is used for labels. |
September 14, 2001 Re: Ambiguities? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | In article <9nt7au$2ohh$1@digitaldaemon.com>, "Walter" <walter@digitalmars.com> wrote: > Ben Cohen wrote in message <9nkkrl$110k$1@digitaldaemon.com>... >>In article <9njv6d$jp9$1@digitaldaemon.com>, "Walter" <walter@digitalmars.com> wrote: >> >>> I've been thinking of the ::, sort of like in C++ it means "use the global version". >>> >>> x = ::foo; // use global foo >>Does this clash with use of : for properties? > > No, : is used for labels. Sorry, I should have said "would this clash..." |
September 15, 2001 Re: Ambiguities? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Cohen | Ben Cohen wrote in message <9nt8jh$2p5h$1@digitaldaemon.com>... >In article <9nt7au$2ohh$1@digitaldaemon.com>, "Walter" <walter@digitalmars.com> wrote: > >> Ben Cohen wrote in message <9nkkrl$110k$1@digitaldaemon.com>... >>>In article <9njv6d$jp9$1@digitaldaemon.com>, "Walter" <walter@digitalmars.com> wrote: >>> >>>> I've been thinking of the ::, sort of like in C++ it means "use the global version". >>>> >>>> x = ::foo; // use global foo >>>Does this clash with use of : for properties? >> >> No, : is used for labels. > >Sorry, I should have said "would this clash..." No, I don't think it would clash. -Walter |
Copyright © 1999-2021 by the D Language Foundation