|
|
Up |
|
|
  |
Author: GaryScottGaryScott Date: Apr 18, 2008 09:03
http://softwareblogs.intel.com/2008/03/31/doctor-it-hurts-when-i-do-this/
But we NEED a syntax that means "the entire array". Code should be
self documenting. Of course, I typically just name arrays so that
it's clear that it is an array (aArray, bArray, cArray), but it is
fairly natural to want to specify a wildcard indicating whole array
since it improves interpretability. It is available in other
languages that I've used in the past.
|
| |
|
| | 49 Comments |
|
  |
Author: nospamnospam Date: Apr 18, 2008 09:27
GaryScott sbcglobal.net> wrote:
I don't think I've seen that article before, but I think it is well done
(as I'd expect from Steve). I also quite agree with its points.
> But we NEED a syntax that means "the entire array". Code should be
> self documenting.
We do have a syntax that means the entire array - the array name. True,
the syntax doesn't directly tell you that it is an array, but it does
tell you that it is the entire of whatever the thing so named is
declared to be.
While I'm a big fan of writing clear and largely self-documenting code,
I disagree that it helps to use a special notation to indicate that
something is an array. Why pick on arrayness in particular? Down that
path lies special notations for all attributes. Might as well go back to
implicit typing, and disallow overriding the implicit type; then you can
look at the variable name and know the type.
|
| Show full article (2.20Kb) |
|
| | no comments |
|
  |
Author: GaryScottGaryScott Date: Apr 18, 2008 10:53
On Apr 18, 11:27 am, nos...@see.signature (Richard Maine) wrote:
> GaryScott sbcglobal.net> wrote:
>
> I don't think I've seen that article before, but I think it is well done
> (as I'd expect from Steve). I also quite agree with its points.
>
>> But we NEED a syntax that means "the entire array". Code should be
>> self documenting.
>
> We do have a syntax that means the entire array - the array name. True,
> the syntax doesn't directly tell you that it is an array, but it does
> tell you that it is the entire of whatever the thing so named is
> declared to be.
>
> While I'm a big fan of writing clear and largely self-documenting code,
> I disagree that it helps to use a special notation to indicate that
> something is an array. Why pick on arrayness in particular? Down that
> path lies special notations for all attributes. Might as well go back to
> implicit typing, and disallow overriding the implicit type; then you can ...
|
| Show full article (2.69Kb) |
| no comments |
|
  |
Author: nonenone Date: Apr 18, 2008 11:25
On Fri, 18 Apr 2008 09:03:06 -0700, GaryScott wrote:
> http://softwareblogs.intel.com/2008/03/31/doctor-it-hurts-when-i-do-this/
>
> But we NEED a syntax that means "the entire array". Code should be
> self documenting. Of course, I typically just name arrays so that
> it's clear that it is an array (aArray, bArray, cArray), but it is
> fairly natural to want to specify a wildcard indicating whole array
> since it improves interpretability. It is available in other
> languages that I've used in the past.
I read the article to mean that Steve *is* happy using to
indicate the whole array. If modifying the code you would check its
declaration, at some point; if just reading it, the atomic use of
name> is sufficient. Steve wrote that there was an alternate 'wildcard',
using (:), but that this usually hindered optimisation - and in the
specific example in his article, prevented the user from getting the
result wanted. Adding a new construct for such a specific operation -
retrieving the whole array - when there are already two mechanisms for
doing this - , on the grounds that this would 'clarify' the array
retrieval, seems an uncessary burden.
|
| |
| no comments |
|
  |
Author: Clive PageClive Page Date: Apr 18, 2008 11:32
>It doesn't logically follow that to ask for a syntax for arrayness
>requires a syntax for any other attributes. The article makes it
>quite clear that it is a common thought process among programmers and
>a common pitfall.
I for one don't agree. It may be a common pitfall among programmers
used to inferior languages such as C, C++, and Java which really don't
support much beyond simple scalar operations, but surely Fortran
programmers are used to being able to use the name of an array and have
it mean the entire array. This has been standard practice in many
statements (READ, WRITE, PRINT, CALL, DATA, SUBROUTINE, FUNCTION, etc)
since Fortran-II (I think), certainly since Fortran-IV/Fortran 66.
The main change since then is that the whole-array notation was extended
to every other appropriate context, and especially to expressions and
assignments. Of course this change came in as recently as 1990.
|
| Show full article (1.47Kb) |
| no comments |
|
  |
Author: GaryScottGaryScott Date: Apr 18, 2008 13:14
On Apr 18, 1:32 pm, Clive Page wrote:
>>It doesn't logically follow that to ask for a syntax for arrayness
>>requires a syntax for any other attributes. The article makes it
>>quite clear that it is a common thought process among programmers and
>>a common pitfall.
>
> I for one don't agree. It may be a common pitfall among programmers
> used to inferior languages such as C, C++, and Java which really don't
> support much beyond simple scalar operations, but surely Fortran
> programmers are used to being able to use the name of an array and have
> it mean the entire array. This has been standard practice in many
> statements (READ, WRITE, PRINT, CALL, DATA, SUBROUTINE, FUNCTION, etc)
> since Fortran-II (I think), certainly since Fortran-IV/Fortran 66.
>
> The main change since then is that the whole-array notation was extended
> to every other appropriate context, and especially to expressions and ...
|
| Show full article (2.06Kb) |
| no comments |
|
  |
Author: glen herrmannsfeldtglen herrmannsfeldt Date: Apr 18, 2008 13:37
GaryScott wrote:
> But we NEED a syntax that means "the entire array". Code should be
> self documenting. Of course, I typically just name arrays so that
> it's clear that it is an array (aArray, bArray, cArray), but it is
> fairly natural to want to specify a wildcard indicating whole array
> since it improves interpretability. It is available in other
> languages that I've used in the past.
Having read this thread backwards (my news reader is set to sort in
decreasing time/date order) and then the referenced article, I agree
with Steve.
Note, though, that the (:) does indicate (the contents of) the
entire array. As someone said, this will be more obvious to C, C++,
and Java programmers, also not previously mentioned, R programmers.
In Java you can say A=B; You get a copy of the Object reference,
or as some say a shallow copy of the array, not a copy of the contents
of the array. In C, an array name is a pointer to the array.
|
| Show full article (2.21Kb) |
| no comments |
|
  |
Author: nospamnospam Date: Apr 18, 2008 13:54
GaryScott sbcglobal.net> wrote:
> Other languages with whole array syntax support it properly by
> including a syntax for consistently differentiating arrayness versus
> scalarness. In this single instance, Fortran has it wrong. It leads
> to ambiguous (actually hidden) meaning when humans are reading the
> code because it looks exactly like a scalar operation, a very
> different thing.
I suppose it is just restating part of my previous post, and I suppose
we are just going to continue to disagree about it, but I still don't
understand why you think it important for there to be such a special
syntax for arrays, but not for derived types. I perhaps exagerated the
case in my prior post by extrapolating to all other attributes in an
attempt to see where that direction might lead, but the case of a
derived type seems awfully simillar to me and not an exageration or
extrapolation. After all, a derived-type assignment can equally "hide" a
simillar underlying meaning. In fact, a derived-type assignment can
include array assignments within it (for array components).
> Anyway, I wasn't intending to start an argument, but merely to point
> those interested in reading the latest edition of "Dr. Fortran".
|
| Show full article (1.45Kb) |
| no comments |
|
  |
Author: glen herrmannsfeldtglen herrmannsfeldt Date: Apr 18, 2008 13:58
Clive Page wrote:
>> It doesn't logically follow that to ask for a syntax for arrayness
>> requires a syntax for any other attributes. The article makes it
>> quite clear that it is a common thought process among programmers and
>> a common pitfall.
> I for one don't agree. It may be a common pitfall among programmers
> used to inferior languages such as C, C++, and Java which really don't
> support much beyond simple scalar operations, but surely Fortran
> programmers are used to being able to use the name of an array and have
> it mean the entire array.
|
| Show full article (2.49Kb) |
| no comments |
|
  |
|
|
  |
Author: Dick HendricksonDick Hendrickson Date: Apr 18, 2008 13:58
GaryScott wrote:
> On Apr 18, 11:27 am, nos...@see.signature (Richard Maine) wrote:
>> GaryScott sbcglobal.net> wrote:
>> I don't think I've seen that article before, but I think it is well done
>> (as I'd expect from Steve). I also quite agree with its points.
>>
In it Steve said
"Still, most of the time, the (:) is "harmless" in that it does not
change the overall meaning of the program, since an array section is
"definable" (can be stored into), as long as you don't use a vector
subscript such as A([1,3,5,7])."
That particular example is perfectly definable. It's only many
to one assignments that are prohibited. Steve undoubtedly meant
A([1,3,5,3]). ;)
Dick Hendrickson
|
| |
| no comments |
|
|
|
|