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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news3.google.com!feeder.news-service.com!novso.com!nerim.net!usenet-fr.net!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: S-expression I/O in Ada Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH 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> Date: Thu, 12 Aug 2010 08:20:55 +0200 Message-ID: <1spow9sibnv6l.ci558lff75c8$.dlg@40tude.net> NNTP-Posting-Date: 12 Aug 2010 08:20:54 CEST NNTP-Posting-Host: cec0df55.newsspool3.arcor-online.net X-Trace: DXC=XZ@m[S1NS@[cHPTNZh_e7QMcF=Q^Z^V3X4Fo<]lROoRQ8kF On Wed, 11 Aug 2010 18:18:48 -0500, Randy Brukardt wrote: > "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). What is the difference between "**" and "+"? It must be a language one, because semantically sum of octets is not an octet. > 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. Huh, and these must be a type conversions too: function S'Exponent (X : T) return universal_integer; S'Length A'Length (N) ... >>> 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. The above looks like math to me. You take octet arguments and compute some results using arithmetic operations. >> 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). I see. No, that is a wrong way IMO. The right one is interfaces. If you want S be like T, derive S from T. If you don't like the implementation of T, inherit only the interface of. You should never have a need in explicit type conversions in a properly designed program. > 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. I would prefer to eliminate them altogether. Conversions are always bad. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de