Re: File mapping (was: programi parsing question)
On Aug 8, 3:45 pm, CBFalconer <cbfalco...@yahoo.com> wrote:[color=blue]
> Ian Collins wrote:[color=green]
> > CBFalconer wrote:[/color][/color]
[color=blue]
> ... snip ...[/color]
[color=blue][color=green][color=darkred]
> >> Why does everyone misinterpret my concern here? It must be what I
> >> wrote. At any point, my point is that there is usually NO reason
> >> to use open, when fopen is guaranteed to be documented and
> >> available.[/color][/color][/color]
[color=blue][color=green]
> > Quite the reverse in a POSIX environment. A FILE* restricts you to
> > working with files, a file descriptor can be used for other entities
> > such as pipes and sockets.[/color][/color]
[color=blue][color=green]
> > I don't think I've ever use fopen in a Unix application.[/color][/color]
[color=blue]
> Interesting. I don't think I have ever actually used a POSIX
> system as such, so this is entirely new to me. Why can't
> pipes and sockets be mapped into streams?[/color]
They could be, but they normally aren't. I'm not sure whether
it would still be Posix conformant, but there's no reason why
fopen couldn't create a pipe, rather than open a file, if the
"filename" started with an "!". (Actually, I'm pretty sure that
it wouldn't be conformant, since you're allowed to have
filenames of actual files whose name starts with a "!".) And
Posix definitely does allow things like "//host:port/path"; if a
filename starts with "//", its meaning is implementation
defined.
[color=blue]
> For comparison, 25 years ago I had no difficulty mapping
> anything into Pascal files. That was proper Pascal, with f^,
> put, and get. Once you have the proper type for the file
> items, everything follows. Remember that Pascal creates new
> user types on demand, and those types can be records.[/color]
Yes, but you still needed some special mechanism to associate
the file type with its external support. The fact that file
types could be records is more like the fact that iostream in
C++ is a template: you're not changing the association with the
external entity, but rather the unit of data which is transfered
(instead of just char).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Re: programi parsing question
Keith Thompson <kst-u@mib.org> wrote:
[color=blue]
> CBFalconer <cbfalconer@yahoo.com> writes:[color=green]
> > Phlip wrote:[color=darkred]
> >> Yet open() _is_ the implementation. It's just not (apparently) in
> >> the narrowest C Standard.[/color]
> >
> > No, open() is not in ANY C implementation.[/color]
>
> Yes, it certainly is in many C implementations. It's not defined by
> the C standard, but it's allowed as an extension.
>
> C99 4p6:
>
> A conforming implementation may have extensions (including
> additional library functions), provided they do not alter the
> behavior of any strictly conforming program.
>
> open() is one of these "additional library functions".[/color]
Not so; a strictly conforming program may itself define open().
What a C implementation _may_ do is declaring open() in a non-Standard
header, since #including such a header renders a program not strictly
conforming anyway.
Whether that means that open() is in such a C implementation, or that
that implementation consists of a C implementation _plus_ a POSIX (or
whatever) library implementation, is something about which one could
debate until the cows come home. Fact remains that a _C_ program cannot
rely on open() being what the OP expects it to be, while a _C plus
POSIX_ program can.
Richard
Re: programi parsing question
[email]rlb@hoekstra-uitgeverij.nl[/email] (Richard Bos) writes:[color=blue]
> Keith Thompson <kst-u@mib.org> wrote:[color=green]
>> CBFalconer <cbfalconer@yahoo.com> writes:[color=darkred]
>> > Phlip wrote:
>> >> Yet open() _is_ the implementation. It's just not (apparently) in
>> >> the narrowest C Standard.
>> >
>> > No, open() is not in ANY C implementation.[/color]
>>
>> Yes, it certainly is in many C implementations. It's not defined by
>> the C standard, but it's allowed as an extension.
>>
>> C99 4p6:
>>
>> A conforming implementation may have extensions (including
>> additional library functions), provided they do not alter the
>> behavior of any strictly conforming program.
>>
>> open() is one of these "additional library functions".[/color]
>
> Not so; a strictly conforming program may itself define open().[/color]
Of course, but how does that disagree with what I wrote?
[color=blue]
> What a C implementation _may_ do is declaring open() in a non-Standard
> header, since #including such a header renders a program not strictly
> conforming anyway.[/color]
Right. On POSIX systems, open() is declared in <fcntl.h>.
[color=blue]
> Whether that means that open() is in such a C implementation, or that
> that implementation consists of a C implementation _plus_ a POSIX (or
> whatever) library implementation, is something about which one could
> debate until the cows come home. Fact remains that a _C_ program cannot
> rely on open() being what the OP expects it to be, while a _C plus
> POSIX_ program can.[/color]
Agreed.
A conforming implementation may have extensions. One such extension
is providing a function called "open" in a header called <fcntl.h>.
--
Keith Thompson (The_Other_Keith) [email]kst-u@mib.org[/email] <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Re: programi parsing question
In comp.unix.programmer Rainer Weikusat <rweikusat@mssgmbh.com> wrote:
| [email]phil-news-nospam@ipal.net[/email] writes:
|> In comp.unix.programmer Rainer Weikusat <rweikusat@mssgmbh.com> wrote:
|>
|> | I don't think that people who consider 'programming language grammar
|> | and syntax' to be 'a really hard problem' will ever write a useful
|> | program. That would be close to expecting first-graders struggling
|> | with expressing themselves in writing to publish enlightening treaties
|> | on epistemology. Programming languages are tools (or toys :-). The
|> | world is a complex thing and most of the (unsolved) problems that
|> | spring from it are hard problems in their own right. Solving them
|> | requires use of suitable tools, not necessarily familiar ones.
|>
|> I don't doubt there are problems where the familiarity of the tool is
|> overshadowed by the suitability of the tool. The lack of familiarity
|> with a tool can impose the cost of becoming familiar to some degree
|> based on what the problem is (I can't think of a case where it would
|> not). I happen to be unfamiliar with Java and barely familiar with
|> Perl. I could write a hello world program far faster in C simply
|> because I am familar with it.
|
| And how often have you been writing 'Hello, world'-programs because of
| an externally imposed requirement ('job') to do so lately? Not very
| often, I guess. The point I was trying to make is that a particular
| programming language is usually a non-negotiable part of some set of
| technical requirements. Eg, I ocassionally need to do modifications to
| a web portal which has been written in procedural PHP4 and it doesn't
| matter the least if $random_fashionable_language would initially have
| been the better choice. In a similar fashion, when I have to solve
| some so-called 'low-level' programming problem for 'our' device
| platform, the code will either be ARM9 assembly or C, because the
| devices have an ARM926SEJ-CPU and run a Linux (2.4) kernel.
Not all technical requirements specify a language. When a company does a
lot of programming and have decided on a language so that programmers can
each be assigned to do other projects, then it makes sense. If it's a Java
shop, then you are expected to code Java or not work there. If a project
leans towards being do in some other language, it can still be appropriate
to do it in Java, anyway, THERE.
A programmer who knows only Java, doing a new project on her own, will
almost certainly choose Java for projects that lean towards other languages.
That might reach a breaking point early if it's something better done in C.
But such projects tend to be not in the realm of most Java programmers.
Of course a lot of things can easily be done in a lot of languages. For
example: a web server
| Given the unholy amount of existing (OSS) software written in C which
| is lying around everywhere, I doubt that someone can seriously work on
| general 'programming tasks' without having a good, working knowledge
| of C. Not writing something from scratch in Java (here chosen because
| 'rewrite the world' is apparently very popular among Java-confined
| people), but adapating existing C code to a new task is going to be
| easier and faster and will lead to a higher quality product just
| because most parts of the existing code have already been debugged (by
| someone else).
That depends on how far the new task departs from the original thoughts of
the programmer of the code being reused.
| In some moderately distant past, I needed to interact with a
| Postscript-interpreter, so I learnt (and forgot :-) Postscript.
Oh those days :-) I hand coded some Postscript to make some interesting
artwork for some newspaper ads I was making. SVG is harder by comparison.
--
|WARNING: Due to extreme spam, googlegroups.com is blocked. Due to ignorance |
| by the abuse department, bellsouth.net is blocked. If you post to |
| Usenet from these places, find another Usenet provider ASAP. |
| Phil Howard KA9WGN (email for humans: first name in lower case at ipal.net) |
Re: programi parsing question
[email]phil-news-nospam@ipal.net[/email] writes:[color=blue]
> In comp.unix.programmer Rainer Weikusat <rweikusat@mssgmbh.com> wrote:
> | [email]phil-news-nospam@ipal.net[/email] writes:[/color]
[...]
[color=blue]
> |> I don't doubt there are problems where the familiarity of the tool is
> |> overshadowed by the suitability of the tool. The lack of familiarity
> |> with a tool can impose the cost of becoming familiar to some degree
> |> based on what the problem is[/color]
[...]
[color=blue]
> | And how often have you been writing 'Hello, world'-programs because of
> | an externally imposed requirement ('job') to do so lately? Not very
> | often, I guess. The point I was trying to make is that a particular
> | programming language is usually a non-negotiable part of some set of
> | technical requirements.[/color]
[...]
[color=blue]
> Not all technical requirements specify a language. When a company does a
> lot of programming and have decided on a language so that programmers can
> each be assigned to do other projects, then it makes sense. If it's a Java
> shop, then you are expected to code Java or not work there.[/color]
Which is precisely the situation I was writing about: It is required
that a particular language is to be used because of factors external
to the language itself. It doesn't matter if using some other language
would be advantageous because of .... and whoever is going to work on
this particular project will have to learn this language. This would
be an administrative and not a technical requirement, but it would
render any language except Java as unsuitable as a technical
requirement would.
Re: programi parsing question
Keith Thompson <kst-u@mib.org> wrote:
[color=blue]
> [email]rlb@hoekstra-uitgeverij.nl[/email] (Richard Bos) writes:[color=green]
> > Keith Thompson <kst-u@mib.org> wrote:[color=darkred]
> >> CBFalconer <cbfalconer@yahoo.com> writes:
> >> > Phlip wrote:
> >> >> Yet open() _is_ the implementation. It's just not (apparently) in
> >> >> the narrowest C Standard.
> >> >
> >> > No, open() is not in ANY C implementation.
> >>
> >> Yes, it certainly is in many C implementations. It's not defined by
> >> the C standard, but it's allowed as an extension.
> >>
> >> C99 4p6:
> >>
> >> A conforming implementation may have extensions (including
> >> additional library functions), provided they do not alter the
> >> behavior of any strictly conforming program.
> >>
> >> open() is one of these "additional library functions".[/color]
> >
> > Not so; a strictly conforming program may itself define open().[/color]
>
> Of course, but how does that disagree with what I wrote?[/color]
It means that open() may not exist for any strictly-C program.
[color=blue][color=green]
> > What a C implementation _may_ do is declaring open() in a non-Standard
> > header, since #including such a header renders a program not strictly
> > conforming anyway.[/color]
>
> Right. On POSIX systems, open() is declared in <fcntl.h>.[/color]
So open() is not actually in the _C_ implementation, but in the _POSIX_
implementation.
Richard
Re: programi parsing question
[email]rlb@hoekstra-uitgeverij.nl[/email] (Richard Bos) writes:[color=blue]
> Keith Thompson <kst-u@mib.org> wrote:[color=green]
>> [email]rlb@hoekstra-uitgeverij.nl[/email] (Richard Bos) writes:[color=darkred]
>> > Keith Thompson <kst-u@mib.org> wrote:
>> >> CBFalconer <cbfalconer@yahoo.com> writes:
>> >> > Phlip wrote:
>> >> >> Yet open() _is_ the implementation. It's just not (apparently) in
>> >> >> the narrowest C Standard.
>> >> >
>> >> > No, open() is not in ANY C implementation.
>> >>
>> >> Yes, it certainly is in many C implementations. It's not defined by
>> >> the C standard, but it's allowed as an extension.
>> >>
>> >> C99 4p6:
>> >>
>> >> A conforming implementation may have extensions (including
>> >> additional library functions), provided they do not alter the
>> >> behavior of any strictly conforming program.
>> >>
>> >> open() is one of these "additional library functions".
>> >
>> > Not so; a strictly conforming program may itself define open().[/color]
>>
>> Of course, but how does that disagree with what I wrote?[/color]
>
> It means that open() may not exist for any strictly-C program.[/color]
Of course. Again, how does that disagree with what I wrote?
[color=blue][color=green][color=darkred]
>> > What a C implementation _may_ do is declaring open() in a non-Standard
>> > header, since #including such a header renders a program not strictly
>> > conforming anyway.[/color]
>>
>> Right. On POSIX systems, open() is declared in <fcntl.h>.[/color]
>
> So open() is not actually in the _C_ implementation, but in the _POSIX_
> implementation.[/color]
Which is (or at least may be) part of the C implementation. It's an
*extension*. It's an additional library function that doesn't alter
the behavior of any strictly conforming program. It is therefore
something that a conforming C implementation is allowed to have.
--
Keith Thompson (The_Other_Keith) [email]kst-u@mib.org[/email] <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"