comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Using 'Base
Date: Sat, 21 Jul 2012 17:26:48 +0100
Date: 2012-07-21T17:26:48+01:00	[thread overview]
Message-ID: <m2ipdhrsfr.fsf@nidhoggr.home> (raw)

I've been working on a binding to msgpack[1]; progress so far at [2],
for booleans, integer, and modular types.

Looking at the read-integer spec, I have

   with Ada.Streams;
   generic
      type Integer_Type is range <>;
   function Message_Pack.Integer_Reader
     (From : not null access Ada.Streams.Root_Stream_Type'Class)
     return Integer_Type'Base;

and I _think_ that the point of returning the 'Base of the formal type
is that any Constraint_Errors will happen in user code during assignment
of the function result. The idea was copied from the Generic Elementary
Functions, but I may well have got the reason wrong. And, also, I may
still raise CE internally if the value received from the wire won't fit
in Integer_Type'Base.

Is there any point in a similar declaration for write-integer? At
present I have

    with Ada.Streams;
    generic
       type Integer_Type is range <>;
    procedure Message_Pack.Integer_Writer
      (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
       Item : Integer_Type'Base);

(again, cf Generic Elementary Functions).

[1] http://msgpack.org/
[2] git://git.code.sf.net/u/simonjwright/msgpack-ada/code



             reply	other threads:[~2012-07-26 16:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-21 16:26 Simon Wright [this message]
2012-07-26 17:21 ` Using 'Base Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox