Guile Mailing List Archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New smob interface



In your post re: SMOB documentation, you wrote:

In this case he needs to use the following idiom:

/* begin */
SCM
scm_make_my_type (int a, SCM b)
{
  SCM z;
  my_type_t *m = scm_must_malloc (sizeof (my_type_t), "my-type");
  m->a = a;
  m->b = b;
  SCM_NEWSMOB (z, my_type, m);
  return m;
}
/* end */

Shouldn't the "return m" be "return z"?

What do you folks think about a RETURN_SCM_NEWSMOB macro that would let
users write:

SCM
scm_make_my_type (int a, SCM b)
{
  my_type_t *m = scm_must_malloc (sizeof (my_type_t), "my-type");
  m->a = a;
  m->b = b;
  RETURN_SCM_NEWSMOB (my_type, m);
}

with:

#define RETURN_SCM_NEWSMOB(t,m) do { SCM __guile_smob_answer; \
                                     SCM_NEWSMOB(__guile_smob_answer,(t),(m));\
                                     return __guile_smob_answer; } while (0)

?

Thanks,
Greg

Guile Home | Main Index | Thread Index