« first day (12 days earlier)      last day (4939 days later) » 

4 mins ago, by Reed Copsey
but - before you do that - why foreach is bad: http://blogs.msdn.com/b/ericlippert/archive/2009/05/18/foreach-vs-foreach.aspx
 
@Reed, thanks for that!
 
@Reed thanks - I was looking for that recently (during a similar conversation)
 
@TimRobinson I see that, I upvoted it too ... now to go suggest a meta.chat.meta.stackoverflow.com
 
@ReedCopsey I really don't get the relevance of it though, I'm asking about how I should implement my parsing method. See
4 mins ago, by drachenstern
yesterday, by Joren
I want to validate some data (a host name, but the specifics don't matter) in a few steps, while carefully and elegantly handling any errors. Which approach should I take: 1) A monadic approach with a Validated<T> type (consider it an extended Nullable<T>), 2) exception throwing validation code + catching everything later, or 3) exception throwing validation code wrapped inside Task<T>? Option 3 is sort of intermediate between 1 and 2.
 
9:01 PM
@drachenstern sure - I'll suggest it at meta.meta.chat.meta.stackoverflow.com
2
 
@TimRobinson lmao
 
That is to say, I have a private IPEndPoint Validate(string hostName), how should I deal with the various kinds of errors I might have while parsing?
 
@Joren since you mentioned monads yesterday, can I suggest the functional approach?
invent an Either<T1, T2> type, which can contain either IPEndPoint, or an object containing error information
 
Well, I'd probably throw in that cae
case - and have your exception handler generate the IDataErrorInfo for your UI, so you can report it correctly
 
... Should I throw exceptions? Change the signature to private Validation Validate(string hostName, out IPEndPoint) (where Validation is some enum of error cases), Change it to private Validated<IPEndPoint Validate(string hostName)? (Monadic approach), or perhaps even private Task<IPEndPoint> Validate(string hostName) with the Task wrapping the exceptions I throw
 
9:04 PM
0
Q: When will we see meta.chat.meta.stackoverflow.com on the SE system?

drachensternA few of us on chat think it's a good idea... You know, for when you really feel the need to make a suggestion for things that the chat system needs but you don't want to clutter the whole meta.stackoverflow.com experience. Of course, then we'll need http://chat.stackoverflow.com/transcript/m...

 
I would just do: private IPEndPoint Validate(...) and then throw an exception if it fails
and have your error handler build the appropriate info for the UI
 
@Tim I guess Validated<IPEndPoint> is equivalent to Either<Validation, IPEndPoint>
 
actually tbh I'd do what @Reed is suggesting
and by "I'd do", I mean "have done in the past"
 
Wikipedia: "In computer programming, a software framework is an abstraction in which common code providing generic functionality can be selectively overridden or specialized by user code providing specific functionality." Can anyone give me an example of this?
 
that's just like Int32.Parse, etc
you could always do a bool TryValidate(string, out IPEndPoint)
 
9:06 PM
does that just mean I override a method existing like the OnActionExecuting for example in MVC?
 
but then you'd have no way to provide more info (via exceptions)
 
@Reed: See my message http://chat.stackoverflow.com/transcript/message/58460#58460
Could return an enumeration instead of a bool
 
@Shogun think of a framework as a collection of utilities to make development easier. The overridability is just a natural byproduct, but the concept is that you have a group of methods and tools and natural classes that make development easier.
 
I've tried the monadic approach, but it's unwieldy and hard to read
 
@Joren I always thought enumerated responses made more sense than Exceptions, but I like what @ReedCopsey is suggesting
 
9:07 PM
@Shogun yes. A "Framework" is pretty much any set of tools/libraries/etc that you can use to build upon. When you develop in C#, you're using an IDE (Visual Studio), the CLR (runtime), and everything that your app uses is part of hte "framework" - from MVC methods down to "string" and "Int32", etc
 
The Task approach makes little sense, since it's just the exception approach in a wrapper – the caller can always add the wrapper later
 
ok, a little more specific, I'm reading the definition for Inversion of Control and I don't see how this is different from encapsulation
 
@Shogun ~ aha! That one is a little more tricky and nuanced in my opinion.
 
such that it needs it's own term?
 
@drachenstern It basically boils down to the question between int.Parse and int.TryParse
 
9:08 PM
@Shogun have you come across dependency injection too?
 
o.O
 
I see it as one is what you do as a normal dev, the other one is something the framework does for you
 
Inversion of control - at its simplest, is when you provide your code to something out of your control
2
 
@Joren I agree
 
any callback is using IoC
for example
 
9:09 PM
(actually, as a piece of terminology, DI is much less vague than IoC)
 
@ReedCopsey good definition
@TimRobinson good point
 
@Joren: Both have their uses - but if you want to include extra information about what specifically went wrong, int.Parse style is better - if you just want to see if it's correct, int.TryParse is nice
 
@TimRobinson omg it's the same thing again wtf
 
@drachenstern But the int.Parse exception is vexing. Both literally, and in Eric Lippert's sense: blogs.msdn.com/b/ericlippert/archive/2008/09/10/…
 
with IoC - you're giving up control of execution to some other code, and allowing it to decide when (and if) your "code" runs
 
9:09 PM
dependency injection - "don't use new, I'll give you the objects you need"
 
@ReedCopsey and he wants to provide extra info, hence my suggestion of a special Exception with further derived exceptions
 
ohhh... woa..
 
@ReedCopsey I can still use the TryParse style, but returning an enum instead of a bool
 
the ocean goes deeper than I thought!!
 
@Joren yep
 
9:10 PM
So why would Parse be better than TryParse?
 
@Shogun welcome to the party mate, have a brew
 
Or the other way around
 
this reminds me of the first time i saw the grand canyon in person..
 
@Shogun but don't just grab a brew, let someone else pass the required brews into a constructor
 
@Joren You're basically introducing magic numbers at that point - en.wikipedia.org/wiki/Magic_number_(programming)
even if they're wrapped into an enum
you still have to turn that enum into something useful
 
9:12 PM
or I guess I could implement a girlfriend event listener that gets the beer whenever the glass hits the table and is empty event happens? lol
 
@Shogun I think you understand IoC then :)
 
