ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* No error when loading a non-existent module
@ 2022-08-25  0:19 Max Chernoff via ntg-context
  2022-08-25  6:57 ` Hans Hagen via ntg-context
  0 siblings, 1 reply; 6+ messages in thread
From: Max Chernoff via ntg-context @ 2022-08-25  0:19 UTC (permalink / raw)
  To: ntg-context; +Cc: Max Chernoff

Hi all,

If you load a non-existent module, ConTeXt issues a minor warning, but
otherwise proceeds as normal:

MWE:

   \usemodule[doesnt-exist]
   
   \starttext
   Hello world!
   \stoptext
   
I think that this behaviour should be changed so that a fatal error is
issued when a loaded module cannot be found. Plain TeX, LaTeX, and OpTeX
all throw an error whenever their versions of modules cannot be found, so
ConTeXt is the odd one out here.

There are 3 scenarios that I can think of for when you attempt to load a
module, but it cannot be found:

1. A module provides some new command "\somecommand"

   In this case, loading the module will quietly fail, but an undefined
   control sequence error will be issued whenever you use
   "\somecommand". This disguises the root problem, which is that the
   module was never loaded, potentially confusing users.
   
2. A module changes the layout of a document

   In this case, the layout of the document would be unchanged by the
   module. If you're looking at every document, then this would be
   obvious; however, if you're using some batch processing system, you
   could unknowingly send out incorrectly-styled documents quite easily.
   
3. You load a module that provides some command, then never use it

   This is the only case where the new error would break any documents.
   However, this case should hopefully be pretty rare since it's
   pointless to load a module then never use any of its features.
   
Making this change could potentially break some documents that currently
work, but I think that this change is worth it, since I'd rather have
something break loudly (throwing an error) rather than silently (producing
a semi-corrupt document).

Thanks,
-- Max
   
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: No error when loading a non-existent module
  2022-08-25  0:19 No error when loading a non-existent module Max Chernoff via ntg-context
@ 2022-08-25  6:57 ` Hans Hagen via ntg-context
  2022-08-26  1:00   ` Max Chernoff via ntg-context
  0 siblings, 1 reply; 6+ messages in thread
From: Hans Hagen via ntg-context @ 2022-08-25  6:57 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Hans Hagen, Max Chernoff

On 8/25/2022 2:19 AM, Max Chernoff via ntg-context wrote:
> Hi all,
> 
> If you load a non-existent module, ConTeXt issues a minor warning, but
> otherwise proceeds as normal:
> 
> MWE:
> 
>     \usemodule[doesnt-exist]
>     
>     \starttext
>     Hello world!
>     \stoptext
>     
> I think that this behaviour should be changed so that a fatal error is
> issued when a loaded module cannot be found. Plain TeX, LaTeX, and OpTeX
> all throw an error whenever their versions of modules cannot be found, so
> ConTeXt is the odd one out here.
> 
> There are 3 scenarios that I can think of for when you attempt to load a
> module, but it cannot be found:
> 
> 1. A module provides some new command "\somecommand"
> 
>     In this case, loading the module will quietly fail, but an undefined
>     control sequence error will be issued whenever you use
>     "\somecommand". This disguises the root problem, which is that the
>     module was never loaded, potentially confusing users.

It doesn't tell you where to look unless we parse all files.

> 2. A module changes the layout of a document
> 
>     In this case, the layout of the document would be unchanged by the
>     module. If you're looking at every document, then this would be
>     obvious; however, if you're using some batch processing system, you
>     could unknowingly send out incorrectly-styled documents quite easily.

Ah ... but texies claim to see the difference so it's an exercise!

> 3. You load a module that provides some command, then never use it
> 
>     This is the only case where the new error would break any documents.
>     However, this case should hopefully be pretty rare since it's
>     pointless to load a module then never use any of its features.

Indeed harmless.

> Making this change could potentially break some documents that currently
> work, but I think that this change is worth it, since I'd rather have
> something break loudly (throwing an error) rather than silently (producing
> a semi-corrupt document).
But ... you can already do

\enabledirectives[logs.errors=*]

or

\enabledirectives[logs.errors=missing modules]

and if needed can add that line to a local cont-loc.mkxl file so that it 
always kicks in.

However, more dangerous is when a user overloads a system macro so if 
you realy want to play safe:

\enabledirectives[overloadmode=error] % or warning

is yuour friend.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: No error when loading a non-existent module
  2022-08-25  6:57 ` Hans Hagen via ntg-context
