closure_to_string() output

4 views
Skip to first unread message

Stephan Weinberger

unread,
Sep 1, 2023, 12:57:48 PM9/1/23
to LDMud Talk
Hello,

I'm having difficulties figuring out the output of closure_to_string():

e.g. when I get output like

#'domains/huegelland/thyrsis/ratstempel/room/gang_034(domains/huegelland/thyrsis/ratstempel/room/gang_034)->check_workroom()
from domains/huegelland/thyrsis/ratstempel/room/std_gang.c line 43

What do the different parts mean? I'm particularly confused about the
first two parts; why the duplication?
From what I can see in the code, the part in brackets is added if
"is_inherited" is true, but this seems to be set as soon as the objects
inherits anything (i.e. basically always) and the closure is from one of
the inherits (which is printed as "from ... line ..." anyways). So the
info seems kinda redundant, unless I'm missing something.


Also as a sidenote: we're running native mode, so shouldn't the program
names start with "/" (like they do with program_name())?

cya
  Invis


Gnomi

unread,
Sep 25, 2023, 4:13:53 PM9/25/23
to ldmud...@googlegroups.com
Hi Invisible,

Stephan Weinberger schrieb:
> I'm having difficulties figuring out the output of closure_to_string():
>
> e.g. when I get output like
>
> #'domains/huegelland/thyrsis/ratstempel/room/gang_034(domains/huegelland/thyrsis/ratstempel/room/gang_034)->check_workroom()
> from domains/huegelland/thyrsis/ratstempel/room/std_gang.c line 43
>
> What do the different parts mean?

The full format is
#'[bound object]target object(target inherit)->function name()
from creating program

> I'm particularly confused about the first two parts; why the duplication?

How did you create that closure? And this something happen to the object
like a replace_program()?

Normally the second part will only be printed if the target program
(inherit) is a different than the main program (object).

> From what I can see in the code, the part in brackets is added if
> "is_inherited" is true, but this seems to be set as soon as the objects
> inherits anything (i.e. basically always)

is_inherited is set, if the closure has a non-NULL .inhProg entry or
the function lookup revealed an inherit, see closure_lookup_lfun_prog().

> and the closure is from one of the
> inherits (which is printed as "from ... line ..." anyways).

The from line is about the creation of the closure, that could be an
entirely different program (e.g. when using symbol_function()).

> So the info
> seems kinda redundant, unless I'm missing something.
>
>
> Also as a sidenote: we're running native mode, so shouldn't the program
> names start with "/" (like they do with program_name())?

Yes, they should. We haven't fixed all those missing slashes in fear we
would break mudlibs. This will be part of the cleanup for LDMud 3.7.

Greetings,
Gnomi

Stephan Weinberger

unread,
Sep 26, 2023, 2:25:50 PM9/26/23
to ldmud...@googlegroups.com
Hoi Gnomi,


On 25.09.23 22:13, Gnomi wrote:
> Hi Invisible,
>
> Stephan Weinberger schrieb:
>> I'm having difficulties figuring out the output of closure_to_string():
>>
>> e.g. when I get output like
>>
>> #'domains/huegelland/thyrsis/ratstempel/room/gang_034(domains/huegelland/thyrsis/ratstempel/room/gang_034)->check_workroom()
>> from domains/huegelland/thyrsis/ratstempel/room/std_gang.c line 43
>>
>>
>
> How did you create that closure? And this something happen to the object
> like a replace_program()?

The closure is created in room/std_gang.c, which is inherited by
room/gang_034.c. Simply with "#'check_workroom".

No replace_program() or the like, just a plain inherit and all blueprint
objects.

The function is also implemented in room/std_gang.c.


>
> Normally the second part will only be printed if the target program
> (inherit) is a different than the main program (object).

so it should say "room/gang_034(room/std_gang)" or just "room/gang_034
from room/std_gang", shouldn't it?


salve,

  Invis.

Gnomi

unread,
Sep 26, 2023, 4:02:16 PM9/26/23
to ldmud...@googlegroups.com
Hi Invisible,

Stephan Weinberger wrote:
> On 25.09.23 22:13, Gnomi wrote:
> > How did you create that closure? And this something happen to the object
> > like a replace_program()?
>
> The closure is created in room/std_gang.c, which is inherited by
> room/gang_034.c. Simply with "#'check_workroom".
>
> No replace_program() or the like, just a plain inherit and all blueprint
> objects.
>
> The function is also implemented in room/std_gang.c.

I tried to reproduce that behavior, but couldn't. I used prog1.c and
prog2.c, both defining fun(). prog1 inheriting prog2 and prog2 creating the
closure with #'fun. Result has been:
"#'prog1->fun() from prog2.c line 3"

Could you provide an example to reproduce it?

> > Normally the second part will only be printed if the target program
> > (inherit) is a different than the main program (object).
>
> so it should say "room/gang_034(room/std_gang)" or just "room/gang_034 from
> room/std_gang", shouldn't it?

Yes, it should just say:
"#'domains/huegelland/thyrsis/ratstempel/room/gang_034->check_workroom()"

Greetings,
Gnomi.

Stephan Weinberger

unread,
Sep 27, 2023, 7:05:15 AM9/27/23
to ldmud...@googlegroups.com
Hi Gnomi.

Example

/home/invisible/cts1.c:

------------------------------------------------------
private closure _clsr;

closure clsr()
{
    return _clsr;
}

private int test()
{
    write("I'm a test.");
    return 1;
}

void create()
{
    _clsr = #'test;
}
------------------------------------------------------

/home/invisible/cts2.c:

------------------------------------------------------
inherit "/home/invisible/cts1";

void create()
{
    ::create();
}
------------------------------------------------------

now when I run:
efun::printf("%O", "/home/invisible/cts2"->clsr());

I get:
#'home/invisible/cts2(home/invisible/cts2)->test() from
home/invisible/cts1.c line 16

Even if we disregard that the part in brackets should not be printed if
target program and target inherit are the same, this cannot be correct,
as test() is declared private in cts1 and therefore should not be
inherited by cts2 to begin with, i.e. cts2 cannot be the "target
inherit". (Without the private modifier the result is exactly the same
though.)

Driver Version is 3.6.6-3-g64b3588a (current master from github).

Gnomi

unread,
Sep 27, 2023, 2:14:49 PM9/27/23
to ldmud...@googlegroups.com
Hi Invisible,

Thanks for the example. Found the bug:
https://github.com/amotzkau/ldmud/commit/57f5067e8cd05bfbaa37631f54222d865aa3a60a

Greetings,
Gnomi.
Reply all
Reply to author
Forward
0 new messages