Re: Most elegant way to read to allocatable array?
- From: Gary Scott <garylscott@xxxxxxxxxxxxx>
- Date: Sat, 20 Jan 2007 12:57:14 -0600
Richard Maine wrote:
Gary Scott <garylscott@xxxxxxxxxxxxx> wrote:
I still don't quite understand the objection to a numeric "handle" as
presently exists. Numeric handles are almost ubiquitous in modern day
software (e.g. Windows API). You can always associate this numeric handle with a well-named variable and pass that around. It would be nice to have an API that can access some of the internal information stored by the run time or OS and to be able to coordinate IO across DLLS
and separate processes (on the same machine at least). I definitely don't want to pass a full file path around everywhere and much prefer an
LFN to that. I can't see another scheme helping me in any significant
way.
Windows uses numeric handles? Yukk. Didn't know that. I don't like lots
of things about it; guess that's one more. I don't know much about the
WIndows API (obviously), but I would in general say the opposite - that
numeric handles are relatively rare overall. In fact, I would have said
that the term "handle" in this context usualy indicates something that
you can't "see" inside of or manipulate directly. Are you sure that
these WIndows handles are documented as user-visible numers, or are you
just talking about the internal implementation? Yes, it makes a big
difference whether it is documented and user visible versus being
internal implementation - because that distinction is the whole point.
Anyway, regardless of what one thinks is "common", the objections are
1. The scheme of having the user define the numeric values has numerous
problems. I hope you understand that, because its problems are
"obvious". It coudl be ok for small programs written by a single person
or cohesive group. But when you use code (such as libraries) from many
sources, the problem becomes something that must be worked around. For
every piece of code in a program, you need to know what unit numbers it
uses. Yes, one can develop an assignment scheme, but that only works if
all the code uses the same scheme. That counts as a workaround for a
problem. I have seen cases where I wanted to use 2 3rd party libraries,
each of which used the same unit number. The particular unit number was
hard-wired into the code of thee 3rd party library, which was not
accessible to us. This kind of thing is even more fun when the usage
isn't documenteed.
2. For system-defined numbers, the numeric nature provides no benefit,
but has problems. Anything you do that uses the numeric properties is
pretty much guaranteed to be an error. Thus, making them numeric
provides opportunity for accidental errors. For heavens sake, look at
all the times that matters come up about what numbers are advisabel to
use or not. That all comes from theirt being numeric.
Egads, no, one wouldn't use the path name! That's worse than a unit
number; has even more problems. I suspect you don't understand the
concept of an abstract handle if you think that's the kind of thing
advocated.
That may be because every handle I've been exposed to (windows API) is simply an integer ID, similar to an LFN. It is an absolute system wide identifier for a process, window, thread, GUI widget, etc that has to be passed around (in the Windows API context it is certainly a huge PITA, but it is what it is). However, there are facilities to query what that handle is in certain cases, but the common method is to pass it around directly. So, with facilities to query what LFN/handle is associated with what (I'd like certain other attributes queriable also such as access rights, security settings), it seems resolvable to me within the context of a numeric LFN/handle as currently exists. I would agree that using negative LFN numbers would probably be required going forward, with conflicts already built into existing applications. I don't oppose necessarily hiding the LFN value behind an API. Most libraries I've been exposed to do not hard code Fortran LFN numbers, they let you pick one or they use a C API internally so that it doesn't matter. I'd just call that bad API design for a 3rd party API designed for use by others.
No, a handle would be something of a separate data type, all of its own.
Typically it would be a like a derived type with private components. In
fact, that's exactly what user-defined handles for various things are
are today. (I have *LOTS* of them for my stuff). By design, you have no
idea what is "inside" of it, because you don't care. It is just a
"handle" by which you can manipulate the file. The internal
implementation is reasonably to be something like a pointer to the
internal place where the information about the file is stored, or
possibly even a numeric index into an array of such areas. But a
significant pooint is that you don't know what the exact internal
structure is, because it doesn't directly matter to you as a user.
--
Gary Scott
mailto:garylscott@sbcglobal dot net
***** 5 Jan: Back from 7 days in Cozumel! *****
Fortran Library: http://www.fortranlib.com
Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html
If you want to do the impossible, don't hire an expert because he knows it can't be done.
-- Henry Ford
.
- References:
- Most elegant way to read to allocatable array?
- From: yair999@xxxxxxxxx
- Re: Most elegant way to read to allocatable array?
- From: Beliavsky
- Re: Most elegant way to read to allocatable array?
- From: Richard Maine
- Re: Most elegant way to read to allocatable array?
- From: yair999@xxxxxxxxx
- Re: Most elegant way to read to allocatable array?
- From: Richard Maine
- Re: Most elegant way to read to allocatable array?
- From: Michael Prager
- Re: Most elegant way to read to allocatable array?
- From: Richard Maine
- Re: Most elegant way to read to allocatable array?
- From: Gary Scott
- Re: Most elegant way to read to allocatable array?
- From: Richard Maine
- Most elegant way to read to allocatable array?
- Prev by Date: Re: Most elegant way to read to allocatable array?
- Next by Date: Re: Most elegant way to read to allocatable array?
- Previous by thread: Re: Most elegant way to read to allocatable array?
- Next by thread: Re: Most elegant way to read to allocatable array?
- Index(es):
Relevant Pages
|