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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5ac1c1813029999b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-14 03:22:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fr.usenet-edu.net!usenet-edu.net!enst.fr!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada Subject: Re: A bunch of questions that come after "Hello world" Date: Thu, 14 Nov 2002 05:21:36 -0600 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <5ad0dd8a.0211131244.42603699@posting.google.com> <5ad0dd8a.0211140218.6d48be15@posting.google.com> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1037272923 10812 137.194.161.2 (14 Nov 2002 11:22:03 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Thu, 14 Nov 2002 11:22:03 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:30862 Date: 2002-11-14T05:21:36-06:00 ----- Original Message ----- From: "Wojtek Narczynski" Newsgroups: comp.lang.ada To: Sent: November 14, 2002 4:18 AM Subject: Re: A bunch of questions that come after "Hello world" > Robert A Duff wrote in message news:... > > wojtek@power.com.pl (Wojtek Narczynski) writes: > > > > > 2. Could somebody confirm that I cannot define a procedure / function > > > as a member of a "record", but I sure can as a member of "protected"? > > I Guess the best way to answer your question is to show you the Ada way to do what you want, viz.: -- File: doors.ads package Doors is type Door is private; procedure Open (This : in out Door); procedure Close (This : in out Door); function Is_Open (This : Door) return Boolean; private type Door is record Open : Boolean := False; end record; end Doors; -- File: doors.adb package body Doors is ----------- -- Close -- ----------- procedure Close (This : in out Door) is begin This.Open := False; end Close; ------------- -- Is_Open -- ------------- function Is_Open (This : Door) return Boolean is begin return This.Open; end Is_Open; ---------- -- Open -- ---------- procedure Open (This : in out Door) is begin This.Open := True; end Open; end Doors; -- File: test_doors.adb with Ada.Text_IO; with Doors; procedure Test_Doors is Front_Door : Doors.Door; begin Ada.Text_IO.Put_Line ("Initial state of a Doors.Door object is open? " & Boolean'Image (Doors.Is_Open (Front_Door))); Ada.Text_IO.Put_Line ("Opening Front_Door.."); Doors.Open (Front_Door); Ada.Text_IO.Put_Line ("Front_Door is open? " & Boolean'Image (Doors.Is_Open (Front_Door))); Ada.Text_IO.Put_Line ("Closing Front_Door.."); Doors.Close (Front_Door); Ada.Text_IO.Put_Line ("Front_Door is open? " & Boolean'Image (Doors.Is_Open (Front_Door))); end Test_Doors; > I have two more questions: > 1. Is there something like super in Java? No. > 2. Can I overload () operator? I guess no. There is no "()" operator in Ada. In Ada, when a sub program requires no parameters, you just don't write thge "()."