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!news4.google.com!feeder2.cambriumusenet.nl!feed.tweaknews.nl!138.195.8.3.MISMATCH!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: S-expression I/O in Ada Date: Wed, 11 Aug 2010 18:18:48 -0500 Organization: Jacob Sparre Andersen Message-ID: References: <547afa6b-731e-475f-a7f2-eaefefb25861@k8g2000prh.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> <1e4cch2df5uyb.18brqdd16dhv8.dlg@40tude.net> <14y70ke8am9qw$.2csc9eflvigg.dlg@40tude.net> <1y1c8zzqmcer5.po56hkesa968.dlg@40tude.net> <1o6jah15584x1$.1arrrgog9jdk7.dlg@40tude.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1281568730 22755 69.95.181.76 (11 Aug 2010 23:18:50 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 11 Aug 2010 23:18:50 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5843 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-RFC2646: Format=Flowed; Original Xref: g2news1.google.com comp.lang.ada:13147 Date: 2010-08-11T18:18:48-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:iv3qwjogornz$.1s8kq0yfl2wxl.dlg@40tude.net... ... > Conversion mess is what we already have right now. The point is that "+" > is > well-defined and meaningful for octets, but it is not closed in there. Why > > function "**" (Left : T; Right : Natural) return T; > function S'Pos(Arg : S'Base) return universal_integer; > ... > > are OK and "+" is not? The first has the same operand and result type (the power operand is something else and not really part of the operator IMHO). The second is the long winded name for a conversion operator - it implies no semantic change. I'm arguing that operations like S'Pos would be better having a common name like "#" rather than a host of specialized names. >> Since we're inventing things, I would suggest: >> >> -- Conversion function (Not Ada): >> function "#" (Right : Octet) return Universal_Integer; >> >> Little_Endian_Value := #Octet_1 + #Octet_2 * 256; >> >> And now you don't need any Octet math. > > 1. What is this else? Huh? This doesn't parse. > 2. I see no advantage over > > Little_Endian_Value := Integer (Octet_1) + Integer (Octet_2) * 256; "#" can be overridden and/or user-defined. "Integer" cannot (and could never be in a version of Ada, as any such attempt would be way too incompatible). In addition, "#" is more readable in the 98% of the cases where you don't need to specify a type. I would probably consider using predefined versions of "#" to replace other forms of explicit type conversion as well (so "#" would always work if defined - no decision about whether to call a function, use a built-in type conversion, or use some attribute - and no need to look up the name of the type). >> BTW, the "#" operator was suggested by Jean Ichbiah and others back >> during >> the design of Ada 83, to be used for conversions between types. It's a >> pity >> that it or something like it never made it into Ada. (It comes up each >> time >> and still is rejected.) > > It would be nice to have more operators than now ("^", "|", "..", "in", > ":=", "<>", "()", "[]", "{}", "<=>", "@", "~" and so on. Ah, Ada is > Unicode > now, here is the list: http://www.unicode.org/charts/PDF/U2200.pdf ). > > But what is so special in type conversions, aren't they just functions? That's the point: in Ada, type conversions are *not* functions, they're a built-in gizmo [including some attributed]; by naming them "#" we would allow unifying them with functions. Of course, this could be abused (by having some semantic change encoded in the function as well), but that of course can happen just as well with "+" or "-" or "*". Randy.