1. Exception handling
- Posted by axtens_bruce Jan 31, 2023
- 1210 views
In the early history of Euphoria it was decided that exception handling would not be present in the language. Can someone point me to the documentation where that's discussed. After years of try/catch and try/catch/finally it's challenging to go back to a language without those constructs.
-Bruce
2. Re: Exception handling
- Posted by katsmeow Jan 31, 2023
- 1206 views
I think there is a law to the effect that no language or computer motherboard can have all the good stuff in/on it.
Kat
3. Re: Exception handling
- Posted by ghaberek (admin) Jan 31, 2023
- 1204 views
In the early history of Euphoria it was decided that exception handling would not be present in the language. Can someone point me to the documentation where that's discussed. After years of try/catch and try/catch/finally it's challenging to go back to a language without those constructs.
Here you go: Try/Catch Dec 30, 2014. Over 200 replies, possibly our largest thread ever!
-Greg
4. Re: Exception handling
- Posted by petelomax Feb 01, 2023
- 1100 views
Of course Phix has already got try/catch.
5. Re: Exception handling
- Posted by axtens_bruce Feb 01, 2023
- 1087 views
As I was waiting for the bus this morning I was wondering how I'd write my JS code without try/catch. It was an interesting gedanken. One place where it would be pretty hard to avoid is where my JS code, running under C# via ClearScript is connected to Selenium. Occasionally, the connection dies without warning. I can catch the death by something like
function isHeDead(driver) { try { var url = driver.Url; return false; catch (E) { return true; } }
Now this is all dotnet, something that AFAICT Euphoria and Phix aren't addressing, and so the connection technology doesn't have an analogue. But I do wonder if such things can happen in OE/P where something dies that's can't be detected without the test itself terminating the process.
In any case, I'm not pushing for OE to have try/catch. I'll create the track as targeting Euphoria generally and then hand it over to the OE maintainers to bless or butcher as they see fit.
6. Re: Exception handling
- Posted by katsmeow Feb 01, 2023
- 1034 views
Now this is all dotnet, something that AFAICT Euphoria and Phix aren't addressing, and so the connection technology doesn't have an analogue. But I do wonder if such things can happen in OE/P where something dies that's can't be detected without the test itself terminating the process.
This is one reason i added task.e features into http.e. And why i wrote a layer over memshare.ew to make transparent global shared vars. Between the two of them, your program(s) can be aware of what various parts of itself are (not) doing.
Kat
7. Re: Exception handling
- Posted by petelomax Feb 03, 2023
- 812 views
dotnet, something that Euphoria and Phix aren't addressing
Not entirely quite sure what you mean by that, care to elaborate? [If you're talking about plundering C:\Windows\WinSxS, then, sure, I ain't going anywhere near that utter madness.]
8. Re: Exception handling
- Posted by ghaberek (admin) Feb 03, 2023
- 808 views
As I was waiting for the bus this morning I was wondering how I'd write my JS code without try/catch. It was an interesting gedanken. One place where it would be pretty hard to avoid is where my JS code, running under C# via ClearScript is connected to Selenium. Occasionally, the connection dies without warning. I can catch the death by something like
function isHeDead(driver) { try { var url = driver.Url; return false; catch (E) { return true; } }
Now this is all dotnet, something that AFAICT Euphoria and Phix aren't addressing, and so the connection technology doesn't have an analogue. But I do wonder if such things can happen in OE/P where something dies that's can't be detected without the test itself terminating the process.
In your example, you're fetching the URL property of the driver in order to determine the connection status, correct? If I were writing a Selenium library for Euphoria, I would do the same thing:
function isHeDead( atom driver ) -- Selenium_GetUrl() would return a sequence (the URL) -- or an atom (an error code, like ERR_TIMEDOUT). object url = Selenium_GetUrl( driver ) if atom( url ) then -- we received ERR_TIMEDOUT return FALSE end if -- we received "https://..." return TRUE end function
Now I'm not saying try/catch isn't a good thing, but in this example I don't see how the two methods are any different.
You could also try the Go approach, which also doesn't have exceptions and instead returns a value and error code from every function:
function isHeDead( atom driver ) -- Selenium_GetUrl() would always return a sequence containing two items: -- [1] a sequence: the URL (on success) or an empty sequence (on error) -- [2] an atom: the error code (on error) or zero (on success) atom err sequence url {url,err} = Selenium_GetUrl( driver ) if err then -- we received {"",ERR_TIMEDOUT} return FALSE end if -- we received {"https://...",ERR_OK} return TRUE end function
This approach is more strictly enforced in Go than it would be in Euphoria, but it provides good error handling without exceptions. The multiple assignment feature was added in Euphoria 4.1.
In any case, I'm not pushing for OE to have try/catch. I'll create the track as targeting Euphoria generally and then hand it over to the OE maintainers to bless or butcher as they see fit.
What are you talking about, Bruce? It's your baby! You'll need to raise maintain it yourself.
-Greg
9. Re: Exception handling
- Posted by axtens_bruce Feb 03, 2023
- 760 views
dotnet, something that Euphoria and Phix aren't addressing
I said that more by way of clarification than anything else. As I was thinking about how I might program some situations at work without try/catch I gave my earlier example not being aware of any analogue in the Euphoria space. Since then Kat's mentioned the use of task in http. I was not by any means suggesting Euphoria.NET (any more than I might suggest Euphoria.JVM). I think I'd suggest Euphoria.LLVM first.
-Bruce
10. Re: Exception handling
- Posted by axtens_bruce Feb 03, 2023
- 738 views
In any case, I'm not pushing for OE to have try/catch. I'll create the track as targeting Euphoria generally and then hand it over to the OE maintainers to bless or butcher as they see fit.
What are you talking about, Bruce? It's your baby! You'll need to raise maintain it yourself.
Thus why I keep poking my nose in to see how 8th and COBOL are getting on.
But thanks for all your examples. Finding out how to detect that Selenium has somehow died in the background without the test crashing the program would be great as there are a large number of instances in the program where Selenium is used.
-Bruce