Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.fortran Subject: Re: Cheating on the types Message-ID: <5033@goanna.cs.rmit.oz.au> Date: 22 Mar 91 06:27:45 GMT References: <1991Mar20.195732.15376@appmag.com> <10146@exodus.Eng.Sun.COM> <1991Mar21.201340.3271@cunixf.cc.columbia.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 26 In article <1991Mar21.201340.3271@cunixf.cc.columbia.edu>, shenkin@cunixf.cc.columbia.edu (Peter S. Shenkin) writes: > Another application: suppose in a large program you want to write your > own routing routines to do IO, which will write to one or more files, and/or > the screen, etc., depending on the setting of various control variables. You > might want to pass a format string plus a variable or two to the routine. > But the variable's type might vary from invocation to invocation. If you can't > cheat on types, I don't think you can do this in Fortran. You can't do it *that* *way*. But you can do the routing! All you have to do is write to a character variable, and pass the already-formatted text to the routing routines. Let's face it, type cheating or no type cheating, there is no way you can pass an implied-DO as a subroutine parameter, so you aren't going to be able to do a thorough job of mimicking WRITE anyway. The 4.4BSD routines and Turbo Pascal and Quintus Prolog and Pop and many many Lisp implementations and dozens of other systems provide a way for users to define their own streams by providing record transfer procedure. The record transfer procedures don't need to "cheat", because they are only ever given and only ever deliver character arrays/ strings. There is no reason why a Fortran implementation could not give you *as an non-standard extension* a way of opening a logical unit with record transfer going through specified user-provided routines. -- Seen from an MVS perspective, UNIX and MS-DOS are hard to tell apart.