comp.lang.ada
 help / color / mirror / Atom feed
From: anon@att.net
Subject: Re: Overloading attributes
Date: Sun, 27 Nov 2011 03:36:59 +0000 (UTC)
Date: 2011-11-27T03:36:59+00:00	[thread overview]
Message-ID: <jasb8q$sgv$1@speranza.aioe.org> (raw)
In-Reply-To: 8ed87fee-166a-4be9-ae6c-4d0fbeb4788c@s6g2000vbc.googlegroups.com

In Ada, Overloading is allow for all attributes include programmers 
created attributes. But Adacore GNAT has decided a number of years 
ago to not allow programmers to create their attributes and has 
limited the overloading of standard attributes. 

While some may see this as cripping Ada others do not. Because 
except for those predefined by the Ada standard library which may 
be hidden, the programmer create attribute routine rather overloading 
or not must be visable to the package it is used in. So, its just as 
reasonable to call the attribute routine as any other routine.



Note: Other Ada compilers may or may not follow Adacore GNAT decision 
on this issue.

In <8ed87fee-166a-4be9-ae6c-4d0fbeb4788c@s6g2000vbc.googlegroups.com>, Matt Borchers <mattborchers@gmail.com> writes:
>Why is it that one cannot overload the 'Image and 'Value attribute
>similar to how we can overload 'Input, 'Output, 'Read, and 'Write?  I
>think it would be nice to be able to do the following:
>
>type FOO is ...;
>
>function Image( f : FOO ) return String;
>for FOO'Image use Image;
>
>function To_Foo( s : String ) return FOO;
>for FOO'Value use To_Foo;
>
>Is there a reason that this is not allowed?  Why limit 'Image and
>'Value to only scalar types.
>Why expose a routine to "stringify" an object through the package
>specification when a language construct already exists that could do
>this?
>
>I can also imagine how overloading 'Pred and 'Succ would be kinda nice
>for link list traversals (and possibly other linked structures):
>
>type A_FOO is access FOO;  --FOO has a field that points to next
>record via pointer
>
>function Succ( f : A_FOO ) return A_FOO;
>for A_FOO'Succ use Succ;
>--similar for 'Pred if it is a doubly linked list
>
>x : A_FOO;
>x := x'Succ;
>
>Why expose a Next routine through the package specification when a
>language construct already exists that can do this?
>
>How about other Attributes like 'Pos, 'Val, 'First, 'Last, etc?  Could
>they be overloaded on user-defined types?




  parent reply	other threads:[~2011-11-27  3:37 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-26 23:13 Overloading attributes Matt Borchers
2011-11-26 23:24 ` Shark8
2011-11-27  7:38   ` Yannick Duchêne (Hibou57)
2011-11-27  3:36 ` anon [this message]
2011-11-27  7:04   ` J-P. Rosen
2011-11-27 20:00     ` anon
2011-11-27 20:34       ` Yannick Duchêne (Hibou57)
2011-11-27 20:50         ` Yannick Duchêne (Hibou57)
2011-11-27 23:10       ` J-P. Rosen
2011-11-28  9:11         ` anon
2011-11-28 10:53           ` Peter C. Chapin
2011-11-29 11:58             ` anon
2011-11-29 12:50               ` Mark Lorenzen
2011-11-30 11:05                 ` anon
2011-11-29 16:16               ` AdaMagica
2011-11-29 17:43                 ` Jeffrey Carter
2011-11-29 23:26                 ` J-P. Rosen
2011-11-30 11:06                   ` anon
2011-11-30 15:52                     ` J-P. Rosen
2011-11-30 17:27                       ` Yannick Duchêne (Hibou57)
2011-11-30 20:45                       ` Pascal Obry
2011-12-01 11:01                       ` Simon Wright
2011-12-02 18:55                       ` anon
2011-12-02 19:34                         ` Ludovic Brenta
2011-12-02 20:02                           ` Yannick Duchêne (Hibou57)
2011-12-03  1:41                           ` Randy Brukardt
2011-11-28 12:06           ` Ludovic Brenta
2011-11-27  5:11 ` Yannick Duchêne (Hibou57)
2011-11-27 12:57 ` Dmitry A. Kazakov
replies disabled

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