@ 2022-08-26  1:00   ` Max Chernoff via ntg-context
  2022-08-26  5:40     ` Hans Hagen via ntg-context
  2022-08-26  7:49     ` Hans Hagen via ntg-context
  0 siblings, 2 replies; 6+ messages in thread
From: Max Chernoff via ntg-context @ 2022-08-26  1:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Max Chernoff

Hi Hans,

On Thu, 2022-08-25 at 08:57 +0200, Hans Hagen wrote:
> On 8/25/2022 2:19 AM, Max Chernoff via ntg-context wrote:
> But ... you can already do
> 
> \enabledirectives[logs.errors=*]
> 
> or
> 
> \enabledirectives[logs.errors=missing modules]

Didn't know about that, thanks.

However, this still continues processing the document and produces a PDF
at the end. All that that seems to do is make ConTeXt exit with a non-
zero status code, which is fairly easy to ignore if you're not paying
attention. 

Is there a way to make this produce a nice little "error" PDF as soon as
the error occurs just like using "\undefined" does?

> and if needed can add that line to a local cont-loc.mkxl file so that it 
> always kicks in.

Didn't know about that either.

But wouldn't it make sense for this to be an error by default? Nothing
good can happen if a user loads a non-existent (or misspelled) module.
Loading a non-existent file is a fatal error even in Plain TeX
\nonstopmode. I think that making this an error by default would break
very few working documents. In exchange, most users would get much more
helpful error messages.

Thanks,
-- Max


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: No error when loading a non-existent module
  2022-08-26  1:00   ` Max Chernoff via ntg-context
@ 2022-08-26  5:40     ` Hans Hagen via ntg-context
  2022-08-26  6:45       ` Max Chernoff via ntg-context
  2022-08-26  7:49     ` Hans Hagen via ntg-context
  1 sibling, 1 reply; 6+ messages in thread
From: Hans Hagen via ntg-context @ 2022-08-26  5:40 UTC (permalink / raw)
  To: Max Chernoff, mailing list for ConTeXt users; +Cc: Hans Hagen

On 8/26/2022 3:00 AM, Max Chernoff wrote:
> Hi Hans,
> 
> On Thu, 2022-08-25 at 08:57 +0200, Hans Hagen wrote:
>> On 8/25/2022 2:19 AM, Max Chernoff via ntg-context wrote:
>> But ... you can already do
>>
>> \enabledirectives[logs.errors=*]
>>
>> or
>>
>> \enabledirectives[logs.errors=missing modules]
> 
> Didn't know about that, thanks.
> 
> However, this still continues processing the document and produces a PDF
> at the end. All that that seems to do is make ConTeXt exit with a non-
> zero status code, which is fairly easy to ignore if you're not paying
> attention.

If someone doesn't pay that kind of attention one can wonder about the 
quality of the document.

> Is there a way to make this produce a nice little "error" PDF as soon as
> the error occurs just like using "\undefined" does?

Only If I add it as option (directive driven, must find some good name 
for it).

Most modules add commands and that shows immediately. Modules that kick 
in without some command that needs to enable something are sort of 
not-done or rare and experimental only and comparable to when some 
module patches or overloads core functionality withoutr mentioning it.

Also, keep in mind that styles can also be modules and that normally 
shows in ta different output.

>> and if needed can add that line to a local cont-loc.mkxl file so that it
>> always kicks in.
> 
> Didn't know about that either.

Ah, that's one of the oldest features: cont-new (for patched before 
updates), cont-loc (for local preferences) and cont-exp (for wolfgang 
and me)

> But wouldn't it make sense for this to be an error by default? Nothing
> good can happen if a user loads a non-existent (or misspelled) module.
> Loading a non-existent file is a fatal error even in Plain TeX
> \nonstopmode. I think that making this an error by default would break
> very few working documents. In exchange, most users would get much more
> helpful error messages.
It would never be default because it is quite possible to have cases 
where a module became redundant or is optional. There arte very few 
cases where we are not downward 'command and file' compatible (the most 
noticeable exceptions are when font, language and encoding subsystems 
fundamentally change).

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: No error when loading a non-existent module
  2022-08-26  5:40     ` Hans Hagen via ntg-context
