From: Robert Klemme Date: 2004-02-20T20:56:51+09:00 Subject: Re: how to raise warning? "Mark Hubbart" schrieb im Newsbeitrag news:4A25FA2C-637E-11D8-9977-000502FDD5CC@mac.com... > > On Feb 19, 2004, at 11:50 PM, Gavri Savio Fernandez wrote: > > >> From: Hal Fulton [mailto:hal9000@hypermetrics.com] > >> Subject: Re: how to raise warning? > >>> Having a variant of 'warn' that displays that information would be > >>> nice IMO. > >>> > >>> warn "You didn't provide such and such", true > >> > >> Mmm. I would expect that just to print 'true' after the warning. > I second that. Adding an optional boolean argument to the function to > get different results doesn't quite seem rubyish to me. It's generally considered bad to have an interface method that changes it's behavior dependend on a flag. The typical solution is to have two methods for the job. If they have something in common they can use a private method for the implementation. > >> The problem as I see it is that we use warnings in two ways: > >> 1. As Ruby does, to complain about something happening at a specific > >> place in the source -- a highly source-related message. In that > >> case, I'd want to see file/line info (as Ruby does when it says I > >> need to add parens or something). > >> 2. To complain about some general condition occurring at runtime that > >> doesn't warrant bailing out of the app. > >> > >> My suggestion: Two names. Call the first one "warning" (the kind of > >> warning that Ruby gives us) and the second one "warn" (a simple verb > >> that just prints to stderr). > > > > One of the main things I like about Ruby is that the names are so > > intuitive. > > Once i check out a particular class or method in the reference, it is > > pretty much guaranteed that i won't forget it ever. Even better, > > sometimes i just guess what the name of a particular entity might be, > > type it in and the program runs. This, for me, is a major plus for > > ruby. > > Even if a particular name is esoteric, it is esoteric in a way i > > remember and find difficult to forget. > > > > Okay, what i'm driving at is this: Naming one method 'warn' (A verb. I > > like that) and another 'warning' (A noun. Don't like it much) is quite > > confusing :( > > There doesn't seem to be any clue in their names to differentiate > > their functionality from each other. > > How about: > warn "Server timed out. retrying." > warn! "That number seemed a bit high... Possible error." > > This would keep the old behavior for warn(), but add a new function > warn!(), which would be used for more serious warnings where you want > to include a traceback. Ops, didn't read your post before I send mine. Similar thoughts. :-) Kind regards robert