Re: retry does not work

  • Permalink
  • submit to reddit
  • Email
  • Follow


Guy Decoux:

>  Well the example was probably
> 
>    def resume_example(x)
>       print x
>       x += 4
>       begin
>          raise if x < 10
>          print x
>       rescue
>          x = 10
>          retry
>       end
>       puts
>    end
 
you have refactored my code to achieve the result. is all code so easily refactored?

    def i_am_libaray_code
      # this is a library call
      # to be used in many differnt apps
      # do not add user interface code!
      raise SpecialWaring, "Warning, incoming!"
      ...
    end

    def resume_example(x)
       begin
          i_am_library_code
       rescue SpecialWaring => e
          puts e
          resume
       end
    end

i can not refactor the lib call to conatin stdout, and i need a message from it about its status. perhaps there is another way to do this. if you know please tell! 

-t0

0
Reply transami (959) 11/20/2003 10:31:00 AM

See related articles to this posting


>>>>> "T" == T Onoma <transami@runbox.com> writes:

T> i can not refactor the lib call to conatin stdout, and i need a message
T> from it about its status. perhaps there is another way to do this. if
T> you know please tell!  

 Becuase you can't refactor the library, you *can't* use resume like you
 want use it because you know nothing about the internal of this library



Guy Decoux



0
Reply decoux (1351) 11/20/2003 10:37:24 AM

"T. Onoma" <transami@runbox.com> schrieb im Newsbeitrag
news:E1AMm57-0002fp-HX@odie.runbox.com...
> Guy Decoux:
>
> >  Well the example was probably
> >
> >    def resume_example(x)
> >       print x
> >       x += 4
> >       begin
> >          raise if x < 10
> >          print x
> >       rescue
> >          x = 10
> >          retry
> >       end
> >       puts
> >    end
>
> you have refactored my code to achieve the result. is all code so easily
refactored?
>
>     def i_am_libaray_code
>       # this is a library call
>       # to be used in many differnt apps
>       # do not add user interface code!
>       raise SpecialWaring, "Warning, incoming!"
>       ...
>     end
>
>     def resume_example(x)
>        begin
>           i_am_library_code
>        rescue SpecialWaring => e
>           puts e
>           resume
>        end
>     end
>
> i can not refactor the lib call to conatin stdout, and i need a message
from it about its status. perhaps there is another way to do this. if you
know please tell!

What strikes me is that you use "resume" in the rescue clause instead of
"retry".  Is that on purpose or is maybe a simple misspelling the reason
for your frustration.

Kind regards

    robert

0
Reply bob.news (3807) 11/20/2003 10:38:20 AM

Hi,

In message "Re: retry does not work"
    on 03/11/20, "T. Onoma" <transami@runbox.com> writes:

|you have refactored my code to achieve the result. is all code so easily refactored?

Not all, but most.

Your "resume" makes exception handling much harder.  With "resume",
every raise can be re-entered, that means programmers need to care
about re-entrance always.

So allowing new thing is not always a good thing.

							matz.

0
Reply matz (1855) 11/20/2003 10:50:57 AM
comp.lang.ruby 48858 articles. 5 followers. Post

3 Replies
218 Views

Similar Articles

[PageSpeed] 49


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Re: retry does not work #9
robert: thanks robert, that's basically what i decided to do. your code is nice and clean to. i like that. but you know. it strikes me as funny that its thought a good idea to implement nested chains of handlers for errors but not for message passing. it seems like a natural fit to me. but when ever i bring it up i get all sorts of nay nays. what so bad about this idea? i think it would be a very powerful tool. i agree that resume should be automatic for this purpose, and a seperate command should exist. i don't what to hurt the poor little raise command. i'm not that bad! ;) i...

Re: retry does not work #2
Guy: > Becuase you can't refactor the library, you *can't* use resume like you > want use it because you know nothing about the internal of this library no, i wrote the library. ;) but i don't want interface code in it so i can resue it under differnt circumstances. -t0 >>>>> "T" == T Onoma <transami@runbox.com> writes: T> no, i wrote the library. ;) but i don't want interface code in it so i T> can resue it under differnt circumstances. Then change it : your need of resume in this case, just means that your library was ...

