no, i wrote the library. but i don’t want interface code in it so i
can resue it under differnt circumstances.
Then change it : your need of resume in this case, just means that your
library was badly designed
thats crap.
were taking about seperation of concerns --that’s not bad design. i have a library i use for downloading files. i have a user interface script that uses the library. things happen in the library and if the user has set verbose more i should be able to report them to the user without having to write special esoteric message passing code.
sounds aweful dosen’t it? come on, are you goating me?
were taking about seperation of concerns --that's not bad design. i have
a library i use for downloading files. i have a user interface script
that uses the library. things happen in the library and if the user has
set verbose more i should be able to report them to the user *without*
having to write special esoteric message passing code.
You are raising an exception, this is, for me, different than sending
message to stdout
…
Then change it : your need of resume in this case…
…i have a user interface script that uses the library. things happen in the library and if the user has set verbose more i should be able to report them to the user …
-ts
To me it seems that to handle this concern, the proper approach is to
raise the exception within the library, catch it within the library
(actually, within the same routine if possible), if you can’t handle it
there, then print out your message and re-raise the exception. Of
course the “printing out of the message” could be handled via a call to
a custom “message handler” routine that serves your needs, so you have
extra place (probably within the library) to specialize things in a more
global way. “resume” is quite tricky if you don’t know just where you
will be resuming to (consider what would happen to an external routine
that “resumed” a program structured as I’m proposing). I feel that
resume is normally best used within the same routine that threw the
exception, and that any other use is…dangerous. It is too likely that
later editing will introduce side effects without seeing the problems
that are being caused.