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 48853 articles. 5 followers. Post

3 Replies
228 Views

Similar Articles

[PageSpeed] 38


  • 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: Re: Re:
>From: David Elliott <elliott@stcnet.com> >To: "Yue Huang" <yue31@hotmail.com> >Subject: Re: Re: Re: >Date: Tue, 9 Dec 2003 23:29:13 -0500 > >On Dec 9, 2003, at 10:41 PM, Yue Huang wrote: > >> >>----- Original Message ----- >>From: "David Elliott" <elliott@stcnet.com> >>Newsgroups: comp.soft-sys.wxwindows >>Sent: Tuesday, December 09, 2003 12:44 AM >>Subject: Re: >> >> >>>You'll notice the code in that wxMac method sets the >>>kFloatingWindowClass Mac...

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: Re: Marc Re: Andreessen Re: created Re: the Re: first Re: web Re: browser
no. ...

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: RE : Re: copulas and SAS
Thanks, I appreciate your comments,I understand that copula is not the appropriate tool to use, what will be the alternative ? Adel David L Cassell <davidlcassell@MSN.COM> a �crit : joewhitehurst@GMAIL.COM replied: > >Adel, > >You may find the following artilce interesting. [article by Thomas Mikosch not copied] This is a really good article, and a really useful point to make. But 55K is a lot of article to copy. Would it have been easier to point to a URL? The people who read SAS-L as a digest and the people who have slow connections are probably not overly thrilled...

Re: Re: Re: Re: No future for DB2
Well, IDS 10 + XPS 9 as open source = Astonishing cool !! J. -----Original Message----- From: "Obnoxio The Clown" <obnoxio@serendipita.com> To: "Jean Sagi" <jeansagi@myrealbox.com> Date: Wed, 27 Jul 2005 22:00:31 +0100 (BST) Subject: Re: Re: Re: No future for DB2 Jean Sagi said: > > Online 5. as open source = Quite cool. But hugely impractical, as it would reveal far too much about IDS to the competition. -- Bye now, Obnoxio "C'est pas parce qu'on n'a rien � dire qu'il faut fermer sa gueule"...

Re: Re: Re: Radio Re: Shack Re: TRP-100 Re: Printer Re:
> Also, trim your replies. Leaving a few pages of original text just so > you can add your few lines at the bottom is just insane. > > g. > > -- > Proud owner of F-15C 80-0007 > http://www.f15sim.com - The only one of its kind. > http://www.diy-cockpits.org/coll - Go Collimated or Go Home. > Some people collect things for a hobby. Geeks collect hobbies. > > ScarletDME - The red hot Data Management Environment > A Multi-Value database for the masses, not the classes. > http://scarlet.deltasoft.com - Get it _today_! > --- Synchrone...