Re: retry does not work #6
> You are raising an exception, this is, for me, different than sending > message to stdout okay, i grant you that was not the intention of raise when designed. but a rose by any other name.... so what other means are there? should a raise_message be added? or maybe you are right. maybe my library is "badly designed", but if so then tell me what would the alternative be that achieves such seperation? -t0 >>>>> "T" == T Onoma <transami@runbox.com> writes: T> so what other means are there? should a raise_message be added? or maybe T> y...

Re: retry does not work #4
Guy: > T> no, i wrote the library. ;) but i don't want interface code in it so i > T> 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 esoteri...

Re: retry does not work #7
> "resume" won't work well unless both your code and the user code know > each other (the user code must care that raise might resume; your code > must know how to fix up the exception cause). In that case, I think > you can make "retry" work, otherwise you can't make them work well > anyway. that is a good point, but the alternative seems to be passing proc or passing self. self seems like over kill, but passing proc is messy. no win situation here? perhaps this suggests another facility like raise but that does not halt execution. rather it moves...

Re: retry does not work #5
matz: > Your "resume" makes exception handling much harder. With "resume", > every raise can be re-entered, that means programmers need to care > about re-entrance always. > > So allowing new thing is not always a good thing. worry? isn't that what testers are for ;) okay, so maybe there could be an option put on raise to allow resuming? just as an example of what this could do: tanaka is adding hook into open_uri to do progress reporting of download. to make it work you have to pass a lambda that acts on progress. but with resume you could raise a ...

Re: retry does not work #3
Hi matz, thanks for reposting, someone should really fix that bug on ruby garden. so Guy gave me same answer. i have problem with it. could you look at those and let me know? ( you probably already are \:) -t0 Hi, In message "Re: retry does not work" on 03/11/20, "T. Onoma" <transami@runbox.com> writes: | so Guy gave me same answer. i have problem with it. could you look at those and let me know? ( you probably already are \:) I'm sorry; which is your problem? [ruby-talk:85791]? In message [ruby-talk:85791], you wrote: |were taking about seperat...

Re: retry does not work #8
thanks matz and thanks guy for chat. continuations work, but still seem clunky. i'll probably pass proc. have a good day, -t0 > Hi, > > In message "Re: retry does not work" > on 03/11/20, "T. Onoma" <transami@runbox.com> writes: > > |that is a good point, but the alternative seems to be passing proc or passing self. self seems like over kill, but passing proc is messy. no win situation here? perhaps this suggests another facility like raise but that does not halt execution. rather it moves up the call chain looking for a handler, if it fi...

RE: Re: problems with FindRoot: what worked with 4.2 does not work with 5.0
> FindRoot[temp[x]==5,{x,8}] Or just FindRoot[test[x]==5,{x,8}] since we have defined test[x_] but not temp[x_] in this case. Br, - James Sungjin Kim (kimsj@mobile.snu.ac.kr) -----Original Message----- From: Gareth J. Russell [mailto:gjr2008@columbia.edu] Subject: Re: problems with FindRoot: what worked with 4.2 does not work with 5.0 In <c4u3gg$9l6$1@smc.vnet.net> Edgar Dachs wrote: > > I have written a Mathematica program called PET (Petrological > elementary tools) for Mathematica (Dachs, 1998, Computers & > Geosciences, 24/3: 219-235)...

RE: commit work not working?
John Your pseudo code needs to look mor like this:- begin work load from fname inset into tableA test sql result code if failure then rollback work quit end if insert tableB test sql result code if failure then rollback work quit else commit work end if In dbaccess or isql you manually make the decision to commit or rollback dependant on whether the inserts are successful or not, a single stream of commands as below will always commit the successful portions of the inserts regardless of the overall success, or otherwise, of the remaining commands. Keith -----...

