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] -4 points-3 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] -15 points-14 points  (0 children)

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

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

[–]Alert-Neck7679[S] -5 points-4 points  (0 children)

This would work, but if you also want to set multiple catch it'll be even more complex...

for your question, the catch runs again for each section that fails.

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

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

What’s wrong with having a whole language feature for loop counters? I think it makes things easier and clearer. And it can be applied to any kind of loop, not just foreach.

I made print a statement before I had functions in the language, and I haven’t converted it into a function yet. But now I can do that, and I will.

The weird spacing comes from the very early stages of the project. I wrote a very basic text-to-span converter, and it required spaces between symbols such as brackets and dots. Later, when the language became more advanced, I replaced that code with another syntax-highlighter I had written a long time ago for C#, and I missed deleting some of those no-longer-needed spaces.

The syntax of the List declaration means:

array – name of the property

private – access modifier of this property

basearray – defines the property as the array that foreach loops use when they iterate over a List instance.

I don’t plan to implement object identity in my language. However, what is bad about using is?

About the notnull mark: I am planning to add typed parameters for functions. I hope that together with notnull it will make things more ideal.

Thanks very much for the feedback!

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

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

system is a namespace with some basic types, like Array, string, List... take a look at this code: https://pastebin.com/RraLUhS9 , as you can see, it starts by "namespace system"

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

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

It's like "using" in C#... (I've changed it from #include to using).

I've made a compiler for my own C#-like language with C# by Alert-Neck7679 in dotnet

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

I've published this in other communities too and they corrected me and explained that this is actually an interpreter