From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1901f265c928a511 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!news.glorb.com!wn14feed!worldnet.att.net!attbi_s01.POSTED!53ab2750!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: new revision ada References: X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 24.6.132.82 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s01 1087942002 24.6.132.82 (Tue, 22 Jun 2004 22:06:42 GMT) NNTP-Posting-Date: Tue, 22 Jun 2004 22:06:42 GMT Organization: Comcast Online Date: Tue, 22 Jun 2004 22:06:42 GMT Xref: g2news1.google.com comp.lang.ada:1795 Date: 2004-06-22T22:06:42+00:00 List-Id: > tmoran> I don't understand why this is considered a problem. Why not make: > tmoran> type data_to_pass is record ... > tmoran> function enstring(x : data_to_pass) return string; > tmoran> function destring(s : string) return data_to_pass; > > That seems like a very ugly hack. Would you prefer something like: package ER is new Exception_With_Record(Record_Type => Data_To_Pass); Problem : exception; ... ER.Raise_Exception(Problem'Identity, Data_To_Pass'(Number=>1, RPM=>4000, Occurred=>After_Switching_Tanks)); ... exception when oops:Problem => declare Failure_Data : constant Data_To_Pass := ER.Exception_Message(oops); ... The hidden string should contain a pointer to the data to pass, so there's no problem about 200 character truncation. It should also contain an authentication watermark so ER.Exception_Message can avoid trying to read data from an Ada.Exceptions.Exception_Message string (in case "raise Problem" was erroneously used instead of ER.Raise_Exception). ER.Exception_Message would also do the deallocation so the only way a memory leak could happen is if you don't properly handle the exception, in which case a memory leak is probably the least of your problems. > Isn't the philosophy behind Ada that you specify what you want to > happen, not how it happens? I don't understand: all code is a statement of "how it happens", more or less hidden inside some convenient syntactic form. Perhaps Ada.Exceptions.Raise_Exception(Problem'Identity, Enstring(Data_To_Pass'(Number=>1, RPM=>4000, Occurred=>After_Switching_Tanks))); is insufficiently opaque. The above ER.Raise_Exception(Problem'Identity, Data_To_Pass'(Number=>1, RPM=>4000, Occurred=>After_Switching_Tanks)); doesn't expose any internals. > Thats also a lot of overhead just to pass variables from one part of > the program to another part of the same program, too. I suspect it compares quite well with a call to Ada.Text_IO.Put_Line. You shouldn't be raising/handling thousands of exceptions/second anyway.