comp.lang.ada
 help / color / mirror / Atom feed
* Ada programs in a UNIX environment (was Re: I have a question...)
  1994-10-14 21:32           ` Norman H. Cohen
@ 1994-10-17 10:34             ` Andre Spiegel
  0 siblings, 0 replies; 2+ messages in thread
From: Andre Spiegel @ 1994-10-17 10:34 UTC (permalink / raw)


I wrote:
> I should say that if a UNIX program needs to ask the user for a file
> name, something must be wrong with its design.

On which Dave Emery replied:
> Some Unix programs are filters.  They read standard input, and write
> to standard output.  This is a SMALL SUBSET of Unix programs.
> Compilers, for instance, may well ask for a filename if the user
> provides no filename on the command line.  Thus this assertion (that a
> Unix program that has to ask for a filename is 'bad') is not valid.

And Norman Cohen said:
> Indeed.  For example, a text editor may support commands to insert a
> given file in the current editing buffer, write all or part of the
> current editing buffer to a file, or open a new buffer and read some file
> into it.  It is a real pain if the user can't use symbols like ~ in such
> commands, so the editor ought to expand the file names in such commands.

Of course, my above statement was intended as a rule of thumb, nothing
more. Sort of a general orientation for Ada programming under UNIX: to
fit neatly into what is already there. Naturally, there are cases when
interactive programs *do* have to ask for filenames, and the like. I
am just saying that sometimes this can be avoided, and, if so, should
be avoided. For example, I wouldn't want a compiler to ask
interactively, even if I didn't provide a filename. Think of the
confusion if you try to use that compiler in a shell script, and you
forget to supply the filename (or the file doesn't exist).

If something like file name expansion is really needed in your own
program (a text editor would be an example, I agree), the "rule of
thumb" should also be applied, by trying to use the already existing
mechanism, not (without good reason) something you write yourself JUST
IN ORDER TO SIMULATE A FACILITY YOU CAN'T FIND ACCESS TO. Chances are
that you'll write something _almost_, but not entirely identical. And
what if the mechanism you have re-implemented gets changed (for
example, a new generation of shells comes up), or your program is to
be ported to, say, a non-UNIX environment, where there are completely
different conventions and facilities? 

Finally, I think that when you really try to find a UNIX-like
solution, you often end up with something you would not have thought
about otherwise, but which proves quite handy in such an
environment. Sometimes it's just a choice between two ways of doing
things, none of which being any more difficult to implement than the
other.

--
Andre Spiegel                     |  This life is a test. It is only a test.
                                  |  Had this been an actual life, you would
University of Stuttgart, Germany  |  have received further instructions as to
Computer Science                  |  where to go and what to do.
                                                            -- Author unknown

	   email: spiegel@bruessel.informatik.uni-stuttgart.de



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Ada programs in a UNIX environment (was Re: I have a question...)
@ 1994-10-20 11:01 The Trooper
  0 siblings, 0 replies; 2+ messages in thread
From: The Trooper @ 1994-10-20 11:01 UTC (permalink / raw)


spiegel@bruessel.informatik.uni-stuttgart.de (Andre Spiegel) writes:
[snip]
> And what if the mechanism you have re-implemented gets changed (for
> example, a new generation of shells comes up), or your program is to
> be ported to, say, a non-UNIX environment, where there are completely
> different conventions and facilities?
>
 How's about either
	system ("echo $HOME/foo");
 or
	system ("csh -c echo ~/bar");
 ?

 I'm sure you can figure out how to call 'system' from Ada ...

> Andre Spiegel
-- 
#  Bill Crawford, BSc (Hons) Comp Sci Year 4 : w.j.m.crawford@bton.ac.uk  #
# Any views wot I express is not necessarily those of Brighton University #



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1994-10-20 11:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-10-20 11:01 Ada programs in a UNIX environment (was Re: I have a question...) The Trooper
     [not found] <1994Oct07.034523.161470@zeus.aix.calpoly.edu>
     [not found] ` <SPIEGEL.94Oct10115716@moskau.bruessel.informatik.uni-stuttgart.de>
1994-10-12 17:33   ` I have a question David Emery
1994-10-14  1:21     ` Keith Thompson @pulsar
1994-10-14 16:46       ` Andre Spiegel
1994-10-14 14:16         ` David Emery
1994-10-14 21:32           ` Norman H. Cohen
1994-10-17 10:34             ` Ada programs in a UNIX environment (was Re: I have a question...) Andre Spiegel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox