March 04, 2005
In article <d09mi9$12o0$1@digitaldaemon.com>, David Medlock says...
>
>Its too bad the with statement doesnt work with arrays:
>
>int []a = new int[100];
>int []x;
>
>with(a) x[0..length] = a[0..length];
>
>
>Looks pretty clean to me.

This looks like a pretty good idea to me!! :) It is clean.

In fact, up until about a couple of months ago I didn't even know that a[ 0 .. length ] (using length in the array brackets was the same as array.length) was even allowed, so I've always just coded a[ 0 .. a.length ] instead. (Guess my code is pretty safe this area, whether "length" ends up being disallowed, or if we're going to use the "$" as its replacement). But I do feel we should save the "$" symbol / character tho, for something much more important down the road for use in D's future development. I'm not sure at this point what that might be, but I'm very sure something will need it. :)

David L.

-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
March 04, 2005
David L. Davis wrote:
> In article <d09mi9$12o0$1@digitaldaemon.com>, David Medlock says...
> 
>>Its too bad the with statement doesnt work with arrays:
>>
>>int []a = new int[100];
>>int []x;
>>
>>with(a) x[0..length] = a[0..length];
>>
>>
>>Looks pretty clean to me.
> 
> 
> This looks like a pretty good idea to me!! :) It is clean.
> 
> In fact, up until about a couple of months ago I didn't even know that a[ 0 ..
> length ] (using length in the array brackets was the same as array.length) was
> even allowed, so I've always just coded a[ 0 .. a.length ] instead. (Guess my
> code is pretty safe this area, whether "length" ends up being disallowed, or if
> we're going to use the "$" as its replacement). But I do feel we should save the
> "$" symbol / character tho, for something much more important down the road for
> use in D's future development. I'm not sure at this point what that might be,
> but I'm very sure something will need it. :)
> 
> David L.
> 
> -------------------------------------------------------------------
> "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"

With the regex discussion and now using adding a '$' character, I think the Perl people have infiltrated this newsgroup...

March 04, 2005
Anders F Björklund <afb@algonet.se> wrote:

[...]
> (still waiting for the reason it was introduced ?)

The start of the discussion on the reason seems to be here: http://www.digitalmars.com/drn-bin/wwwnews?D/24082

And I still think, that this property of arrays is as much needed by us, as bicycles are needed by fish.

-manfred
March 04, 2005
Manfred Nowak wrote:

>>(still waiting for the reason it was introduced ?)
> 
> The start of the discussion on the reason seems to be here:
> http://www.digitalmars.com/drn-bin/wwwnews?D/24082

Ah, the good ole negative string indexes...
Just like momma Perl used to make them. :-)

@a = (0..9); @b = @a[0,1,-2,-1]; print @b;
Prints: 0189

--anders
March 04, 2005
On Fri, 4 Mar 2005 19:36:01 +0000 (UTC), Manfred Nowak wrote:

> Anders F Björklund <afb@algonet.se> wrote:
> 
> [...]
>> (still waiting for the reason it was introduced ?)
> 
> The start of the discussion on the reason seems to be here: http://www.digitalmars.com/drn-bin/wwwnews?D/24082
> 
> And I still think, that this property of arrays is as much needed by us, as bicycles are needed by fish.

Are you referring to the ability to reference elements relative to the end of an array? It is not needed in the same sense that we don't need 'for', 'foreach', 'while', 'switch', etc ... There are other ways of achieving the same thing, but at the cost of more obscure code and potentially more bugs.

-- 
Derek Parnell
Melbourne, Australia
5/03/2005 8:55:38 AM
March 05, 2005
Derek Parnell <derek@psych.ward> wrote:

[...]
> Are you referring to the ability to reference elements relative to the end of an array?

No. This needed ability was and is given by the `.length'-property of arrays. I am referring to the shortcut of this property, denoted by the quasi-keyword `length' --- or whatever it will be in the future.

> It is not needed in the same sense that
> we don't need 'for', 'foreach', 'while', 'switch', etc ... There
> are other ways of achieving the same thing, but at the cost of
> more obscure code and potentially more bugs.

