October 06, 2014
On 10/6/14, 11:13 AM, Jacob Carlborg wrote:
> Then you'll always catch all exceptions. If error code doesn't match you
> need to rethrow the exception. Or make a language change that allows to
> catch based on the error code.

Either solution is fine here because that's the rare case. -- Andrei
October 06, 2014
On Sunday, 5 October 2014 at 20:37:18 UTC, Nick Sabalausky wrote:
> forbidden from advancing at their own level (thus boring the shit out of them and seeding quite a few additional problems).

Yeah, I've always wondered if the motivation for keeping kids locked up in schools is to prevent them from doing mischief in the streets and teach them to accept hours of pointless boredom so that they will eventually accept doing boring pointless stuff when they later join the workforce as bureaucrats. :-/

> Obviously US teachers have no idea what the word "fair" actually means. But then, in my experience, there's a LOT that US teachers don't know.

The status of teaching has gone downhill. It used to be viewed as highly skilled work, then you got some idealistic teachers of the 1968-generation, but after the yuppie period in the 80s it has become the easy path to higher-education when you don't know what you want to do except that you aren't good with theory and you want to work with people. I think the same can be said about psychology, the field you enter if you don't know what to study and find science too difficult… (or am I being unfair?)

> statement on unions in general, BTW) and the complete and total lack of "logic" being part of the curriculum *they* were taught as kids (which is still inexcusably absent from modern curriculums).

"logic" is theory. Theory does not belong in schools. Too difficult. You are only supposed to learn things that you don't have to figure out, otherwise finding qualified teachers will become impossible.

> US has a few of those too. They're constantly ridiculed (leave it to the US to blast anything that isn't group-think-compatible), but from what I've seen Montesorri's are at least less god-awful than US public schools.

We have a few Montesorri and a few more Rudolph Steiner schools. Which I believe are better at motivating kids and at least not killing the fun of learning. Learning that figuring things out and doing things your own way is fun is a very important lesson.

The government says that the public school system has changed and is kind of incorporating those methodologies too, but that is not what I see. And how can a single teacher handle 27 kids in a class, with only 2 minutes per kid per hour and a rigid plan for what you are supposed to teach?

Btw, did you know that the majority in Norway voted against joining EU, so we did not, but since the majority of politicians were pro EU they got us in the backdoor by signing away our freedom in treaties instead? And even when the treaties do not apply we "harmonize our laws to EU" because we "just have to". So thanks to bureaucratic maneuvers we are now 99% EU regulated, have shittier consumer laws than we used to, have next to no control on the borders and are flooded by romanian beggars and criminals from every corner of Europe and beyond, in return we get no vote in the EU decision making process since we are "independent"… You gotta love democracy…

On a positive note: the IOC managed to demand that the norwegian King ought to hold a party for the IOC leaders and additionally demanded that he should pay their drinks. It was part of their 7000 page olympics qualification requirements document. It is so heavily regulated that it explicitly specifies that the personnel in the hotels MUST SMILE to the IOC leaders when they arrive. I kid you not, even games and past times are heavily bureaucratic down to minuscule details these days. So, due pressure from the newspapers/grassroots and the royal insult the politicians eventually had to turn down the ~$10.000.000.000 winter olympics budget proposal. Good riddance. Live monarchy!

I am personally looking forward to Beijing hosting the winter olympics 2022. I am sure they will mange to fake a smile after the politicians have demolished their homes to make space for the ski-jumping event.

In the meantime Norway should not even think about hosting any sporting event until we can avoid being ranked as the worlds most expensive country: http://www.numbeo.com/cost-of-living/rankings_by_country.jsp 'Cause, we all know that a $10 billion budget turns into at least a $30 billion budget before the games are over. That would have been $6000 per capita. I'd say that royal insult paid off.

Was this off-topic?
October 06, 2014
On Mon, Oct 6, 2014 at 7:50 AM, Andrei Alexandrescu via Digitalmars-d < digitalmars-d@puremagic.com> wrote:

> On 10/6/14, 7:01 AM, H. S. Teoh via Digitalmars-d wrote:
>
>> On Mon, Oct 06, 2014 at 06:46:31AM -0700, Andrei Alexandrescu via Digitalmars-d wrote:
>>
>>> On 10/5/14, 11:39 PM, Dmitry Olshansky wrote:
>>>
>>>>
>>>> It's obvious to me that one hierarchy is way to limiting for exceptions, simply because there could be many ways to categorize the same set of error conditions.
>>>>
>>>
>>> Well put. -- Andrei
>>>
>>
>> What's the alternative, though? I can't think of any solution that
>> (1) isn't far more complicated than the current state of things and
>> (2) is easier to use.
>>
>
> I'm thinking a simple key-value store Variant[string] would accommodate any state needed for differentiating among exception kinds whenever that's necessary.
>
>
And 'kinds' is a synonym for 'types' - You can have different kinds of problems, so you raise them with different kinds of exceptions.

s/kind/type/g and the question is: why not leverage the type system?

For a consumer-of-something-that-throws, having different types of exceptions for different things with different data makes sense.  You have to switch on something to determine what data you can get from the exception anyway.



> It's commonly accepted that the usability scope of OOP has gotten significantly narrower since its heydays. However, surprisingly, the larger community hasn't gotten to the point to scrutinize object-oriented error handling, which as far as I can tell has never delivered.
>

Maybe, but what fits better?  Errors/Exceptions have an inherent hierarchy, which maps well to a hierarchy of types.  When catching an Exception, you want to guarantee you only catch the kinds (types) of things you are looking for, and nothing else.


October 07, 2014
On 10/6/14, 4:46 PM, Jeremy Powers via Digitalmars-d wrote:
> On Mon, Oct 6, 2014 at 7:50 AM, Andrei Alexandrescu via Digitalmars-d
>     I'm thinking a simple key-value store Variant[string] would
>     accommodate any state needed for differentiating among exception
>     kinds whenever that's necessary.
>
>
> And 'kinds' is a synonym for 'types' - You can have different kinds of
> problems, so you raise them with different kinds of exceptions.
>
> s/kind/type/g and the question is: why not leverage the type system?

I've used "kinds" intentionally there. My basic thesis here is I haven't seen any systematic and successful use of exception hierarchies in 20 years. In rare scattered cases I've seen a couple of multiple "catch"es, and even those could have been helped by the use of a more flat handling. You'd think in 20 years some good systematic use of the feature would come forward. It's probably time to put exception hierarchies in the "emperor's clothes" bin.

> For a consumer-of-something-that-throws, having different types of
> exceptions for different things with different data makes sense.  You
> have to switch on something to determine what data you can get from the
> exception anyway.

Oh yah I know the theory. It's beautiful.

>     It's commonly accepted that the usability scope of OOP has gotten
>     significantly narrower since its heydays. However, surprisingly, the
>     larger community hasn't gotten to the point to scrutinize
>     object-oriented error handling, which as far as I can tell has never
>     delivered.
>
>
> Maybe, but what fits better?  Errors/Exceptions have an inherent
> hierarchy, which maps well to a hierarchy of types.  When catching an
> Exception, you want to guarantee you only catch the kinds (types) of
> things you are looking for, and nothing else.

Yah, it's just that most/virtually all of the time I'm looking for all. And nothing else :o).


Andrei

October 07, 2014
On 10/6/2014 10:09 AM, Dicebot wrote:
> It is only in undefined state because language handles Errors that way. At the
> point of throwing the Error state was perfectly defined and 100% recoverable.
> This is the typical case for assertion failure in contract - it detects some
> program flaw like inability to handle specific data combination from other
> process but it does not mean memory is corrupted or program is inherently
> broken. Just killing the fiber and continuing with other requests (which don't
> trigger that unexpected code path) is absolutely fine unless compiler kicks in
> and optimizes something away in surprising fashion.

What you're describing sounds like using asserts to validate input data. This is not what asserts are for.