lmao, yep
 
DI is more like "I just need a beer here" instead of "I'm going to go brew up some malt and hops now..."
 
@Reed how would an enum ever be worse than a bool? You could implement an int.TryParse that returns either Success or Failure as two enum possibilities, and I don't see how then it's suddenly magic numbers, but not when it's true or false
 
and let somebody else make it
 
9:14 PM
@joren you still have to decide what to do with the true and the false
 
Also I've never heard someone use 'magic numbers' when there is no actual number constants involved
 
@Joren You only have 2 states, at that point - success/failure is a bit different than a series of possibilities
 
@drachenstern: Yes, that's up to the caller to decide?
 
but even there, you're going to have to turn that into a "This is not a valid number for this ..."
 
2
A: When will we see meta.chat.meta.stackoverflow.com on the SE system?

Marc GravellSigh... is it Friday already? If in doubt; chat feedback should achieve everything in the question.

@ReedCopsey he could be using them for tracking responses, and not so much for making choices
 
9:15 PM
apparently it's not meta all the way down
 
@Joren ok but it still has to be dealt with
@TimRobinson I know
 
@ReedCopsey Yes, of course. In the TryParse you would eventually do an if on the return value. In the enum case you could do a switch instead.
 
in unrelated news, I think I got my home VPN working
 
@Joren just a term, of course. I've called lots of things magic numbers that weren't numbers
@TimRobinson yay, nice
 
in case I log onto a wifi network and some guy sniffs my password with Firesheep
 
9:16 PM
I don't think an if or switch is much too different from a series of catch clauses for different exception types, which is what you would otherwise end up with
 
All I know is this is important business:
87
Q: Question title that doesn't describe the problem

Pollyanna Pre Edit 4: Pointing out that thread's popularity is a direct result of programming community interest in said subject, and that someone likely stands to become rich and/or famous by solving the problem none of the answers, save my own, came even close to resolving. Long salutation desc...

 
Also, what do you guys think about what Eric Lippert says in his related blog post:
Vexing exceptions are the result of unfortunate design decisions. Vexing exceptions are thrown in a completely non-exceptional circumstance, and therefore must be caught and handled all the time.

