comp.lang.ada
 help / color / mirror / Atom feed
* Charles: missing default values
@ 2002-11-14  4:15 Victor Porton
  2002-11-14  4:32 ` Hyman Rosen
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Victor Porton @ 2002-11-14  4:15 UTC (permalink / raw)


It is reasonable to add default values to the arguments of
many functions in charles, e.g. Genereic_Find for vectors would
become:

generic
  with function Predicate (Element : Element_Type)
    return Boolean is <>;
function Generic_Find 
     (Container : Container_Type;
      First     : Index_Type'Base := First(C);
      Back      : Index_Type'Base := Last (C)) return Index_Type'Base;



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

* Re: Charles: missing default values
  2002-11-14  4:15 Charles: missing default values Victor Porton
@ 2002-11-14  4:32 ` Hyman Rosen
  2002-11-14 12:48   ` Marin David Condic
  2002-11-14 16:23   ` Matthew Heaney
  2002-11-14  7:18 ` Victor Porton
  2002-11-14 16:16 ` Matthew Heaney
  2 siblings, 2 replies; 7+ messages in thread
From: Hyman Rosen @ 2002-11-14  4:32 UTC (permalink / raw)


Victor Porton wrote:
> Genereic_Find for vectors

If Charles is meant to be an emulation of C++ STL, there is no
such thing as Generic_Find for vectors. Algorithms operate on
iterators, not containers.




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

* Re: Charles: missing default values
  2002-11-14  4:15 Charles: missing default values Victor Porton
  2002-11-14  4:32 ` Hyman Rosen
@ 2002-11-14  7:18 ` Victor Porton
  2002-11-14 16:16 ` Matthew Heaney
  2 siblings, 0 replies; 7+ messages in thread
From: Victor Porton @ 2002-11-14  7:18 UTC (permalink / raw)


In article <9HFA9.19067$6Z.12706@nwrddc01.gnilink.net>,
	Hyman Rosen <hyrosen@mail.com> writes:
> Victor Porton wrote:
>> Genereic_Find for vectors
> 
> If Charles is meant to be an emulation of C++ STL, there is no
> such thing as Generic_Find for vectors. Algorithms operate on
> iterators, not containers.

I meant Charles.Vectors.Unbounded.Generic_Find !



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

* Re: Charles: missing default values
  2002-11-14  4:32 ` Hyman Rosen
@ 2002-11-14 12:48   ` Marin David Condic
  2002-11-14 15:56     ` Hyman Rosen
  2002-11-14 16:23   ` Matthew Heaney
  1 sibling, 1 reply; 7+ messages in thread
From: Marin David Condic @ 2002-11-14 12:48 UTC (permalink / raw)


If Charles is meant to emulate the STL, then it is just a "Me Too" effort.
Its a good thing if it maybe starts from the STL, but then expands on that
theme. Especially if it can exploit features of Ada that give it additional
capability.

MDC
--
======================================================================
Marin David Condic
I work for: http://www.belcan.com/
My project is: http://www.jast.mil/

Send Replies To: m c o n d i c @ a c m . o r g

    "I'd trade it all for just a little more"
        --  Charles Montgomery Burns, [4F10]
======================================================================

Hyman Rosen <hyrosen@mail.com> wrote in message
news:9HFA9.19067$6Z.12706@nwrddc01.gnilink.net...
> Victor Porton wrote:
> > Genereic_Find for vectors
>
> If Charles is meant to be an emulation of C++ STL, there is no
> such thing as Generic_Find for vectors. Algorithms operate on
> iterators, not containers.
>





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

* Re: Charles: missing default values
  2002-11-14 12:48   ` Marin David Condic
@ 2002-11-14 15:56     ` Hyman Rosen
  0 siblings, 0 replies; 7+ messages in thread
From: Hyman Rosen @ 2002-11-14 15:56 UTC (permalink / raw)


Marin David Condic wrote:
> If Charles is meant to emulate the STL, then it is just a "Me Too" effort.

Well, take it up with the author, then. I'm not commenting on whether
Charels is good, bad, or indifferent. I do know that the author has
claimed that its design is based on the C++ STL, so I'm explaining
what that means to people who might not be familiar with it.

In the STL, algorithms are applied to iterator ranges, not to
containers. Trust me, the number of C++ programmers who whine
about this probably exceeds the total number of Ada programmers.




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

* Re: Charles: missing default values
  2002-11-14  4:15 Charles: missing default values Victor Porton
  2002-11-14  4:32 ` Hyman Rosen
  2002-11-14  7:18 ` Victor Porton
@ 2002-11-14 16:16 ` Matthew Heaney
  2 siblings, 0 replies; 7+ messages in thread
From: Matthew Heaney @ 2002-11-14 16:16 UTC (permalink / raw)


porton@ex-code.com (Victor Porton) wrote in message news:<3dd32396$0$308$bed64819@news.gradwell.net>...
> It is reasonable to add default values to the arguments of
> many functions in charles, e.g. Genereic_Find for vectors would
> become:
> 
> generic
>   with function Predicate (Element : Element_Type)
>     return Boolean is <>;
> function Generic_Find 
>      (Container : Container_Type;
>       First     : Index_Type'Base := First(C);
>       Back      : Index_Type'Base := Last (C)) return Index_Type'Base;

This won't compile.  Where is C defined?  

This isn't even correct, because the default value for Back is Last
(C), which is incorrect.

Note that there is a non-generic version of Find, that works by
comparing elements using the equality operator for Element_Type.

If you want an instantiation of Find that accepts only the container
as a parameter, then why don't you simply use a nesting subprogram:

function Find (V : Vector_Subtype) return Index_Subtype'Base is
   procedure Find is new Generic_Find (Predicate);
begin
   return Find (V, First (V), Back (V));
end;

Note also that this is a linear search.  If your vector is sorted,
then you should be using Binary_Search or Lower_Bound.



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

* Re: Charles: missing default values
  2002-11-14  4:32 ` Hyman Rosen
  2002-11-14 12:48   ` Marin David Condic
@ 2002-11-14 16:23   ` Matthew Heaney
  1 sibling, 0 replies; 7+ messages in thread
From: Matthew Heaney @ 2002-11-14 16:23 UTC (permalink / raw)


Hyman Rosen <hyrosen@mail.com> wrote in message news:<9HFA9.19067$6Z.12706@nwrddc01.gnilink.net>...
> Victor Porton wrote:
> > Genereic_Find for vectors
> 
> If Charles is meant to be an emulation of C++ STL, there is no
> such thing as Generic_Find for vectors. Algorithms operate on
> iterators, not containers.

Charles is meant to be an Ada library, optimized for flexibility and
efficiency.  The C++ STL is interesting to me only to the extent that
it contributes towards that goal.

Yes, in the STL, find_if is a generic algorithm, not a vector member
function.  However, searching for items in a container is
"sufficiently primitive" such that it deserved to be an operation for
all containers (not just sorted associative containers, as in the
STL).

Also, the vector container doesn't have an iterator, for reasons
explicated in another email message.



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

end of thread, other threads:[~2002-11-14 16:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-14  4:15 Charles: missing default values Victor Porton
2002-11-14  4:32 ` Hyman Rosen
2002-11-14 12:48   ` Marin David Condic
2002-11-14 15:56     ` Hyman Rosen
2002-11-14 16:23   ` Matthew Heaney
2002-11-14  7:18 ` Victor Porton
2002-11-14 16:16 ` Matthew Heaney

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