9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Lyndon Nerenberg (VE6BBM/VE7TFX)"  <lyndon@orthanc.ca>
To: 9fans@9fans.net
Subject: Re: [9fans] NaN, +Inf, and -Inf, constants?
Date: Mon,  8 Feb 2010 09:39:39 -0700	[thread overview]
Message-ID: <5cf02fd3b416bf1db1b7c58217511630@yyc.orthanc.ca> (raw)
In-Reply-To: <b5e37becf9e504113a9352ff3ca2dfac@brasstown.quanstro.net>

> why does being able to switch on any enum trump
> the ability to define constants without #define?

Because enum's legacy is that of a 'first class' int-like
object, which can be subject to the usual set of int-like
operations. switch() is one of those. #define isn't.

> if you try, sizeof(foo)==4, but you'll need to remove
> 'd' since you can't have a string.  you can't switch on
> a vlong or float.  would be nice, though.

Why not a string? If you can extend an enum to include floats,
why not an integer representation of a pointer?

And yes, I also think switching on vlongs would be useful.

> the plan 9 style is never to typedef or name enums.

It may not be the style for the Labs, but that's not the case for
everyone.  The compile time type checking named enums provide isn't
something I'd want to lose.

> if it were an error to name or typedef an enum
> containing non-int members, there would be no
> problem.

This could work. But I have to agree with Bakul: 'static const'
is a much better fit for the language.

--lyndon




  reply	other threads:[~2010-02-08 16:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-06 15:38 Tristan Plumb
2010-02-06 15:57 ` erik quanstrom
2010-02-06 17:14   ` Tristan Plumb
2010-02-07 16:12     ` erik quanstrom
2010-02-07  0:06 ` Russ Cox
2010-02-07 10:46   ` Charles Forsyth
2010-02-07 11:05     ` Charles Forsyth
2010-02-07 20:01     ` Russ Cox
2010-02-07 20:31       ` erik quanstrom
2010-02-07 21:33       ` Charles Forsyth
2010-02-07 22:19         ` Lyndon Nerenberg (VE6BBM/VE7TFX)
2010-02-07 22:37           ` erik quanstrom
2010-02-08 16:39             ` Lyndon Nerenberg (VE6BBM/VE7TFX) [this message]
2010-02-08 18:48               ` Russ Cox
2010-02-07 23:16           ` Bakul Shah

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=5cf02fd3b416bf1db1b7c58217511630@yyc.orthanc.ca \
    --to=lyndon@orthanc.ca \
    --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).