The classic example of a vexing exception is Int32.Parse, which throws if you give it a string that cannot be parsed as an integer. But the 99% use case for this method is transforming strings input by the user, which could be any old thing, and therefore it is in no way exceptional for the parse to fail. Worse, there is no way for the caller to determine ahead of time whether their argument is ba
(No idea how to blockquote in a reliable way)
 
@Joren I agree with Eric, I liked the way he phrased that
 
@drachenstern humorous reply indicating reaction
 
Hullo Marc
Come to see what all the hubbub was about? ;)
 
9:18 PM
@Joren I do too - but you're not talking about raising the exception out of your API here - you're handling it internally
 
So IoC does that usually just mean objects within your one app, or could it mean multiple processes communicating with each other too?
 
The opposite - I've come to relax after a long day with chat.SE ;p
 
@Shogun IoC is more of a conceptual thing. It's possible to use IoC across multiple processes/machines as well as within a program
 
@Shogun it tends to be at the low level, i.e. classes interacting with eachother
 
9:19 PM
I happened to notice the similarity on the username between the chap curious if I was on to my Friday a tad early and the fella that just landed in the chat ;)
 
@ReedCopsey True, but I like to make my internal code as clean as it would be if it were a public API
 
cool, thanks for the feedback guys... now speaking of brew I want a beer, fairwell
 
well, it wouldn't occur to me to refer to cross-process communication as IoC
 
beer + fallout new vegas = good evening :D
 
9:20 PM
@TimRobinson nor I but it does work
@Shogun beer + vegging out in front of the TV is a good evening too
 
@drachenstern yep, I see that
 
@TimRobinson I wouldn't either - except things change a bit when you start thinking of clustering/HPC "application"
 
I don't have TV :O
 
etc
 
@drachenstern I guess Ajax would be an example of IoC across machine boundaries
 
9:21 PM
I only pay for internet, TV is too intrusive, I don't get to decide what is on :)
 
or presumably any web app
 
@TimRobinson Yeah but I wouldn't have before the comment was made here, I would've assumed a different paradigm
 
@Reed: But what do you think would be positively better about using exceptions? The one thing I can think of is that you can't just ignore them, but I'm not sure that's a plus in this case. What drives your preference for one over the other?
 
@Shogun hello DVR
 
@drachenstern but still that's just deciding WHEN not WHAT
 
9:22 PM
@Joren I like it because it lets you put the actual true error message right where you're checking for the error
with an error code, you're putting the code there
then other code outside has to decipher and translate that again
 
@Shogun so googletv then in addition? or in place of?
 
it's basically a DRY issue for me
 
I see no reason to have TV, /shrug
i can get any news or info instantly from the web
 
@ReedCopsey so grab the exceptions that bubbled up and turn them into a string before giving up control? In other words, have all the joys of the exceptions internally in your own module, just don't let them escape your own module?
 
in terms of if i need to know something important that is
and i have never been impressed by popular network TV..
 
9:23 PM
yeah - if the thing you're handling is really exceptional
I like exceptions for user input - there are just so many little nuances you can handle that way
if you want to avoid it - you can easily enough
but I would do it in such a way that you can directly set the info in the validation
instead of setting it + translating it later
but that starts making code look ugly
 
@ReedCopsey Okay, that makes sense. But I'm not too fond of putting UI messages into exceptions ... that doesn't generalize too well. What if I want the UI messages to be localized? Should my parsing code know about localization? What if my code is eventually hoisted to a public API? In that case the caller would still have to do his own transformation to whatever messages he wants to provide
And what if my preferred UI output messages contain some more data that only the UI has access to?
 
I hope they keep working on this chat, or it's just my browser, but I don't see why so many things need to refresh when a new chat message appears
my whole damn screen flashes..
 
there are times when it doesn't make sense - though your localization can do a translation from that error string to your localized one (even with codes, you'd still do that)
 
or is that only when someone appends to an already existing chat when nobody else has said something?
test
 
@Shogun I think that's a Firefox problem
 
9:26 PM
yeah that's what it is.. weird
 
@Shogun I think it's just yours
@Shogun I don't see that, but I'm on chrome
 
ohh yeah I am on Firefox.. I should get Chromium
 
perhaps
 
rocking ubuntu on my thinkpad
visual studio in virtual box, BSODs = 0
 
