comp.lang.ada
 help / color / mirror / Atom feed
* Using 'Base
@ 2012-07-21 16:26 Simon Wright
  2012-07-26 17:21 ` Simon Wright
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Wright @ 2012-07-21 16:26 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-01  2:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-21 16:26 Using 'Base Simon Wright
2012-07-26 17:21 ` Simon Wright

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