Re: WORK libname re-assigned
Thank you for all the replies. The problem was encountered testing an AF application deployment using a custom config file. I assumed USER=WORK would have taken care of (resolved) one-level dataset references. It turns out that WORK was not being re-assigned, but an instance of libname USER had been created and used because some references to work datasets were not prefixed with 'work.'. In particular, work.gseg was not being used to store gplots, but user.gseg was. This was fixed by adding the option OUT=WORK.GSEG to the proc gplot statement. ODS output datasets in proc model had...

RE: commit work not working? #2
I'm not sure I agree that the documentation implies that it will automatically roll back. It will do what it's told, and if the client program (dbaccess) tells it to commit what it's done, then it does. I believe there is a new flag (-a, I think) in IDS 10 (possibly 9.4) for dbaccess that causes it to abort on error to avoid this sort of behavior. You could also use Jonathan Leffler's sqlcmd, which aborts by default (it's available on the IIUG software repository at www.iiug.org). Better, however, would be to use transactions directly inside the perl script. I as...

Re: Snit's Own Photoshop Work [was Re: Exposing a liar [was Re: An angel left this in my inbox...]
"Steve Carroll" <noone@nowhere.com> stated in post noone-E6FBDD.14263512042005@comcast.dca.giganews.com on 4/12/05 1:26 PM: > In article <115o5041mlfk9b3@corp.supernews.com>, > "Elizabot v2.0.2" <Elizabot@NsOpSyPmAaMc.com> wrote: > >> Snit wrote: >> >>> It is like the yahoos in CSMA who have said that since I have posted links >>> to my site that must mean it is OK to data mine my site, steal photos, >>> modify them, and re-post them. >>> >>> Some people can not understand the difference b...

Re: Snit's Own Photoshop Work [was Re: Exposing a liar [was Re: An angel left this in my inbox...] #2
"Elizabot v2.0.2" <Elizabot@NsOpSyPmAaMc.com> stated in post 115o5041mlfk9b3@corp.supernews.com on 4/12/05 11:31 AM: > Snit wrote: > >> It is like the yahoos in CSMA who have said that since I have posted links >> to my site that must mean it is OK to data mine my site, steal photos, >> modify them, and re-post them. >> >> Some people can not understand the difference between not minding *an* email >> vs. getting any email, or not minding people looking at one web page (or >> even several) vs. obsessive data mining of someone'...

Re: Re: Format->Magnification does not work
On Tue, 8 May 2007 05:47:06 -0400 (EDT), roby.nowak@gmail.com wrote: > On 7 Mai, 11:40, Carl Woll <c...@wolfram.com> wrote: > >> Nasser Abbasi wrote: >>> Is this a feature of a bug? >>> It used to be (in 5.2) when I do Format->Magnification->150% (say), >>> then >>> the WHOLE notebook will be magnified. >>> >>> Now, when I do the same NOTHING happens. The fonts remain small. >>> >>> One has to first go and select all the cells to be magnified, then do >>> the >>> For...

Re: [LogoForum] Re: Making tag work.
> G'day G'day Folks, > > If MSWLogo doesn't currently implement tag is there a work around > routine or another instruction that fulfils the same purpose? repeat 100 [G'day] Quentin, For every specific use of tags you can find a suitable workaround. Sometimes it will need to relogic your source. Most likely there is no a common solution to handle goto. For example, this one is simple: tag "beginning label [Oh! not again] goto "beginning and can be written as: while "true [ label [Oh! not again] ] (of course there are other solutions)...

RE: [VxW] Re: how schedular works in vxworks?
Hi usually it is done when using the time ticks as the time tick occurs it will call a service routine which will look into the ready table and decide who will run and how according to the scheduling scheme you have chosen regards CJ -----Original Message----- From: sumit.sharma@wipro.com [mailto:sumit.sharma@wipro.com] Sent: Tuesday, October 21, 2003 2:42 PM To: vxwexplo@csg.lbl.gov Subject: [VxW] Re: how schedular works in vxworks? Who informs the scheduler? Who sends the event, or does semGive or send event to the scheduler? sumit Joe Durusau <durusau@bellsouth.net> wrote in me...