October 07, 2014
On Mon, Oct 06, 2014 at 07:55:23PM -0700, Walter Bright via Digitalmars-d wrote:
> On 10/6/2014 10:09 AM, Dicebot wrote:
> >It is only in undefined state because language handles Errors that way. At the point of throwing the Error state was perfectly defined and 100% recoverable.  This is the typical case for assertion failure in contract - it detects some program flaw like inability to handle specific data combination from other process but it does not mean memory is corrupted or program is inherently broken. Just killing the fiber and continuing with other requests (which don't trigger that unexpected code path) is absolutely fine unless compiler kicks in and optimizes something away in surprising fashion.
> 
> What you're describing sounds like using asserts to validate input data.  This is not what asserts are for.

Using assertions in contracts in D currently has some design issues, one of the foremost being that in-contracts of derived classes are allowed to be more relaxed than base classes, which means that the effective contract is (baseClassContract || derivedClassContract).  However, since in-contracts are allowed to be arbitrary statements, the only way to implement this is to catch AssertErrors and continue running if at least one of the contracts didn't assert. But that means we're technically in an undefined state after that point. :-(

(If the in-contract calls a nothrow function that asserts, for example, dtors may have been skipped, cleanups not performed, etc., and yet we blindly barge on because the other contract didn't assert.)


T

-- 
LINUX = Lousy Interface for Nefarious Unix Xenophobes.
October 07, 2014
On 06/10/14 20:26, Andrei Alexandrescu wrote:

> Then scope them.

We already have scoping rules built in to the language. Why should we invent a new way and set of rules for this.

-- 
/Jacob Carlborg
October 07, 2014
On 10/06/2014 07:06 PM, "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= <ola.fosheim.grostad+dlang@gmail.com>" wrote:
> On Sunday, 5 October 2014 at 20:37:18 UTC, Nick Sabalausky wrote:
>> statement on unions in general, BTW) and the complete and total lack
>> of "logic" being part of the curriculum *they* were taught as kids
>> (which is still inexcusably absent from modern curriculums).
>
> "logic" is theory. Theory does not belong in schools. Too difficult. You
> are only supposed to learn things that you don't have to figure out,
> otherwise finding qualified teachers will become impossible.
>

Math is theory too.

But regardless: Yes, there *is* a theoretical side to logic, but logic is also *extremely* applicable to ordinary everyday life. Even moreso than math, I would argue.

Now, I don't necessarily mean things like formal symbolic logic, lambda calculus. Although, my 9th grade math class *did* have a very heavy focus on formal proofs - and it wasn't even remotely one of the hardest math classes I'd taken, even just up to that point. Students can handle theory just fine as long as it isn't the more advanced/complex stuff...Although college students should be *expected* to be capable of handling even that. Now, *cutting edge* theory? Sure, leave that for grad students and independent study.

Anyway, when I say "teach logic in schools" I just mean (at the very least) the basic things: Like recognizing and identifying the basic logical fallacies (no need necessarily to dive into the actual latin names - the names aren't nearly as crucial as understanding the concepts themselves), recognizing ambiguity, understanding *why* the fallacies and ambiguity are flaws, and the problems and absurdities that can occur when such things aren't noticed and avoided.

This is VERY simple, and crucial, stuff. And yet I see SOOO many grown adults, even ones with advanced graduate degrees, consistently fail completely and uttery at basic logical reasoning in everyday life (and we're talking very, very obvious and basic fallacies), that it's genuinely disturbing.

>
> I am personally looking forward to Beijing hosting the winter olympics
> 2022. I am sure they will mange to fake a smile after the politicians
> have demolished their homes to make space for the ski-jumping event.
>

Don't know whether this has always been the case and just never got noticed until recent years, but between the last winter olympics and the recent soccer/football match, and what you're saying about 2022, I'm noticing a rather bad trend with these big international sporting events. I get the feeling this'll be something that'll get bigger and bigger until either A. the right people get together and do something about it, or B. things come to a head and the shit *really* starts to hit the fan. (Yes, I like outdated slang ;) ) Nothing good can come from the current trajectory.

>
> Was this off-topic?

It was off-topic several posts up. :)

October 07, 2014
On 10/7/2014 5:19 PM, Nick Sabalausky wrote:

> Anyway, when I say "teach logic in schools" I just mean (at the very
> least) the basic things: Like recognizing and identifying the basic
> logical fallacies (no need necessarily to dive into the actual latin
> names - the names aren't nearly as crucial as understanding the concepts
> themselves), recognizing ambiguity, understanding *why* the fallacies
> and ambiguity are flaws, and the problems and absurdities that can occur
> when such things aren't noticed and avoided.

In other words, critical thinking. This is something that, at least in America, is not at all part of the primary school experience.

>
> This is VERY simple, and crucial, stuff. And yet I see SOOO many grown
> adults, even ones with advanced graduate degrees, consistently fail
> completely and uttery at basic logical reasoning in everyday life (and
> we're talking very, very obvious and basic fallacies), that it's
> genuinely disturbing.
>
>>

I've personally seen two university courses offered under different guises that try to correct this problem. One is called "Introduction to Mathematical Thinking" and is taught by Keith Devlin at Stanford. The other is called "Think Again: How to Reason and Argue", headed by alter Sinnott-Armstrong at Duke. Despite the disparity in the course titles and the very different approaches taken by the instructors, the content is directed at the same goal -- pushing students to get past their cognitive biases and critically and logically examine any data presented to them.

Sadly, American culture seems to increasingly encourage the opposite of critical thinking. It has almost become a badge of honor among some (rather large) circles to embrace a form of willful ignorance rooted in rejecting logic and hard, cold data in favor of falling victim to confirmation bias.


---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

October 07, 2014
On Tuesday, 7 October 2014 at 08:19:15 UTC, Nick Sabalausky wrote:
> But regardless: Yes, there *is* a theoretical side to logic, but logic is also *extremely* applicable to ordinary everyday life. Even moreso than math, I would argue.

Yep, however what the human brain is really bad at is reasoning about probability. I agree that primary school should cover modus ponens, modus tollens and how you can define equivalance in terms of two implications. BUT I think you also need to experiment informally with probability at the same time and experience how intuition clouds our thinking. It is important to avoid the fallacies of black/white reasoning that comes with propositional logic.

Actually, one probably should start with teaching "ad hoc" object-oriented modelling in primary schools. Turning what humans are really good at, abstraction, into something structured and visual. That way you also learn that when you argue a point you are biased, you always model certain limited projections of the relations that are present in real world.

> up to that point. Students can handle theory just fine as long as it isn't the more advanced/complex stuff...Although college students should be *expected* to be capable of handling even that. Now, *cutting edge* theory? Sure, leave that for grad students and independent study.

Educational research shows that students can handle theory much better if it they view it as useful. Students have gone from being very bad at math, to doing fine when it was applied to something they cared about (like building something, or predicting the outcome of soccer matches).

Internalized motivation is really the key to progress in school, which is why the top-down fixed curriculum approach is underperforming compared to the enormous potential kids have. They are really good at learning stuff they find fun (like games).

> This is VERY simple, and crucial, stuff. And yet I see SOOO many grown adults, even ones with advanced graduate degrees, consistently fail completely and uttery at basic logical reasoning in everyday life (and we're talking very, very obvious and basic fallacies), that it's genuinely disturbing.

Yes, social factors are more important in the real world than optimal decision making, unless you build something that can fall apart in a spectacular way that makes it to the front page of the newspapers. :-)

> big international sporting events. I get the feeling this'll be something that'll get bigger and bigger until either A. the right people get together and do something about it, or B. things come to a head and the shit *really* starts to hit the fan. (Yes, I like outdated slang ;) ) Nothing good can come from the current trajectory.

Yeah, I think the trajectory will keep going upwards until there are no more less-democratic countries willing to pay the price to look civilized.

It is probably also the result of it being increasingly hard to be heard in the increased and interactive information flow of media, so being big and loud is viewed as a necessity. The Internet makes it much easier to escape from the events, in the 80s the olympics would be on all media surfaces. I barely noticed the last winter olympics despite the 20 billion price tag.

>> Was this off-topic?
>
> It was off-topic several posts up. :)

At some point the forum will split into a developer-section and a end-user-section. It is kind of inevitable :). The current confusion about the roles of developer vs end-user is kind of interesting. Maybe it is a positive thing. Not sure. :-)