I did not follow that discussion to the end. However, if costs
where introduced as an argument
1) how have they been defined?
2) why where the cases that led to this new outbreak of the
discussion not included?
3) please show, that under that cost measure there is no problem
size, i.e. a natural number "n", for which the relative saving of
costs becomes neglectable. Where for example "n" is defined to be
the dimension of a "n"-dimensional cuboid array, which has to be
reduced into the maximal "n"-dimensional cubed array, that fits
into the original cuboid array.
4) if you cannot prove number 3), please admit, that your statement
is wrong, that those well known and accepted elements of blöck-
structured programming, `while' etc., are comparable to the
shortcut, which is in question here.

-manfed

March 05, 2005
On Fri, 04 Mar 2005 14:01:35 +0100, Anders F Björklund <afb@algonet.se> wrote:
> Unknown W. Brackets wrote:
>
>> It's not, as far as I know.  Just syntactical sugar... but, it is fairly nice sugar.  Consider:
>>
>> Airport.getFromHangar(AIRPLANE_747).optionalComponents["seatbelts"][length - 5 .. length]
>>
>> Okay, strange example, but it's nice to have.
>
> So just use a temp ? Too much sugar is not good for you, anyway :-)

This just occured to me...
(assuming we remove the special length syntactical sugar)

void foo(char[] array) {
  array.length = array.length + 2;
}

...

char[] array;

...

int length = array.length;
if (foo(array) && b = array[0..length]) {}

Basically length becomes invalidated when foo is called, and is incorrect (or maybe it's actually correct) in the b = assignment.

Sure, the above example is contrived, it may also be rare, not sure. All I know is that it's 'possible'.

Regan
March 05, 2005
On Sat, 5 Mar 2005 01:37:09 +0000 (UTC), Manfred Nowak wrote:

> Derek Parnell <derek@psych.ward> wrote:
> 
> [...]
>> Are you referring to the ability to reference elements relative to the end of an array?
> 
> No. This needed ability was and is given by the `.length'-property of arrays. I am referring to the shortcut of this property, denoted by the quasi-keyword `length' --- or whatever it will be in the future.
> 
>> It is not needed in the same sense that
>> we don't need 'for', 'foreach', 'while', 'switch', etc ... There
>> are other ways of achieving the same thing, but at the cost of
>> more obscure code and potentially more bugs.
> 
> I did not follow that discussion to the end. However, if costs
> where introduced as an argument
> 1) how have they been defined?

They (that is "costs where[sic] introduced as an argument") were not introduced as an argument, therefore the costs were not defined.

> 2) why where the cases that led to this new outbreak of the discussion not included?

Just bad luck, I guess. Maybe I'm too lazy. Maybe I'm too arrogant? Maybe I ran out of time 'cos I had to go shopping with my wife to get our weekly groceries, two new shirts, a BNC-RCA adaptor for an old VCR I'm trying to hook up to the new digital TV, a birthday gift for my daughter, ... in short I've got a life.

> 3) please show, that under that cost measure there is no problem size, i.e. a natural number "n", for which the relative saving of costs becomes neglectable. Where for example "n" is defined to be the dimension of a "n"-dimensional cuboid array, which has to be reduced into the maximal "n"-dimensional cubed array, that fits into the original cuboid array.

Sure! 42  ;-)

> 4) if you cannot prove number 3), please admit, that your statement is wrong, that those well known and accepted elements of blöck- structured programming, `while' etc., are comparable to the shortcut, which is in question here.

I cannot prove (3). Mainly because I can't understand (3). And I do not
admit that my statement was wrong. BTW, what was my statement?

Was it "There are other ways of achieving the same thing, but at the cost of more obscure code and potentially more bugs."? This was made in the context of the 'for' etc line. These would otherwise be implemented with GOTO statements mainly and I think the literature is generally of the opinion that GOTO is a cause of more costly software.

In the same manner, I, me, myself, personally, moi, is of the opinion that a small token of one or two characters, that represents a reference to the end of an array, is easier to write, read and absorb, than longer ways to do the same thing.

I'll try to say it clearly this time ...

A symbolic reference to the end of an array by a *short* token is better for software developers than a *longer* token.

The only 'proof' I have is personal experience. I'm embarrassed that you find that lacking in credibility.

> -manfed

WTFWT?

-- 
Derek Parnell
Melbourne, Australia
5/03/2005 8:49:51 PM
1 2
Next ›   Last »