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: a07f3367d7,d5b211b0c1ffcf3e X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.204.149.210 with SMTP id u18mr453884bkv.1.1339700387763; Thu, 14 Jun 2012 11:59:47 -0700 (PDT) Path: e27ni48318bkw.0!nntp.google.com!news1.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Practicalities of Ada for app development Date: Tue, 12 Jun 2012 09:55:36 +0200 Organization: cbb software GmbH Message-ID: References: <1c82b5mc3waww.1t6q6vj61u36u.dlg@40tude.net> <42a87cf3ce9bfd6054f78b2b5b356301@dizum.com> <4fd60053$0$9510$9b4e6d93@newsspool1.arcor-online.net> <4fd62785$0$9518$9b4e6d93@newsspool1.arcor-online.net> <1crzx65j543zy.1ptlx1vf7esmq.dlg@40tude.net> <4fd65a15$0$9507$9b4e6d93@newsspool1.arcor-online.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-06-12T09:55:36+02:00 List-Id: On Mon, 11 Jun 2012 22:50:33 +0200, Georg Bauhaus wrote: > Reason: numeric literals typically mean a number of some "arithmetic" > type. No, a numeric literal means what it tells "a number." > U+number is similar to the explicit checking of units (and possibly > values) in > > Some_Time_Object := 45 * Seconds; > > presented in Barnes's book. Technically Barnes is not quite right. A correct expression should be: Some_Duration_Object := 45.0 * s; 1. 45.0 is floating-point; 2. You cannot multiply time, you do durations (time intervals); 3. "s" or "second" is the proper name of the unit. http://www.dmitry-kazakov.de/ada/units.htm > When using U+number, the checks are performed by one subprogram ("+"). Code points are numbers, not dimensioned numbers. Dimensioned numbers form a structure different from one of the code points. You are confusing type and dimension. Dimension is one characteristic of some types, e.g. a constraint, but not every type is dimensioned. > A different design might (but need not) require checking in many places. > U+number feels a bit like using a "constructor" for literals. Literal per definition cannot be a constructor. Its name reveals that: literal is denotes a value, e.g. a number, "literally." Furthermore, literal is a syntactic notion (expression term), while constructors are related to the program semantics (create objects from raw memory). Anyway, the point stands: in a properly typed languages you need no special forms of literals. I guess that U+n stems from C-ish nL, nU etc. These are syntactic inventions necessary in C because the language is incapable to resolve ambiguity using the result type. C is bottom up. Ada is not bottom up. You can overload numeric literals in almost any context in Ada. So you don't need silly tricks like U+n. >> BTW, as practice shows, code points are used rarely and almost always as an >> argument for conversion to a UTF-8 string. > > OK. I imagine, though, that most US programming styles will suggest not to > write non-7-bit source text. When I need a UTF-8 encoded literal PI, wouldn't > I then need to write something like the following? > > PI : constant UTF_8_String := > Character'Val (16#CF#) > & Character'Val (16#80#) > & Character'Val (16#0A#); No. The proper way to do this is: UTF8_Pi : constant String := Image (16#0C30#); http://www.dmitry-kazakov.de/ada/strings_edit.htm#Strings_Edit.UTF8 -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de