Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

F2007: another possible improvement
INMHO, array constructors should allow us to declare the types of the
entries in a declaration, so that something like the following would
be possible:

CHARACTER(LEN=16), PARAMETER::  WEEKDAYS( 7 ) = &
CHARACTER(LEN=9)(/
'Sunday',    'Monday',   'Tuesday', &
'Wednesday', 'Thursday', 'Friday' &
'Saturday',  'Sunday'
/)

so that all of the names of the days would be coerced into the same
length and therefore could be used as the PARAMETER-value for the
array WEEKDAYS, for example.

Likewise, one should be able to do an array constructor like
REAL(KIND=foo)(/ 1, 2.0, 3.0D0 /)
where all of the entries are coerced into REAL(KIND=foo) before
being used as array-entries in the array-constructor.


fwiw--

Carlie J. Coats, Jr.                        carlie.coats@baronams.com
Environmental Modeling Center               carlie_coats@ncsu.edu
c/o North Carolina State University                   MEAS Department
1125 Jordan Hall                                      Campus Box 8208
Raleigh, NC 27695           phone: (919)515-7076 / fax: (919)515-7802
"My opinions are my own, and I've got *lots* of them!"

Report this thread to moderator Post Follow-up to this message
Old Post
Carlie J. Coats
10-29-04 08:58 PM


Re: F2007: another possible improvement
Carlie J. Coats wrote:
>
> INMHO, array constructors should allow us to declare the types of the
> entries in a declaration, so that something like the following would
> be possible:
>
>    CHARACTER(LEN=16), PARAMETER::  WEEKDAYS( 7 ) = &
>       CHARACTER(LEN=9)(/
>            'Sunday',    'Monday',   'Tuesday', &
>            'Wednesday', 'Thursday', 'Friday' &
>            'Saturday',  'Sunday'
>             /)
>
> so that all of the names of the days would be coerced into the same
> length and therefore could be used as the PARAMETER-value for the
> array WEEKDAYS, for example.

I'm . What length do you want? Len=16 or Len=9? What's wrong with so
mething like:

CHARACTER(*), PARAMETER::  WEEKDAYS( 7 ) = &
(/'Sunday',    'Monday',   'Tuesday', &
'Wednesday', 'Thursday', 'Friday' &
'Saturday',  'Sunday'/)

and with the result that LEN(WEEKDAYS(1)) = the length of the longest compon
ent.


> Likewise, one should be able to do an array constructor like
>     REAL(KIND=foo)(/ 1, 2.0, 3.0D0 /)
> where all of the entries are coerced into REAL(KIND=foo) before
> being used as array-entries in the array-constructor.

This one I like even less - for personal reasons, since I think it encourage
s sloppiness
(goodness, I sound like a school marm!) I think having to specify the kind t
ype in the
declaration ala

REAL(foo) :: x(3)

x = (/ 1.0_foo, 2.0_foo, 3.0_foo /)

makes one think more about the precision required (e.g. do I even need KIND=
foo? Or will
KIND=bar be enough? Is "x" declared as KIND=foo or KIND=bar?) I've "fixed" p
lenty of code
that didn't work right because people assumed, e.g., the variable assignment
 x=0.1 meant x
really was 0.100000000000....etc, and not x=0.09999999485763.....whatever. (
Aside: the
thing that gets me about this is that a few times the result is said people 
thinking
Fortran is a stupid language. Oof. I'm amazed at the number of people who st
ill don't grok
how numbers are represented in computers.)

> Carlie J. Coats, Jr.                        carlie.coats@baronams.com
> Environmental Modeling Center               carlie_coats@ncsu.edu
> c/o North Carolina State University                   MEAS Department

Hey! I thought *I* was at EMC! :o)

cheers,

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC

Report this thread to moderator Post Follow-up to this message
Old Post
Paul Van Delst
10-29-04 08:58 PM


Re: F2007: another possible improvement
I think F2003 does what you want, you can
put a type-spec as the leading thing in an array
constructor.  The syntax rule is

R465     array-constructor is (/ ac-spec /)
...
R466     ac-spec  is type-spec ::
or [type-spec ::] ac-value-list

And "type-spec" is
R401 type-spec    is intrinsic-type-spec
or derived-type-spec

which covers anything you should want ;).  It coerces all
of the following constructor values into the specified type.

An example is:
(/ CHARACTER(LEN=7) :: 'Takata', 'Tanaka', 'Hayashi' /)

Before anyone asks, the first form
(/ type-spec:: /)
allows you to create a zero-size array of a specific type.
You couldn't do that before F2003.  (There was an ambiguity
in what (/ (I, I=1,0) /) meant.)


Dick Hendrickson

Carlie J. Coats wrote:
>
> INMHO, array constructors should allow us to declare the types of the
> entries in a declaration, so that something like the following would
> be possible:
>
>    CHARACTER(LEN=16), PARAMETER::  WEEKDAYS( 7 ) = &
>       CHARACTER(LEN=9)(/
>            'Sunday',    'Monday',   'Tuesday', &
>            'Wednesday', 'Thursday', 'Friday' &
>            'Saturday',  'Sunday'
>             /)
>
> so that all of the names of the days would be coerced into the same
> length and therefore could be used as the PARAMETER-value for the
> array WEEKDAYS, for example.
>
> Likewise, one should be able to do an array constructor like
>     REAL(KIND=foo)(/ 1, 2.0, 3.0D0 /)
> where all of the entries are coerced into REAL(KIND=foo) before
> being used as array-entries in the array-constructor.
>
>
> fwiw--
>
> Carlie J. Coats, Jr.                        carlie.coats@baronams.com
> Environmental Modeling Center               carlie_coats@ncsu.edu
> c/o North Carolina State University                   MEAS Department
> 1125 Jordan Hall                                      Campus Box 8208
> Raleigh, NC 27695           phone: (919)515-7076 / fax: (919)515-7802
> "My opinions are my own, and I've got *lots* of them!"


Report this thread to moderator Post Follow-up to this message
Old Post
Dick Hendrickson
10-29-04 08:58 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:24 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.