🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #8400

Re: 'C' style etc...

#8400
From: Peter da Silva
Date: Thu, 14 Apr 1988 16:33
32 lines
2101 bytes
In article <8572@agate.BERKELEY.EDU>, doug@eris (Doug Merritt) writes:
> [ re: long character constants like "case 'REXX':" ]

> Well, not really, although it sounds good at first...Consider that C
> does not even require longs to be 32 bits. But 'REXX' definitely does
> require 32 bits.

What this really is is an unsigned integer containing the characters.
You can do this in FORTRAN, even. 
Anyway, if there aren't enough bits in a long to support the string
'REXX', then it should be flagged as a warning.

> Also, what you're really doing is a form of character
> array packing.

What makes you say this? It's just a way of specifying another bit pattern
that a long can have. It's just more convenient than 0x52455858L. Just
as 'a' is more convenient than 0x61. There are lots of languages that
don't even provide a consistent method of specifying 1-character constants.
Pascal, for instance (quick, is 'a' a character or a string?).

> What people usually want is to be able to put ANYTHING in a switch
> statement, and in fact a number of languages have been developed that
> allow this. It just turns into syntactic-sugar for a sequence of if-
> then-elses.

It doesn't have to be in a switch statement. Lots of programs use character
constants for tokens, for all sorts of purposes.
-- 
-- Peter da Silva      `-_-'      ...!hoptoad!academ!uhnix1!sugar!peter
-- "Have you hugged your U wolf today?" ...!bellcore!tness1!sugar!peter
-- Disclaimer: These aren't mere opinions, these are *values*.
Technical Details
Message-ID: <1832@sugar.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!uwvax!rutgers!bellcore!tness7!tness1!sugar!peter
References: <8647@eddie.MIT.EDU> <893@nuchat.UUCP> <8449@agate.BERKELEY.EDU> <8572@agate.BERKELEY.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!uwvax!rutgers!bellcore!tness7!tness1!sugar!peter
From: peter@sugar.UUCP (Peter da Silva)
Newsgroups: comp.sys.amiga.tech,comp.lang.c
Subject: Re: 'C' style etc...
Message-ID: <1832@sugar.UUCP>
Date: 14 Apr 88 16:33:09 GMT
References: <8647@eddie.MIT.EDU> <893@nuchat.UUCP> <8449@agate.BERKELEY.EDU> <8572@agate.BERKELEY.EDU>
Organization: Sugar Land UNIX - Houston, TX
Lines: 32
Keywords: K&R, nonstandard constructs, multi-char char constsants, hashing
Summary: It's not a character constant, it's an unsigned integer.