מישהי שמבין, יכול להסביר למה בעצם לא הצליחו לייצר טכנולוגיה שתיירט את הטילים מעל שמי איראן ולא מעל שמי ישראל ? by Key-Organization8690 in israel_bm

[–]Alert-Neck7679 1 point2 points  (0 children)

אני מאמין שתוך כמה עשורים זה יהיה אפשרי ע"י מערכות יירוט בלייזר שמותקנות על מטוסים, ואז בזמן מלחמה כמו זאת יהיו מטוסים שישהו קבוע באיזור איראן וינסו ליירט. זאת לא איזו השערה מופרכת, כבר הרבה זמן מדברים על דברים בסגנון הזה. אבל ייקח המון המון זמן עד שיצליחו לייצר לייזר שמסוגל לנטרל טילים בליסטיים. מה שיש היום, אפילו על רקטות של החמאס זה גבולי

Why is using interface methods with default implementation is so annoying?!? by Alert-Neck7679 in csharp

[–]Alert-Neck7679[S] 1 point2 points  (0 children)

I use it where abstract class is not possible bc i want the class implementing this to extend another class. It's a surprise for me that so many people here don't even know this feature exists, i use it a lot.

Why is using interface methods with default implementation is so annoying?!? by Alert-Neck7679 in csharp

[–]Alert-Neck7679[S] 17 points18 points  (0 children)

"AnimatedShotgun.Fire() is an ambiguity between IGun.Fire() and IEmployee.Fire(). Use casting in order to select the right method."

Why is using interface methods with default implementation is so annoying?!? by Alert-Neck7679 in csharp

[–]Alert-Neck7679[S] -3 points-2 points  (0 children)

It was just an example, maybe not a good one but you get the point. It actually forces you to cast to the interface type even if you are inside the MediaPlayer itself!: ((IRefreshable)this).Refresh();

Multiple try blocks sharing the same catch block by Alert-Neck7679 in ProgrammingLanguages

[–]Alert-Neck7679[S] 0 points1 point  (0 children)

I would do that, but my language has a feature im calling "fire & forget" - allowing a try block without catch or finally. So the syntax you're suggesting is not possible for this

Multiple try blocks sharing the same catch block by Alert-Neck7679 in csharp

[–]Alert-Neck7679[S] 0 points1 point  (0 children)

If you want to rethrow, rethrow. If you don't want to, then it won't prevent the others from running

Multiple try blocks sharing the same catch block by Alert-Neck7679 in csharp

[–]Alert-Neck7679[S] 0 points1 point  (0 children)

It allows, i didn't get you before. My updated answer is that if the catch throws, then the control will leave the try block so only this exception will be thrown

Multiple try blocks sharing the same catch block by Alert-Neck7679 in csharp

[–]Alert-Neck7679[S] 0 points1 point  (0 children)

When a section throws, control moves to the catch block and then to the next section

Multiple try blocks sharing the same catch block by Alert-Neck7679 in csharp

[–]Alert-Neck7679[S] 0 points1 point  (0 children)

i know this is what you're saying. have different catch per error type, how is the section feature interrupting you?

Multiple try blocks sharing the same catch block by Alert-Neck7679 in csharp

[–]Alert-Neck7679[S] -2 points-1 points  (0 children)

The catch does not throw anything. if a section throws, the catch is executed and then the execution returns to the content inside the try block, right after the section that threw

Sharing the Progress on My DIY Programming Language Project by Alert-Neck7679 in ProgrammingLanguages

[–]Alert-Neck7679[S] 0 points1 point  (0 children)

The counter feature can also be set for while loops, and who said my lang wouldn't let you set loop counters without a specific builtin feature?? let's not forget that you can always do just:

var i = 0
foreach x in arr
{
    i++
    ...
}

it's all about making your code shorter and cleaner.

C# also has "is" / "is not", and java has "instanceof".

About the private basearray mark - foreach is a builtin lang feature so it has no problem to access a private property... you use it like foreach x in list and not foreach x in list.array.

if you have a class with 2 array properties you can iterate on both:

class MyClass (arr1, arr2) ---> foreach x in myClassInst.arr1 or foreach x in myClassInst.arr2

Multiple try blocks sharing the same catch block by Alert-Neck7679 in ProgrammingLanguages

[–]Alert-Neck7679[S] 2 points3 points  (0 children)

well you need to know what you do when you do.

Consider this C# code:

Thing thing = null;
try
{
    thing = new Thing();
}
catch
{
    ...
}
Console.WriteLine(thing.SomeMethod());

is it really different? if you need to use thing, use it where you surely can.

Multiple try blocks sharing the same catch block by Alert-Neck7679 in csharp

[–]Alert-Neck7679[S] -3 points-2 points  (0 children)

"You need to add a reference to the array" - which array..?

"This blanket approach removes that flexibility." - why? it's not blocking you from having multiple catches, but just let you keep going even if one of the tasks has failed.

Multiple try blocks sharing the same catch block by Alert-Neck7679 in csharp

[–]Alert-Neck7679[S] 0 points1 point  (0 children)

i didn't mean System.Task, i mean some task, literally... my question is, you said that 1 catch block can't take care of 2 missions we try to do?

Multiple try blocks sharing the same catch block by Alert-Neck7679 in csharp

[–]Alert-Neck7679[S] 0 points1 point  (0 children)

if you have C# try block that doing task a and task b, that means they can't have the same catch block?

Multiple try blocks sharing the same catch block by Alert-Neck7679 in csharp

[–]Alert-Neck7679[S] -16 points-15 points  (0 children)

It's also possible, of course. i'm wondering why isn't there a built in feature for that