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-Thread: 103376,24d7acf9b853aac8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: S-expression I/O in Ada Date: Sun, 08 Aug 2010 16:03:22 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <547afa6b-731e-475f-a7f2-eaefefb25861@k8g2000prh.googlegroups.com> <1qk2k63kzh7yv$.3jgc403xcqdw$.dlg@40tude.net> <8ae8e899-9eef-4c8c-982e-bfdfc10072f1@h17g2000pri.googlegroups.com> <258zlxrv4fn6.1vszho1rtmf48$.dlg@40tude.net> <984db477-973c-4a66-9bf6-e5348c9b95f2@n19g2000prf.googlegroups.com> <46866b8yq8nn$.151lqiwa0y2k6.dlg@40tude.net> <13b07f2c-2f35-43e0-83c5-1b572c65d323@y11g2000yqm.googlegroups.com> <13tpf7ya3evig$.h05p3x08059s$.dlg@40tude.net> <1omt2srxtpsga$.c3hbxthzo6cf.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1281297790 20753 192.74.137.71 (8 Aug 2010 20:03:10 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 8 Aug 2010 20:03:10 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:vBLz4kWTOp54Na7IL/Wf4B9I+dE= Xref: g2news1.google.com comp.lang.ada:12965 Date: 2010-08-08T16:03:22-04:00 List-Id: "Dmitry A. Kazakov" writes: > On Sun, 08 Aug 2010 11:34:23 -0400, Robert A Duff wrote: > >> Modular types are evil, and should usually be avoided. > > They aren't, modular arithmetic is. Hmm. Implicit modular arithmetic is evil. I have no problem with expressions like "X mod N". >...I wished to be able to define a modular > types without +,-,*,/, and, or, xor, and have a more decent notation for > S'Succ and S'Pred. > >> The index type of an unconstrained array should (almost) never >> be modular. > > That is again not their fault. If a subtype of a modular type were modular, > e,g, > > type T is mod 256; > subtype S is T range 2..10; > > X : S := 10; > begin > X := X + 1; -- The result is 2! 2 factorial? ;-) For scalars, the primitive operations mostly don't know the subtype bounds -- they are operations of the type. So this wouldn't fit into Ada well. > ...then they could be used as indices. The problem I was alluding to is that if you have an unconstrained array type, sooner or later you might have an empty one. So you want bounds 0..-1, but -1 wraps around. Same thing with a "for" loop that goes from T'First up to something. If 2..10 wrapped around, then you'd want range 2..1, which has the same problem. Did I mention that modular types are my least favorite feature of Ada? ;-) - Bob