Please limit reports of undefined symbols

In my program, if I put a syntax error in some CHR code, and then make/0:

  • the CHR compiler aborts, so a lot of predicates are not preprocessed into the source,
  • the Prolog compiler proceeds.
  • I get a CHR error notice.
  • I then get approximately 200 warnings about missing symbols
    Warning: cp:delete_done/1, which is referenced by
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:4708:4: 1-st clause of cp:del/1
    Warning: cp:deleted_object_refs/1, which is referenced by
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:1559:4: 1-st clause of cp:del_object_refs/1
    Warning: cp:deleting_object_refs/1, which is referenced by
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:1558:4: 1-st clause of cp:del_object_refs/1
    Warning: cp:display_cons_on_var/1, which is referenced by
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:2846:4: 1-st clause of cp:cons_on_ref/1
    Warning: cp:do_create_compile_ref/7, which is referenced by
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:1723:4: 1-st clause of cp:create_compile_ref/2
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:1726:4: 1-st clause of cp:create_compile_ref/3
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:1729:4: 1-st clause of cp:create_compile_ref/4
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:1732:4: 2-nd clause of cp:create_compile_ref/4
    Warning: cp:done_rewind_step/1, which is referenced by
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:2546:4: 1-st clause of cp:rai/2
    Warning: cp:edit_var/3, which is referenced by
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:3015:4: 1-st clause of cp:delete_from_array/2
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:3029:4: 1-st clause of cp:insert_array/2
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/dispatcher.pl:201:13: 1-st clause of dispatcher:
    Warning: cp:post_values/0, which is referenced by
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/build_plates.pl:67:13: 1-st clause of build_plates:build_plates/1
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/build_plates.pl:95:13: 1-st clause of build_plates:make_plates/1
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/build_plates.pl:98:13: 1-st clause of build_plates:make_plates/1
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/build_plates.pl:76:13: 1-st clause of build_plates:make_stack/2
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/build_plates.pl:140:13: 1-st clause of build_plates:stack_up_ejector_plates/2
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/build_plates.pl:162:13: 1-st clause of build_plates:stack_up_plates0/2
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/build_plates.pl:177:13: 1-st clause of build_plates:stack_up_plates0/2
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:2803:8: 1-st clause of cp:fix_materials/0
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:2805:8: 1-st clause of cp:fix_materials/0
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:3162: 1-st clause of cp:solve_system0/1
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:3297:7: 1-st clause of cp:test_edit/0
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:3310:7: 1-st clause of cp:test_edit/0
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/xbp.pl:3233:4: 1-st clause of cp:test_system_1/0
    Warning: d:/vmm/2021pro/rule-processor/branches/gen3/dispatcher.pl:182:11: 1-st clause of dispatcher:make_object/2
    (etc. for more lines than fit in the interactive console).

The result of this is the limited console buffer erases the error and I don’t even know the cause. Maybe it’s possible to expand the console. Any suggestions on how I can find my error given it scrolls away before I can see it?

What I REALLY want, is to reduce the warnings. After the first 10, I don’t care. If it wasn’t caused by a CHR error, it’s caused because I forgot to load a file. 10 is plenty to let me know and start figuring. Any way I can do this? Any way Jan can do this? I REALLY want this change.

See SWI-Prolog for MS-Windows

user:message_hook/3 is what can be used for this.

Finally, there is the very old protocol/1 to log output to a file.

looks like user:message_hook is the one that will serve. Seems very complicated in this case. I’ll need to count the warnings, and only after a set number decide to suppress future messages. And then somewhere somehow I’ll have to know to reset the warning count?

A fair bit of work, but worth it. Going to a log file I know how to do that, but not something I want to do on each make call.

1 Like

Any idea how I can know to reset the warning count to zero when make concludes?

Have a look at make/0. It calls two hooks and uses a hookable print_message/2 that allows user defined actions before and after the make.

Note that breaking out of compilation using e.g. abort/0 is not a good idea. Unfortunately too much of the compiler does not do a good job recovering from that. You better use your counter to simply ignore all further errors. You can do that selectively, for example only suppress messages of a certain type.

2 Likes