Oct 15 at 16:28, by Skawful
Anyone else's screen flashing for new messages?
 
9:27 PM
i kept having them like once or twice a month when running windows 7 native.. i could blame lenovo i guess
 
somewhat off topic - why the async ctp excites me:
0
Q: C# BackgroundWorker - how should i get rid of DoEvents

pocoI'm trying to figure out the best way to handle a backgroundworker that is triggered off radio button clicks. I created a very simple form with 3 radio buttons and a label. Each of the radio buttons share the same event radioButton_CheckedChanged. If the event completes then I update the label ...

 
you'll never get rid of DoEvents
 
it won't be for lack of trying, though.
 
@TimRobinson I don't ever use DoEvents
they hid it very well in WPF
 
Couldn't he just use a callback on that?
 
9:30 PM
I don't think I've used it since VB3
 
so at least it's not quite as easy
 
but, we haven't seen the last of DoEvents
 
Like "don't use regex to parse html", .NET has "don't use DoEvents; ever" and "don't abort threads; ever"
 
@MarcGravell why would you "don't abort threads, ever"? that seems a little finalistic to me
 
9:31 PM
@MarcGravell this can be the new channel description
@drachenstern from my recollection, the majority of "CLR via C#" explains why thread aborting is bad
 
@Reed
What I'm trying to say is that in general (if your error handling is complex enough that your parser logic can't do it all by itself), it's going to boil down to a few options:

1) Parsing logic gives you some error enum value, which you `switch` upon to decide what to do. (`case Foo: {}` `case Bar: {}` etc)
2) Parsing logic throws you one member of some exception hierarchy, and you have a sequence of `catch (FooException e) {}` `catch (BarException e) {}` to decide what to do.
3) Parsing logic throws you a single type of exception, and you `switch` upon the exception message to decid
 
(possibly not the majority, but it did put me off calling Thread.Abort)
 
@drachenstern aborting a thread is very, very bad - you should never do thread.Abort()
@Joren Or parsing logic throws you one exception, with properties you need to build your results in a unified manner
 
I'm totally not trolling when I say this but I wonder why .Abort() exists then
 
Just seems like there may be occasions where it's necessary (altho I can't think of any) and since I would use a thread to contain a function, I would prefer to just exit the function and let the thread sit idle ...
@Shogun that's what I'm thinking
The worst that happens is I introduce a bit more overhead for the OS/GC
It's not like spawning new threads is really intensive
 
9:34 PM
switched to chrome, now the chat is smooth, but now i remember why i dont use google chrome, no master password!
 
The "ever" probably deserves a really really small asterisk - with footnote "unless you are absolutely 100% certain you know what you are doing - meaning you are a threading internals guru beyond human power"
 
Fair enough, didn't consider that. In my case then, I have nothing to report other than what kind of error it was, so there would be a single property with the aforementioned enum value in it.
That then makes both options almost exactly equivalent ... the only difference is, do you return an error code, or do you throw an exception?
 
@MarcGravell Oh, well when you say it like that, I agree wholeheartedly
@Joren return
and I think that THAT is the new room description ;)
 
And then it's almost exactly just int.Parse vs. int.TryParse again
 
"unless you are absolutely 100% certain you know what you are doing - meaning you are a {Jon Skeet}esque guru beyond human power" ... no?
 
9:36 PM
Except instead of a FormatException (or whatever) in the Parse case you have an exception with more info, and instead of the bool in the TryPase case you return more info.
 
9:58 PM
So wow, that got all quiet ...
 
because it just hit 5pm?
 
perhaps so
 
on that note i'm done for the day too.
 
later @entens
 
10:25 PM
and i'm back
 
and I never left ;)
 
trying to work out whether MSBuild scripts are Turing complete
I don't think they are
you can't loop or recurse
 
@TimRobinson I'm pretty sure they're not
@TimRobinson but all you need is to be able to jump
 
you can invoke one target from another
you can pass values between targets
 
@TimRobinson does that indeed let you implement a goto like structure? must it return after invoking?
 
10:29 PM
but because all flow control statements are determined at startup, you'll either loop forever, or not loop at all
@drachenstern right, <CallTarget/> is a subroutine call
 
if the statement is true "you'll either loop forever or not at all" it's not turing complete
 
