9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Charles Forsyth <charles.forsyth@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] go forth and ulong no more!
Date: Thu, 22 Nov 2012 11:32:34 +0000	[thread overview]
Message-ID: <CAOw7k5hDFwcevDmfhHdvgVSSTBJ_3DZ_yX_uSAMCcM+VmBgqAQ@mail.gmail.com> (raw)
In-Reply-To: <8a7bc276ced4ae75de62a296b99c1efb@hamnavoe.com>

To try to clarify: most existing Plan 9 code doesn't worry about the
actual type of sizeof or pointer differences.
They assume int/long or uint/ulong. It's obvious from this discussion
that hardly anyone noticed usize.
Since its introduction years ago, grep shows that only kernel code has
used usize. size_t is more
popular in ANSI C code, but I suspect even there neither size_t nor
ptrdiff_t are used everywhere they ought to be. An arbitrary sample
(my src directory on Linux) shows 4995 uses of size_t, and only 54 of
ptrdiff_t, but perhaps pointer subtraction just isn't that common.

That's why I say that it would be better to make int and uint the same
size as uintptr, although it's a bit of a waste,
since existing code that needs bigger int values will use another
type, but after the change it's easy to have code casually assume 64
bits.

One reason 6c doesn't make int and long 64 bits is that it's quite
hard to find code (automatically) that assumes they are 32 bits.
Hence the drive to use explicit types when it matters.

Again, I'll note that erik's manual page doesn't propose or introduce
anything new: even allowing for the ill-chosen "typically" and
"usually"
it is still a fair reflection of the current state, or aims to be.
Perhaps the unfortunate qualifications should be in BUGS.

On 22 November 2012 11:10, Richard Miller <9fans@hamnavoe.com> wrote:
>> usize is indeed the same size as uintptr.
>> Instead of either for purely integer values, it would be better to
>> make all integers 64 bit
>
> I hope that was intended as a joke.  It's not that long ago I was
> writing C for a 16-bit processor (in a smart card).  I would hate to
> lose the meaning of "int" as "whatever fits in a CPU register".
>
>



  parent reply	other threads:[~2012-11-22 11:32 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-20 21:49 erik quanstrom
2012-11-22  0:18 ` Federico G. Benavento
2012-11-22  1:21   ` erik quanstrom
2012-11-22  1:35     ` Bruce Ellis
2012-11-22  2:08       ` Dan Cross
2012-11-22  2:15         ` Bruce Ellis
2012-11-22  2:33           ` Charles Forsyth
2012-11-22  2:35             ` Charles Forsyth
2012-11-22  3:44               ` Bruce Ellis
2012-11-22  8:56                 ` Charles Forsyth
2012-11-22  9:02                 ` Charles Forsyth
2012-11-22 10:21                   ` erik quanstrom
2012-11-22 11:00                     ` Richard Miller
2012-11-22 11:11                       ` Charles Forsyth
2012-11-22 11:13                         ` Charles Forsyth
2012-11-22 11:32                         ` Richard Miller
2012-11-22 11:38                           ` Charles Forsyth
2012-11-22 11:49                       ` erik quanstrom
2012-11-22 13:26                         ` Richard Miller
2012-11-22 14:05                           ` Charles Forsyth
2012-11-22 14:53                           ` erik quanstrom
2012-11-22 11:50                       ` erik quanstrom
2012-11-22 11:10                   ` Richard Miller
2012-11-22 11:13                     ` Charles Forsyth
2012-11-22 11:32                     ` Charles Forsyth [this message]
2012-11-22 11:33                       ` Charles Forsyth
2012-11-22 10:31                 ` Charles Forsyth
2012-11-22 12:39                   ` Anthony Martin
2012-11-22 12:48                     ` Charles Forsyth
2012-11-22 12:50                       ` Charles Forsyth
2012-11-22 12:54                       ` Anthony Martin
2012-11-22 13:08                         ` Charles Forsyth
2012-11-22  9:59       ` Charles Forsyth
2012-11-22  9:38     ` Charles Forsyth
2012-11-22  9:40       ` Charles Forsyth
2012-11-22 18:18       ` Federico G. Benavento
2012-11-22 11:36 Richard Miller
2012-11-22 11:45 ` Charles Forsyth
2012-11-22 11:54 ` Steve Simon
2012-11-22 11:59   ` Charles Forsyth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOw7k5hDFwcevDmfhHdvgVSSTBJ_3DZ_yX_uSAMCcM+VmBgqAQ@mail.gmail.com \
    --to=charles.forsyth@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).