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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5265ce03ee8f5252 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-04 04:46:05 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!ppp-5-251.5800-6.access.uk.worldonline.COM!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: Ok sorry, it is just a book gives no feedback. Date: Wed, 3 Jan 2001 06:24:10 -0000 Message-ID: <931r2l$4ai5t$2@ID-25716.news.dfncis.de> References: NNTP-Posting-Host: ppp-5-251.5800-6.access.uk.worldonline.com (62.64.157.251) X-Trace: fu-berlin.de 978612118 4540605 62.64.157.251 (16 [25716]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Xref: supernews.google.com comp.lang.ada:3647 Date: 2001-01-03T06:24:10+00:00 List-Id: My own opinion is that, generally, functions should have no side effects (whereas procedures generally do). Ada does not enforce this principle (rightly, since it would be difficult and sometimes wrong to do so), but it does disallow parameters of mode 'out' and 'in out' for functions. What is a 'side effect'? If a subprogram (a function or procedure), when called, changes something outside itself, that is a side effect. The 'thing' outside could be anything: a variable; a display or printer; a hard disk floppy disk; etc. The 'change' is any kind of change whatever: modification of a value; output of a character or string; writing or modifying a file; etc. To be crystal clear, when I say a function 'should have no side effects', I mean it should be written so that it never causes a side effect. Some people do not respect (or even recognise) this principle, although there are good arguments for it. I would suggest you follow the principle unless you have a very good reason not to. Briefly, the main argument for functions not having side effects is that an expression such as A+B, where A and B are both function calls, may be compiled to execute A first and then B, or B first and then A (depending on complex optimisation rules within the compiler). If both A and B could both cause a side effect which interferes with the other, it might then become unpredictable what this expression does or returns: often a particularly pernicious type of bug! Keeping functions free of side effects avoids the possibility of this type of bug. It follows from the above that the kind of side effect in a function which you can get away with most easily is the kind which is carefully designed never to interfere with any other function. Do keep up your hard work with Ada. How did you get on with 'hangman'? My advice with regard to books is: try to have a go with as many as you can, before purchasing if possible. Does your place have a good library? Might your friends lend you theirs for a while? Often you can get nowhere with many books, and then find one which just seems to 'click'. (Clearly, that's the one to buy!) Sometimes one book will explain one thing well, and another book something else. (In which case, a photocopier might be handy.) Happy New Year! -- Nick Roberts http://www.AdaOS.org "Mark Pagdin" wrote in message news:t4ug0qb63j7e4e@corp.supernews.co.uk... > Hi ya, > > I am sorry to keep on asking qns, but my text book doesn't give answers, > i.e. it says things like write a procedure to do ......., but it doesn't > actually give the answer at the back, so that if you are a bit stuck then > everything won't work and you get demoralised. > > I want to become good at programming and I am prepared to work hard, but I > am not brilliant at maths and I don't think thsi helps my plight. > > I am sorry to ask newbie qns here, but I am in a catch 22, or I think I am. > > Anyway, > Have a fun New Years,