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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d1df6bc3799debed X-Google-Attributes: gid103376,public From: davidk@OS7.ifs (David Kristola) Subject: Re: Syntax for tagged record types (was Re Date: 1997/05/28 Message-ID: <5mg7d7$6t5@butch.lmms.lmco.com>#1/1 X-Deja-AN: 244405153 Distribution: world References: Organization: Sun Microsystems, Inc. Reply-To: davidk@OS7.ifs Newsgroups: comp.lang.ada Date: 1997-05-28T00:00:00+00:00 List-Id: In article ya023680002305971754170001@news.ni.net, mheaney@ni.net (Matthew Heaney) writes: >In article , jsa@alexandria (Jon S Anthony) wrote: > > >>> Here is what I'd like to do: >>> >>> declare >>> The_File : File_Type'Open (Name => "my_file.dat", Mode => In_Mode); >>> begin >>> >>> Renaming a function return as a constant object won't fly, because I have >>> to modify the object. [snip] >What I am proposing is a new syntax, by adding a constructor abstraction; >File_Type'Open in this example. (Today, in Ada 95, Text_IO.Open is an >ordinary procedure.) It would look something like: > > constructor Open (Name : String; Mode : File_Mode) return File_Type; > >or maybe > > constructor File_Type'Open (Name : String; Mode : File_Mode); [snip] Or how about a change to the rules that allow a constructor function (using normal function notation) when a limited object is created: declare -- Fine since this is creation The_File : File_Type := Text_IO.Open (Name => "my_file.dat", Mode => In_Mode); begin -- Illegal since The_File already exists. The_File := Text_IO.Open (Name => "my_other_file.dat", Mode => In_Mode); where in Text_IO, there is a function named Open that returns the limited type Text_IO.File_Type. The only time an object of a limited type could be set by a function is on creation. I would also be allowed to provide my own function, say one that checked a flag and returned Text_IO.Standard_Input or Text_IO.Open(...). Hmm, might this cause problems? Maybe mark the allowable functions with the word "limited" as in: limited function Open(...) return File_Type; Then, limited functions would only be allowed in the package that defines the limited type. If the implementation allowed The_File to contain whatever is returned by Standard_Input, then Standard_Input could also be marked as limited. I would hesitate to add a new key word to Ada, especially if existing key words could be used. But then, this is all just fancy. :-) --david kristola (not speaking for Lockheed Martin or SAMCO) (My news reader does not understand the firewall, oh well, automatic spam shield) Home: David95037 at aol dot com Work: davidk at os6 dot epc dot lmms dot lmco dot com Spam: eat-spam-and-die@dev.null