> > It never fails to amaze me just how many people do this:
> > if (foo == NULL) { ... }
> > or:
> > if (foo == 0) { ... }
> [instead of...]
> > if (!foo) { ... }
>
> Well, I wrote it the way you think people ought to for 8 years before
> changing to coding the test explicitly. I changed because the (!foo)
> notation is less readable than the (foo == 0) notation.
Amen. The three constructs given have exactly the same meaning in C (yes,
wait for the explanation, it's true) and any good compiler will produce
exactly the same code for them. However, "!foo" is suggestive of testing
for the falsity of a Boolean (yes, I know C doesn't have a formal Boolean
type, but that's the proper way to think of something with values meaning
"true" and "false"), while "foo == NULL" is suggestive of testing whether a
pointer is null or not, and "foo == 0" is suggestive of testing whether an
integral value is zero or not.
> Also, if foo is a pointer type, the test (!foo) is wrong. NULL doesn't
> have to be zero.
Oh, yes it does. A null pointer need not have a bit pattern consisting of
all zeroes. However, the value of a null pointer is constructed in
C by converting the integral constant 0 to a pointer type. In the construct
"foo == 0", the LHS is a pointer, so the compiler knows enough to convert
the "0" on the RHS to a pointer of the same type, hence a null pointer of
the appropriate type. (No, I won't cite the K&R/ANSI C draft which says
this; seek and ye shall find.)
As such, NULL should be #defined as 0 - NOT "(char *)0", because that
causes the compiler to get annoyed when you compare an "int *" against NULL,
since you're comparing two different kinds of pointers.
> > The reason the compiler is exhibiting the behavior you describe is
> >because you told it to. You are asking the compiler to compare an unsigned
> >byte to the literal value of NULL.
Which should always be 0. As such, in the example given,
if (var == NULL) ...
is identical to
if (var == 0) ...
and should generate the same code; as the author of the response to the
above comment points out, there is NO reason to extend a 1-byte variable
"var" to 4 bytes when doing this.
--
Guy Harris
{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
g...@sun.com (or g...@sun.arpa)
In article <22...@utcsstat.uucp> spe...@utcsstat.UUCP writes:
>But at current prices can Gary provide support for UNIX|STAT?
I can't provide support, except that I try to help out people if
they can't get the package running on a new UNIX machine (there
are about 20 hardware-software combinations running |STAT on UNIX).
>Will he mail out updates to all users?
About once a year, I send out an announcement of what is in the
new release, and it is up to the user to order it, if they think
the enhancements are worth the extra $15 for MSDOS or $20 for
UNIX. People can freely copy the package, both on and off site,
so it is not possible for me to get information about updates to
all users.
>Will he provide telephone support during business hours?
This is something that a computer center would want, and something
I definately will not provide.
>Is his (optional) documentation typeset and bound?
It is typeset on paper, and stapled between heavy paper covers.
I charge $10 for the handbook, and $5 for printed versions of the
online manual entries. To be honest, I don't care if people make
copies.
>How extensive is the documentation?
It is meant for people familiar with running commands like DIR,
DEL, COPY, and SORT on MSDOS, or similar commands on UNIX. It can
get a lot of whining from undergraduates if they don't get a lot
of hand holding, but I have seen many undergraduate courses use it
effectively.
>It's tough to deliver lots of service when it's a hobby and not a business.
You bet, and the person who requests |STAT must be willing to
spend the time to read the manuals carefully. However, individual
programs do not need much support, because they are UNIX style
tools; how much support does someone need for a descriptive stats
program that reads all the numbers in its input? One feature I like
about the |STAT programs is that they can be used away from data
analysis; there are several programs for text manipulation in
files. The major problems with learning |STAT is in learning how
to make the programs work together, through pipelines. Consider
the following command line to make a 5x5 matrix of uniformly
random numbers drawn from 1..25 with replacement:
probdist random uniform 25 | dm floor(x1*25+1) | maketrix 5
or without replacement:
series 1 25 | perm | maketrix 5
These are intuitive to a UNIX user, but it takes a while for
students struggling with MSDOS to learn the tricks.
>They can both run on vanilla PCs with 256K and two floppies.
|STAT runs on vanilla MSDOS, not just IBM PC's. People have
told me they have the programs running on AT&T, DEC, Tandy, adn
Wang PC's. You don't even need two floppies, but the thought of
doing anything on a PC with just one floppy make me queasy.
>We've tried PowerStat here
>at the University of Toronto in several classes: students find it very easy to
>learn and use. Much more so than SAS (which we formerly used on the
>mainframe).
Although I think SAS provides the most functionality of any PC
stat package, I don't think it is necessary or appropriate for
student instruction. I am not even sure that my |STAT is
appropriate for students, given that there is no student manual,
only a users manual.
>I'd like to see more good statistical software for PCs--I don't think that
>we should sit back and let SAS Institute do it all (good as they are). We
>need innovative approaches like Gary Perlman's UNIX|STAT and Analytical
>Engineering's PowerStat.
As PC's get faster, and mass storage cheaper, SAS will become more
palatable. I hope there is enough competition to motivate SAS to
get better and cheaper. Stat packages seem to be a good candidate
for commodity pricing sometime in the future.
--
Gary Perlman Wang Institute Tyngsboro, MA 01879 (617) 649-9731
UUCP: decvax!wanginst!perlman CSNET: perlman@wanginst
UNIX|STAT 5.2
Gary Perlman
DATA MANIPULATION & ANALYSIS PROGRAMS
FOR UNIX and MSDOS
UNIX|STAT is a set of over 20 data manipulation and analysis programs
developed at the University of California, San Diego and at the Wang
Institute of Graduate Studies by Gary Perlman. The programs are designed
with the UNIX philosophy that individual programs should be designed as
tools that do one task well and produce output suitable for input via pipes
to other programs. Interactive use is supported in the command line
interpreter which also provides a programming language for complex
analyses. Typical usage involves a pipeline of transformations of data
followed by input to an analysis program, summarized schematically by:
INPUT DATA | TRANSFORM | ANALYSIS | OUTPUT RESULTS
Functions built into many statistical packages (e.g., graphics and editing)
are not re-invented in UNIX|STAT which delegates such responsibility to
standard tools.
DATA MANIPULATION PROGRAMS:
abut join data files
colex column extraction
dm column oriented data manipulator
dsort multiple key data sorting filter
maketrix create matrix type file from free-form file
perm permute line order
probdist probability distribution functions
ranksort rank order columns
repeat repeat a pattern or file
reverse reverse lines, columns, and characters
series generate a series of numbers
transpose transpose matrix type file
validata verify data file consistency
DATA ANALYSIS PROGRAMS:
anova multi-factor analysis of variance
calc interactive algebraic modeling calculator
contab contingency tables and chi-square
desc descriptions histograms, frequency tables
dprime signal detection d' and beta calculations
oneway one-way anova and t-test with error-bar plots
pair paired data statistics, regression, plots
regress multivariate linear regression and correlation
stats report summary statistics
ts time series analysis and plots
FEATURES:
easy to use programs (negligible training period)
simple input formats (free format field oriented)
used in pipelines with other utilities (sort, print)
flexible data manipulation
several simple lineprinter plotting options
data validation (range and type checking)
documentation includes online manual entries, Handbook
consistent option conventions with online help
runs on any UNIX System (V6, V7, 2.8BSD, 4BSD, System V, etc.)
runs on MSDOS 2.0 and 3.0 with 96K (IBM, Wang, AT&T, etc.)
usually less than a few seconds per analysis
liberal copyright (but can't be distributed for gain)
in use at hundreds of MSDOS and UNIX sites since 1980
WARRANTY AND DISTRIBUTION CONDITIONS:
Carefully read the following warranty and conditions. If you do not
find them acceptable, you should not order or use UNIX|STAT.
Warranty. UNIX|STAT is provided ``as is'' and without any warranty
expressed or implied. There is no claim that UNIX|STAT is suited to your
needs, nor that it will run on your particular hardware/software
configuration. The availability of and programs in UNIX|STAT may change
without notice.
Copyright Conditions. You may make copies of the programs, in source,
object, or binary form, and you may make copies of the ONLINE pre-formatted
manual entries, provided that there is no material gain involved, and
provided that the information in this flyer accompanies every copy. You
may not modify the source code for any purposes other than getting the
programs to work on your system. You may not distribute any modified
source code to any sites other than your own. Any costs in compiling or
porting UNIX|STAT to your system are your's alone, and not any other
parties.
Use At Your Own Risk. All risk of loss of any kind due to use of
UNIX|STAT is with you, the user. You are responsible for all mishaps, even
if the programs prove to be defective. You must be trained at your expense
to learn to use the programs. In particular, you are hereby given fair
warning that data analysis programs make many assumptions about data, These
assumptions affect the validity of conclusions you may make based on the
programs. References to appropriate statistical sources are made in the
UNIX|STAT Handbook and in the manual entries for specific programs.
ORDERING INFORMATION:
Carefully read the instructions below. Orders not following them may
be be returned or even discarded. All prices include delivery and should
be prepaid to G. Perlman. Checks must be in US funds, drawn on a US bank.
Orders that include any terms or conditions other than those in this notice
may be returned or discarded. Company purchase orders should be avoided in
favor of a personal check, with a request for a receipt if needed. Orders
must include a delivery mailing label acceptable to the post office, and
international orders must include the country name on the label. Orders
without mailing labels may not be deliverable or returnable.
UNIX Version of UNIX|STAT:
Price: $20
Contents: Program (C language) & Manual (troff) Source Files
Space: 450K bytes for source and manuals, 450K bytes for binaries
Format: 600 foot half inch 9 track mag tape, 1600 bpi tar format
MSDOS Version of UNIX|STAT:
Price: $15
Contents: Preformatted Manuals and Executables
Space: 700K for binaries and online manuals
Format: 2S/2D MSDOS 5.25 inch floppy diskettes
Handbook:
Price: $10
Contents: Examples, Conventions, Reference Materials, CALC & DM Manuals
Format: Printed Manual (~70 pages)
Printed Manual Entries:
Price: $5
Contents: Typeset Versions of Manual Entries, Reference Sheets
Format: Printed Manual (~30 pages)
CONTACT:
Gary Perlman
Wang Institute of Graduate Studies
Tyng Road
Tyngsboro, MA 01879 USA
UUCP: decvax!wanginst!perlman CSNET: perlman@wanginst
NOTES:
UNIX is a trademark of AT&T Bell Laboratories.
MSDOS is a trademark of MicroSoft.
UNIX|STAT is NOT a product of any company or organization.
>
> >I'd like to see more good statistical software for PCs--I don't think that
> >we should sit back and let SAS Institute do it all (good as they are). We
> >need innovative approaches like Gary Perlman's UNIX|STAT and Analytical
> >Engineering's PowerStat.
> As PC's get faster, and mass storage cheaper, SAS will become more
> palatable. I hope there is enough competition to motivate SAS to
> get better and cheaper. Stat packages seem to be a good candidate
> for commodity pricing sometime in the future.
>
> Ian Spence {allegra,decvax,seismo,utzoo,watmath}!utcs!utcsstat!spence
> --
> Gary Perlman Wang Institute Tyngsboro, MA 01879 (617) 649-9731
> UUCP: decvax!wanginst!perlman CSNET: perlman@wanginst
There are quite a few good statistics packages for the PC:
Statgraphics
Systat
Statpac
Stats-2
Statpro
to name a few. All run on the PC (vanilla included, I'm sure). Systat and
Statgraphics are probably the best selling.
Statgraphics, Systat, Statpac, Stats-2, Statpro are all trademarks of their
respective companies.
--
-- Ed.
Net : {noao!ihnp4!yale!}!hsi!tankus
Snail: Health Systems Int'l, 100 Broadway, New Haven, CT 06511
Bell : (203) 562-2101