[fpc-devel] Templates / Generics Syntax
    Vinzent Hoefler 
    JeLlyFish.software at gmx.net
       
    Fri Nov  4 14:48:42 CET 2005
    
    
  
On Friday 04 November 2005 13:27, Marco van de Voort wrote:
["<>"]
> The evil is in
>
> - using characters instead of modifiers.
> - worse, recycling already used characters.
Alright, I completely understand at least the first part, so perhaps 
they should simply not be overused. :-)
Just for the fun and for those who don't know it yet, the previously 
given example in Ada95-syntax:
-- 8< -- snip --
procedure Gen_Test is
   ---------------------------------------------------------------------
   package Show is
      procedure Do_It (i : Integer);
      procedure Do_It (s : String);
   end Show;
   package body Show is
      procedure Do_It (i : Integer) is
      begin
         null;
      end Do_It;
      procedure Do_It (s : String) is
      begin
         null;
      end Do_It;
   end Show;
   ---------------------------------------------------------------------
   ---------------------------------------------------------------------
   generic
      type T (<>) is private;
      procedure Dump (Value : T);
      procedure Dump (Value : T) is
         use Show;
      begin
         Do_It (Value);
      end Dump;
   ---------------------------------------------------------------------
   ---------------------------------------------------------------------
   procedure My_Dump is new Dump (Integer);
   procedure My_Dump is new Dump (String);
   ---------------------------------------------------------------------
begin -- Gen_Test
   My_Dump (42);
   My_Dump ("foobar");
end Gen_Test;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20051104/711431f4/attachment.sig>
    
    
More information about the fpc-devel
mailing list