@ 2022-08-26  6:45       ` Max Chernoff via ntg-context
  0 siblings, 0 replies; 6+ messages in thread
From: Max Chernoff via ntg-context @ 2022-08-26  6:45 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Max Chernoff

On Fri, 2022-08-26 at 07:40 +0200, Hans Hagen wrote:
> On 8/26/2022 3:00 AM, Max Chernoff wrote:
> > Is there a way to make this produce a nice little "error" PDF as soon as
> > the error occurs just like using "\undefined" does?
> 
> Only If I add it as option (directive driven, must find some good name 
> for it).

You already have errors and warnings as an option, so a good name might
be "fatal"?

> Most modules add commands and that shows immediately. Modules that kick 
> in without some command that needs to enable something are sort of 
> not-done or rare and experimental only and comparable to when some 
> module patches or overloads core functionality withoutr mentioning it.

Here I'm mainly thinking about my lua-widow-control module, which
produces a visual effect, although it can be quite subtle if you're not
paying very close attention.

> > > and if needed can add that line to a local cont-loc.mkxl file so that it
> > > always kicks in.
> > 
> > Didn't know about that either.
> 
> Ah, that's one of the oldest features: cont-new (for patched before 
> updates), cont-loc (for local preferences) and cont-exp (for wolfgang 
> and me)

Not seeing anything on the Wiki about either of those. I guess that
means I'm volunteering myself :)

Similarly to "cont-loc.mkxl", is there some local file that is only read
during format generation? Some of my documents use pgf/TikZ and expl3,
and loading these during format generation can save quite a bit of time
when compiling. I know that I can just modify "cont-en.mkxl" or
"context.mkxl", but those can be overwritten by updates.

> > But wouldn't it make sense for this to be an error by default? Nothing
> > good can happen if a user loads a non-existent (or misspelled) module.
> > Loading a non-existent file is a fatal error even in Plain TeX
> > \nonstopmode. I think that making this an error by default would break
> > very few working documents. In exchange, most users would get much more
> > helpful error messages.
> It would never be default because it is quite possible to have cases 
> where a module became redundant or is optional. There arte very few 
> cases where we are not downward 'command and file' compatible (the most 
> noticeable exceptions are when font, language and encoding subsystems 
> fundamentally change).

Fair enough. 

Thanks,
-- Max


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: No error when loading a non-existent module
  2022-08-26  1:00   ` Max Chernoff via ntg-context
  2022-08-26  5:40     ` Hans Hagen via ntg-context
@ 2022-08-26  7:49     ` Hans Hagen via ntg-context
  1 sibling, 0 replies; 6+ messages in thread
From: Hans Hagen via ntg-context @ 2022-08-26  7:49 UTC (permalink / raw)
  To: Max Chernoff, mailing list for ConTeXt users; +Cc: Hans Hagen

On 8/26/2022 3:00 AM, Max Chernoff wrote:
> Hi Hans,
> 
> On Thu, 2022-08-25 at 08:57 +0200, Hans Hagen wrote:
>> On 8/25/2022 2:19 AM, Max Chernoff via ntg-context wrote:
>> But ... you can already do
>>
>> \enabledirectives[logs.errors=*]
>>
>> or
>>
>> \enabledirectives[logs.errors=missing modules]
> 
> Didn't know about that, thanks.
> 
> However, this still continues processing the document and produces a PDF
> at the end. All that that seems to do is make ConTeXt exit with a non-
> zero status code, which is fairly easy to ignore if you're not paying
> attention.
> 
> Is there a way to make this produce a nice little "error" PDF as soon as
> the error occurs just like using "\undefined" does?
I added logs.quitonerror as alternative:

% \enabledirectives[logs.errors=*]
\enabledirectives[logs.quitonerror=missing modules]

\starttext
     \usemodule[crapcrap]
     TEST
\stoptext

error logging   > start possible issues
modules         > start missing modules
modules         >       *-crapcrap
modules         > stop missing modules
error logging   > error marked as fatal
mtx-context     | fatal error: return code: 1

That has to do, no default,

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-26  7:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-25  0:19 No error when loading a non-existent module Max Chernoff via ntg-context
2022-08-25  6:57 ` Hans Hagen via ntg-context
2022-08-26  1:00   ` Max Chernoff via ntg-context
2022-08-26  5:40     ` Hans Hagen via ntg-context
2022-08-26  6:45       ` Max Chernoff via ntg-context
2022-08-26  7:49     ` Hans Hagen via ntg-context

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).