December 06, 2001
Pavel Minayev wrote:

> I agree.
>
> Hey, don't forget about cases when one end is inclusive
> and other isn't:
>
>     a(2..5];    a[2..5);
>
> Personally, I believe that this plus the @ syntax covers the widest possible range and is able to satisfy most programmers. It'd be great to see these things in D.

I haven't heard anybody really argue (practically) for the cases where the starting index is exclusive...but I suppose if we're going to allow all of this flexibility, there really isn't any reason not to include them, too...

--
The Villagers are Online! http://villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]


December 06, 2001
> "Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message
> > Ok, why don't we all give up and work together?  Maybe there can just be 3 equivalent array slice syntaxes:
> >
> > start/length:  a[3@2]   or   a[3 at 2]   or ....

or a[3 : 2) ?
it remind me something..oh yes: bit fields !

Pavel Minayev a écrit :

> I agree.
>
> Hey, don't forget about cases when one end is inclusive
> and other isn't:
>
>     a(2..5];    a[2..5);

I agree too.

Roland

December 06, 2001
> "Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message
> > Ok, why don't we all give up and work together?  Maybe there can just be 3 equivalent array slice syntaxes:
> >
> > start/length:  a[3@2]   or   a[3 at 2]   or ....

or a[3 : 2] ? it remind me something.....oh yes: bit fields !

Pavel Minayev a écrit :

> I agree.
>
> Hey, don't forget about cases when one end is inclusive
> and other isn't:
>
>     a(2..5];    a[2..5);

I agree too.

Roland

December 06, 2001
Roland a écrit :

> or a[3 : 2) ?

Hum, i just made a mistake: putting ')' instead of ']'.
I makes me notice that ')' and ']' are the same key on my keyboard (French): ']'
is Halt-Gr ')' !
Dangerous isn't it  ?

Roland


December 06, 2001
Responding to Walter's comments -


    >     INTEGER [ 1 .. 10 ]
    >     INTEGER [ 1 .. 11 )
    >     INTEGER ( 0 .. 10 ]
    >     INTEGER ( 0 .. 11 )
    >
    > I'm sure you can see what's going on - the ()'s are used for "open"
    > endpoints, the []'s are used for "closed" endpoints.  The resulting
    > syntax was, I thought, pretty intuitive (perhaps because of background
    > in mathematics).
    >
    > Maybe a syntax something along these lines could be adopted in D.

    While that can be done, I'm a little uncomfortable with:
    1. the non-matching ( and ] <g>.

Agreed, the opening side and the closing side are not symmetric. But then the endpoints aren't symmetric either.  It would be nice if the syntax reflected this.


    2. ] and ) look pretty similar on the screen.

Without meaning to be flip, perhaps people with that problem should get a better screen (or better fonts).  If it's hard to tell parentheses and square brackets apart, how can one see the difference between an array index and a function call?


Additional remark:  Even if all of the different forms above aren't adopted in D, the inclusive/exclusive semantics that D seems to favor could use the [ .. ) form rather than the [ .. ] form.
December 06, 2001

la7y6nvo@shamko.com wrote:
> 
> Responding to Walter's comments -
> 
>     2. ] and ) look pretty similar on the screen.
> 
> Without meaning to be flip, perhaps people with that problem should get a better screen (or better fonts).

Or work shorter hours.

> If it's hard
> to tell parentheses and square brackets apart, how can one
> see the difference between an array index and a function call?

Easy -- the compiler tells me I can't function-call an array, or index a function name. Having both ) and ] be legal in a given context, and mean similar but not exactly identical things, is a recipe for hard-to-find bugs.

-RB
December 07, 2001
"Russell Borogove" <kaleja@estarcion.com> wrote in message news:3C10025B.55DB0D91@estarcion.com...

> > Without meaning to be flip, perhaps people with that problem should get a better screen (or better fonts).
>
> Or work shorter hours.

Yeah, right! =)

> Easy -- the compiler tells me I can't function-call an array, or index a function name. Having both ) and ] be legal in a given context, and mean similar but not exactly identical things, is a recipe for hard-to-find bugs.

Well you can't call a function with square braces, right?
As for arrays... the syntax for slicing would be (a..b). The
syntax for function call is (a, b). So:

    int A();
    int[] a;

    A(3..7);    // ".." is not legal here, so an error is displayed
                // immediately, maybe even with a tip ("slicing a function")

    a(3, 7);    // (3, 7) is treated as a comma operator, and thus, as
                // a starting point for a slice. Since there's no ending
one,
                // an error is given ("ending point expected")

So where are those "hard-to-find" bugs?


December 07, 2001
<la7y6nvo@shamko.com> wrote in message news:s7cg06ot2nc.fsf@michael.shamko.com...
>     2. ] and ) look pretty similar on the screen.
> Without meaning to be flip, perhaps people with that problem
> should get a better screen (or better fonts).  If it's hard
> to tell parentheses and square brackets apart, how can one
> see the difference between an array index and a function call?

Whenever I see the [ ) notation, it trips the "typo warning" in my brain. I understand the arguments in favor of it, but at my age rewiring my sense of what looks right and what looks wrong is risky <g>.


December 07, 2001
"Pavel Minayev" <evilone@omen.ru> wrote in message news:9upv5c$23gg$1@digitaldaemon.com...
> "Russell Borogove" <kaleja@estarcion.com> wrote in message news:3C10025B.55DB0D91@estarcion.com...
> > Having both ) and ] be legal in a given
> > context, and mean similar but not exactly identical things, is a
> > recipe for hard-to-find bugs.
> So where are those "hard-to-find" bugs?

I remember the first time I came across a mathematical expression:

    A[0..foo)

I just assumed it was a typo. I'd guess that having both A[0..foo) and A[0..foo] supported but meaning different things will result in bugs like not seeing the ; in:

    while (expression);
        statement;




December 07, 2001
"Walter" <walter@digitalmars.com> wrote in message news:9uq413$26dn$1@digitaldaemon.com...

> Whenever I see the [ ) notation, it trips the "typo warning" in my brain.
I
> understand the arguments in favor of it, but at my age rewiring my sense
of
> what looks right and what looks wrong is risky <g>.

Then, a questionnare to determine the age of all potential D users is required =)