>>>>> "H" == Hugh Sasse Staff Elec Eng <hgs / dmu.ac.uk> writes:

H> But how does it work?  Does it use 'type' to find this, or is there
H> some language feature I should be aware of that I'm not.

static VALUE
marshal_dump(argc, argv)
    int argc;
    VALUE* argv;
{
    VALUE obj, port, a1, a2;
    int limit = -1;
    struct dump_arg arg;
    struct dump_call_arg c_arg;

    port = 0;
    rb_scan_args(argc, argv, "12", &obj, &a1, &a2);
    if (argc == 3) {
	if (!NIL_P(a2)) limit = NUM2INT(a2);
	port = a1;
    }
    else if (argc == 2) {
	if (FIXNUM_P(a1)) limit = FIX2INT(a1);
	else port = a1;
    }

#define FIXNUM_P(f) (((long)(f))&FIXNUM_FLAG)
#define FIXNUM_FLAG 0x01

H> Hmmm, The Book says its 100.

 marshal.c (ruby-1.6.1)

[..]
    if (limit == 0) {
	rb_raise(rb_eArgError, "exceed depth limit");
    }
[...]
    else {
	long num;

	limit--;
[...]
static VALUE
marshal_dump(argc, argv)
    int argc;
    VALUE* argv;
{
    VALUE obj, port, a1, a2;
    int limit = -1;
[...]
 


Guy Decoux