unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Thien-Thi Nguyen <ttn@glug.org>
Cc: Guile-user@gnu.org
Subject: Re: Enumeration in GUILE
Date: Thu, 09 Oct 2003 07:32:03 -0400	[thread overview]
Message-ID: <E1A7Z1X-0003vq-00@colo.agora-net.com> (raw)
In-Reply-To: <OF7B9D474D.76DEE374-ON65256DBA.002762EE-65256DBA.0028CF62@ad.skynet> (dv.praveen@skyworksinc.com)

   From: dv.praveen@skyworksinc.com
   Date: Thu, 9 Oct 2003 12:55:45 +0530

   typedef enum { FIRST, SECOND, THIRD, NONE) CHOICE;

   Is it possible to get these enums recognized by GUILE.

   guile> (my-choice-is FIRST)

there are three approaches: variables, symbols and keywords.  for
variables, you need to choose a symbol for each element, bind an integer
value to it, and arrange for your functions to accept numeric integers.
for symbols, your functions should accept symbols and translate them to
integers internally.  similarly for keywords.

using variables is a step backward in some sense.  even though the
symbols and keywords approach is a little more work to put in place, it
makes debugging simpler on the scheme side; a backtrace w/ symbols is
less work to understand than a backtrace w/ integers.  (presuming your
stuff is not buggy at the C level -- if that's the case, you have to
take care of that first. :-)

thi


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


      parent reply	other threads:[~2003-10-09 11:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-09  7:25 Enumeration in GUILE dv.praveen
2003-10-09 11:27 ` Andreas Rottmann
2003-10-09 11:32 ` Thien-Thi Nguyen [this message]

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=E1A7Z1X-0003vq-00@colo.agora-net.com \
    --to=ttn@glug.org \
    --cc=Guile-user@gnu.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).