Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: Can extern "C" functions throw exceptions Date: Wed, 06 Oct 2021 16:12:53 -0700 Organization: None to speak of Lines: 50 Message-ID: <87pmsh7nnu.fsf@nosuchdomain.example.com> References: <7c6c3418-f54f-40dd-ba84-9b6b56bec1d2n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="0101718fcd2a42c8d4c22baec500ecab"; logging-data="5495"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kXJcQwfG9izEAqxyPT++/" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:rLBNFZJh62gqWLhtwhraZHI6LAI= sha1:MyuasuvrPxcyDe/95axFJkqHTDg= Xref: csiph.com comp.lang.c++:81887 Branimir Maksimovic writes: > On 2021-10-06, daniel...@gmail.com wrote: >> On Saturday, September 11, 2021 at 11:00:42 AM UTC-4, Alf P. Steinbach wrote: >> >>> And these are the guys creating a Windows calculator >>> that by default evaluates 2+3*4 as (2+3)*4. >> >> In Standard mode, but not in Scientific or Programmer mode :-) > --main = print $ calculate "3 * 2 + 5 / 2" > > calculate :: String -> String > calculate str = case (eval operatorRegister . words) str of > Just r -> printf "%.2f" (fromRational r::Double) > Nothing -> "Nothing" > > eval :: Register -> [String] -> Maybe Rational > eval [] _ = Nothing -- No operator found. > eval _ [] = Nothing -- If a operator don't have anything to operate on. > eval _ [number] = let a :: Maybe Double = readMaybe number > in case a of > Just a -> Just (toRational a) > Nothing -> Nothing > eval ((operator, function):rest) unparsed = > case span (/=operator) unparsed of > (_, []) -> eval rest unparsed > (beforeOperator, afterOperator) -> > function > <$> (eval operatorRegister beforeOperator) > <*> (eval operatorRegister $ drop 1 afterOperator) I don't know what language that is, and you haven't bothered to tell us. (No, I'm not asking, just saying that whatever point your post might have is defeated by not knowing what language you're using.) Again, you've posted something that isn't relevant either to the subject of this newsgroup (the C++ language) or to the thread (which is about extern "C" functions throwing exceptions, with a passing reference to the Windows calculator program). This kind of thing is a problem. I can solve it for myself by configuring my newsreader to stop showing me your posts. You can solve it for everyone by not making off-topic posts. (The fact that you post obscure things without any explanation is just icing on the unpleasant cake.) Please don't just post whatever you think is interesting. Consider whether it's appropriate. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips void Void(void) { Void(); } /* The recursive call of the void */