right
I think -- by design -- the complete program flow is determined at startup
 
then no, it's not turing complete imo
or rather, the language is unlikely to be so
 
in your opinion, and in Turing's opinion :)
I guess you can't prove that it's not Turing complete, only that it is or might be
 
well that and IIRC only the language can be deemed to be TC, the program in specific can always be a turd
 
10:33 PM
but if a language is not TC, then you know that you can inspect any program in that language and determine whether it's a turd
 
lol, I think so ;)
 
i.e. the parser could detect scripts that fall over, and refuse to run them
which can't be said of most languages
 
If there is no loops or recursion whatsoever, then it not going to be turing complete, no
And even if you have loops, you don't necessarily have a turing complete language if you don't have infinite memory
I mean, a finite state machine certainly allows looping
But it's far from turing complete
The 'finite' part is the problem ... a turing machine has an infinite number of possible states
 
it looks like you could recurse, but I can't see anything that would stop the program recursing forever
 
Do you have (theoretically) infinite memory?
 
10:42 PM
try to write a Brainf*** interpreter using only what's here: msdn.microsoft.com/en-us/library/0k6kkbsd.aspx
@Joren yes, as infinite as any other program
 
Then if you can recurse indefinitely then it should be turing complete
 
you can define whichever variables you like, and you could always go to the file system
ah - you can't tell whether a universal Turing machine will halt or not on a given program
whereas I think you can look at an MSBuild script and decide up front whether it will halt when run
 
How?
 
because all of the flow control constructs have to appear at the top level
and their conditions are evaluated at startup
it looks like the control flow graph is determined once and then run
 
Flow control is static?
 
10:46 PM
@TimRobinson that's the key, and if the control graph is pre-determined then it's not TC
@Joren would that surprise you on MSBuild?
 
@Joren right, I can't find any flow control constructs that aren't static
 
I've never used MSBuild, so no idea what to expect
If all flow control is static, then it's basically a FSM
Hell, even less powerful than that
 
@Joren exactly
 
Even a FSM can go into one of several possibilities based on its input
So MSBuild is always just a straightforward, invariant sequence of operations?
 
it looks like it
which is nice
 
10:49 PM
Well, nice for some purposes :P
 
because it allows you to write tools that can parse scripts and do something useful with them
it's more like a data file format than a program
 
Yeah, it makes analysis or manipulation a lot simpler
But of course MSBuild itself is then a lot less powerful
 
for practical purposes it's reasonably adequate
it's no problem to loop over a set of files
and do something on each one
it's even got map-like functionality, i.e. run a transformation across a set of values
 
photo.stackexchange.com has quite a slick layout ... at least at the banner level. I like it.
 
Well sure, I don't really see why my build process would need to be able to do arbitrarily complex computations :P
 
10:51 PM
it's just that the values in the set - file names etc. - can be determined without running the program
@Joren me neither, but apparently GNU make is Turing complete
@drachenstern me too, looks pretty good
 
is it sad that my Area51 account has my second highest SE rep?
You've associated your Photography and Area 51 accounts: +100 reputation
 
I don't think any of my SE accounts has any amount of rep except the 101 default
Except stackoverflow of course
 
Congrats, you've gained the privilege – create chat rooms and 8 other privileges
wow, I automatically qualify to do like half what needs to be done ... interesting
 
@TimRobinson I wonder if the people who made GNU make would make a regular expression library turing complete if they wrote one ;)
 
only 25 more points to vote downing
 
10:54 PM
(Just think of the horrors)
 
@Joren ouch
 
Regular expressions are evil anyway
They're lovely for mathematics
For specifying languages
But if you're trying to write a state machine to parse something ... I'd rather have something more readable
 
hunter2 ... lovely passwords ... if I bring up a window that will ask for a password and the window has focus, why can't I just start typing? stupid focus .... grrrrr
"You have 5 votes left today" ... guess it's time to go home then ;)
 
11:15 PM
@drachenstern hey, we have the same password
 
how do you know what my password is??? it should be *******!!!
fortunately there's a redo ;)
 
11:38 PM
And with that ladies and germs I will officially depart for the lovely remainder of this ... gray evening
 
11:48 PM
hello
 
Rye
morning guys
 
evening
 

« first day (12 days earlier)      last day (4939 days later) »