This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: interface reductions
- To: Marius Vollmer <mvo at zagadka dot ping dot de>
- Subject: Re: interface reductions
- From: Dirk Herrmann <dirk at ida dot ing dot tu-bs dot de>
- Date: Wed, 31 May 2000 08:00:12 +0200 (MEST)
- cc: Guile Mailing List <guile at sourceware dot cygnus dot com>
On 30 May 2000, Marius Vollmer wrote:
> Dirk Herrmann <dirk@ida.ing.tu-bs.de> writes:
>
> > For example: Fluids can't currently be garbage collected, just because
> > users might store the integer reference to it instead of a SCM value. So,
> > I can easily break guile by creating lots of fluids and not use them any
> > longer: They live forever even without references. That's bad.
>
> Yes, that's a good point. I can't argue against that. So feel free
> to make any necessary changes.
The proposed change is shown as a patch below. It basically deprecates
SCM_FLUID_NUM, SCM_FAST_FLUID_REF and SCM_FAST_FLUID_SET_X, and provides
as a replacement for these the macros SCM_FLUID_DATA and
SCM_SET_FLUID_DATA. If there are suggestions for better names, I'd be
happy to hear them. Otherwise I am going to apply that patch.
Best regards
Dirk
Index: fluids.h
===================================================================
RCS file: /cvs/guile/guile/guile-core/libguile/fluids.h,v
retrieving revision 1.10
diff -u -r1.10 fluids.h
--- fluids.h 2000/05/25 09:21:06 1.10
+++ fluids.h 2000/05/31 05:53:34
@@ -76,20 +76,9 @@
extern long scm_tc16_fluid;
#define SCM_FLUIDP(x) (!SCM_IMP (x) && (SCM_CELL_TYPE (x) == scm_tc16_fluid))
-#define SCM_FLUID_NUM(x) (SCM_CELL_WORD_1 (x))
-
-/* The fastest way to acces/modify the value of a fluid. These macros
-do no error checking at all. You should only use them when you know
-that the relevant fluid already exists in the current dynamic root.
-The easiest way to ensure this is to execute a SCM_FLUID_SET_X in the
-topmost root, for example right after SCM_MAKE_FLUID in your
-SCM_INIT_MUMBLE routine that gets called from SCM_BOOT_GUILE_1. The
-first argument is the index number of the fluid, obtained via
-SCM_FLUID_NUM, not the fluid itself. */
+#define SCM_FLUID_DATA(x) (SCM_VELTS (scm_root->fluids) [SCM_CELL_WORD_1 (x)])
+#define SCM_SET_FLUID_DATA(x, v) (SCM_VELTS (scm_root->fluids) [SCM_CELL_WORD_1 (x)] = v)
-#define SCM_FAST_FLUID_REF(n) (SCM_VELTS(scm_root->fluids)[n])
-#define SCM_FAST_FLUID_SET_X(n, val) (SCM_VELTS(scm_root->fluids)[n] = val)
-
SCM scm_make_fluid (void);
SCM scm_fluid_p (SCM fl);
SCM scm_fluid_ref (SCM fluid);
@@ -105,6 +94,16 @@
void scm_swap_fluids_reverse (SCM fluids, SCM vals);
void scm_init_fluids (void);
+
+
+
+#if (SCM_DEBUG_DEPRECATED == 0)
+
+#define SCM_FLUID_NUM(x) (SCM_CELL_WORD_1 (x))
+#define SCM_FAST_FLUID_REF(n) (SCM_VELTS (scm_root->fluids) [n])
+#define SCM_FAST_FLUID_SET_X(n, val) (SCM_VELTS (scm_root->fluids) [n] = val)
+
+#endif /* SCM_DEBUG_DEPRECATED == 0 */
#endif /* !FLUIDSH */