Re: Re[2]: working directory not writable
> >> > (a) If the effective uid/gid is 0 (root), how can the access() > >> > call be resulting in "access denied"? > > MA> access() != eaccess() > > I think your earlier answer was clearer (at least to me), > when you said the named initially drops most (if not all) > of root's special privileges. That explains everything I > saw, but doesn't change the fact that the access() test in > named/server.c is being done at the wrong time. Here's > the sequence that I see (plus the adjustme...

Re: Re: Reverse DNS Mapping not working
Now I am getting confused. We have 32 IP Addresses (195.141.214.32 up to 63) and I cannot do reverse mapping for my servers myself? Where do the other ISP's lookup for a reverse mapping then? You see, I need some enlightment on this. Dave > > In article <bikasp$uuk$1@sf1.isc.org>, David Meier > <MEIER@logmail.net> wrote: Hi all, >> >> I am a newbie to this and have the thankful task of administering >> an OpenVMS DNS server that had been set up years ago by some other >> person. Now we get more and more returned emails back wit...

Re: Re: SphericalPlot3D doesn't work
David, I'm not sure if this is an old message. But, just in case you still need some help, I tried running your program and found no problems. To make a cylindrical or spherical plot, you first need to execute the following command: <<Graphics`ParametricPlot3D`; This command will load the standard package ParametricPlot3D.m. Then, you will need to execute the following command: SphericalPlot3D[2, {theta, 0, Pi}, {phi, -Pi, Pi}]; This should produce the results you are looking for. If you need a soft copy of the notebook that I created, please let ...

Re: Running on a mainframe was Re: working storage values
>>> On 1/1/2008 at 4:15 PM, in message <i9iln3t2fsvp6lsmtv1mnhtkekjd4dvfg4@4ax.com>, Robert<no@e.mail> wrote: > On Tue, 01 Jan 2008 16:20:58 -0400, Clark F Morris ><cfmpublic@ns.sympatico.ca> wrote: > >>On Fri, 21 Dec 2007 22:18:01 -0600, Robert <no@e.mail> wrote: >>>> much snipped >>> >>>Actually, I think OS provided GUIs are passe. Web browser is the way to > go. Google is on >>>the right track with Gears, but it now supports only JavaScript. When the > browser is your >>>UI, you can run...

Re: BODYTITLE NOT WORKING. (Re: ODS RTF: ... A workaround)
Here is my current workaround: 1. I don't use title & footnote because I want them to be in the body part, also because I have to leave the real header/footer section untouched for global header/footer when multiple rtf files(tables/listings) are eventually combined together in word. 2. I don't use bodytitle option because it has bug. 3. I have to create a pagebreak var as a 'BY' var, so that I can use 'BY' statement which will insert a pagebreak for me after each page. Now the sample code: options nodate nonumber nobyline papersize=letter orientation...

RE: [tao-users] Re: DLL example not working
Hi Doug, We don't run examples on our scoreboard. The change itself is wrong, this will break all other compilers. The report is about cygwin, that port is really experimental. If people can provide patches to improve this then it would be great Regards, Johnny Willemsen Remedy IT Postbus 101 2650 AC Berkel en Rodenrijs The Netherlands www.theaceorb.nl / www.remedy.nl > Hi Folks, > > The following PRF was sent to me. Has anyone else seen this > problem? I don't think we're getting it on our scoreboard. > > Thanks, > ...

RE: [JavaCC] Re: working with lexical states question
> Scott Boag wrote: [snip ...] > > Likewise, the particular token you mentioned, StringLiteral, is > used as many > > different tokens in our test parser: > > > > <DEFAULT, OPERATOR> > > TOKEN : > > { > > < StringLiteral : (("\"" ((<PredefinedEntityRef> | <CharRef> | > ("\"" "\"") > > | ~["\"", "&"]))* "\"") | ("'" ((<PredefinedEntityRef> | > <CharRef> | ("'" > > ...