unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Enumeration in GUILE
@ 2003-10-09  7:25 dv.praveen
  2003-10-09 11:27 ` Andreas Rottmann
  2003-10-09 11:32 ` Thien-Thi Nguyen
  0 siblings, 2 replies; 3+ messages in thread
From: dv.praveen @ 2003-10-09  7:25 UTC (permalink / raw)


hi all,

I am creating new data types using smobs
in my application.  In the process I have
used some enums like

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

Is it possible to get these enums recognized by GUILE.
For instance, I have my own function,
"my-choice-is" which I would like to use it as.

guile> (my-choice-is FIRST)

If it is not possible is there a hack how I can use
it?

regards,
Praveen


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Enumeration in GUILE
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Rottmann @ 2003-10-09 11:27 UTC (permalink / raw)
  Cc: Guile-user

dv.praveen@skyworksinc.com writes:

> hi all,
>
> I am creating new data types using smobs
> in my application.  In the process I have
> used some enums like
>
> typedef enum { FIRST, SECOND, THIRD, NONE) CHOICE;
>
> Is it possible to get these enums recognized by GUILE.
> For instance, I have my own function,
> "my-choice-is" which I would like to use it as.
>
> guile> (my-choice-is FIRST)
>
> If it is not possible is there a hack how I can use
> it?
>
You may want to have a look at g-wrap, which is able to do this.

Regards, Andy
-- 
Andreas Rottmann         | Rotty@ICQ      | 118634484@ICQ | a.rottmann@gmx.at
http://www.8ung.at/rotty | GnuPG Key: http://www.8ung.at/rotty/gpg.asc
Fingerprint              | DFB4 4EB4 78A4 5EEE 6219  F228 F92F CFC5 01FD 5B62

Make free software, not war!


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Enumeration in GUILE
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2003-10-09 11:32 UTC (permalink / raw)
  Cc: Guile-user

   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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-10-09 11:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).