comp.lang.ada
 help / color / mirror / Atom feed
* HELP - MAC compilation of an Ada program
@ 1999-11-04  0:00 William A Whitaker
  1999-11-05  0:00 ` Robert Dewar
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: William A Whitaker @ 1999-11-04  0:00 UTC (permalink / raw)


I have a Latin dictionary program written in Ada for the PC.  It is a
hobby for a long-retired natural philosopher.  The system has been
ported to a number of other (UNIX-like) machines/OS and compiles on a
number of different compilers.  The system is only about 15KLOC.  See:

http://www.erols.com/whitaker/words.htm

This is a DOS-like (command line, not GUI) program for portability
reasons.  I understand that there is a capability to port  such a
program to the MAC, such that it would run in the same manner.

I have no experience with the MAC.  I do not even know what the MAC
means anymore (68040?, Power MAC?, what OS), and if it makes a
difference.  In particular, I do not know if a program in that mode
would be acceptable to MAC users.

I would like to find someone who could advise me on this an/or do the
port.  This is a free distribution program, so I am not offerring a big
contract.  But I really would like to have this done (if
possible/reasonable) without my having to buy a MAC - or touch one in
any manner.

Please contact me directly, and pass on the plea to anyone you know who
might be interested.

Bill Whitaker








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

* Re: HELP - MAC compilation of an Ada program
  1999-11-04  0:00 HELP - MAC compilation of an Ada program William A Whitaker
  1999-11-05  0:00 ` Robert Dewar
@ 1999-11-05  0:00 ` James E. Hopper
  1999-11-12  0:00 ` Generic package array parameter Mario Amado Alves
  2 siblings, 0 replies; 9+ messages in thread
From: James E. Hopper @ 1999-11-05  0:00 UTC (permalink / raw)



I would be glad to work with you on this, as i am sure would a couple
of other mac folks i know.  my email is hopperj@macconnect.com

jim

In article <382255CE.F5CB679A@erols.com>, William A Whitaker
<whitaker@erols.com> wrote:

> I have a Latin dictionary program written in Ada for the PC.  It is a
> hobby for a long-retired natural philosopher.  The system has been
> ported to a number of other (UNIX-like) machines/OS and compiles on a
> number of different compilers.  The system is only about 15KLOC.  See:
> 
> http://www.erols.com/whitaker/words.htm
> 
> This is a DOS-like (command line, not GUI) program for portability
> reasons.  I understand that there is a capability to port  such a
> program to the MAC, such that it would run in the same manner.
> 
> I have no experience with the MAC.  I do not even know what the MAC
> means anymore (68040?, Power MAC?, what OS), and if it makes a
> difference.  In particular, I do not know if a program in that mode
> would be acceptable to MAC users.
> 
> I would like to find someone who could advise me on this an/or do the
> port.  This is a free distribution program, so I am not offerring a big
> contract.  But I really would like to have this done (if
> possible/reasonable) without my having to buy a MAC - or touch one in
> any manner.
> 
> Please contact me directly, and pass on the plea to anyone you know who
> might be interested.
> 
> Bill Whitaker




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

* Re: HELP - MAC compilation of an Ada program
  1999-11-04  0:00 HELP - MAC compilation of an Ada program William A Whitaker
@ 1999-11-05  0:00 ` Robert Dewar
  1999-11-05  0:00 ` James E. Hopper
  1999-11-12  0:00 ` Generic package array parameter Mario Amado Alves
  2 siblings, 0 replies; 9+ messages in thread
From: Robert Dewar @ 1999-11-05  0:00 UTC (permalink / raw)


In article <382255CE.F5CB679A@erols.com>,
  whitaker@erols.com wrote:
> I have a Latin dictionary program written in Ada for the PC.
> It is a hobby for a long-retired natural philosopher.  The
> system has been ported to a number of other (UNIX-like)
> machines/OS and compiles on a number of different compilers.
> The system is only about 15KLOC.

Nice to see you back on CLA Bill (for new comers who don't know,
Bill Whitaker is one of the original guiding lights of the
project that eventually produced the Ada language :-)

There is a port of GNAT to the Mac, but it requires you to
purchase and install the Tenon Code Builder or Machten system
(minimum cost about $100), to provide the necessary environment.
However, you can indeed generate stand alone Mac OS programs
using this package (at least that is my understanding), so if
you can get one of the Mac/GNAT enthiusiasts to help you out
with the port, it should work fine.

Robert Dewar

P.S. It sure is a pity there is no native Mac OS port of Ada 95.
As I have noted in a previous message, the government did
allocate funds for this purpose, but the Mac disappointingly
disappeared from the (Intermetrics) contract post award.


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* Generic package array parameter
  1999-11-04  0:00 HELP - MAC compilation of an Ada program William A Whitaker
  1999-11-05  0:00 ` Robert Dewar
  1999-11-05  0:00 ` James E. Hopper
@ 1999-11-12  0:00 ` Mario Amado Alves
  1999-11-12  0:00   ` Matthew Heaney
  1999-11-12  0:00   ` Tucker Taft
  2 siblings, 2 replies; 9+ messages in thread
From: Mario Amado Alves @ 1999-11-12  0:00 UTC (permalink / raw)
  To: comp.lang.ada@list.deja.com

I am trying to rewrite

generic
  type X is (<>);
  type Y is (<>);
  Table: array(X, Y) of X;
package Foo is
...

in order to circuvent the 'anonymous array definition not allowed here'
constraint. I tried

generic
  type X is (<>);
  type Y is (<>);
  Table: Table_Type;
package Foo is
  type Table_Type is array(X, Y) of X;
...

and of course got '"Table_Type" is undefined'. Then I tried

generic
  type X is (<>);
  type Y is (<>);
  type Table_Type is array(X, Y) of X;
  Table: Table_Type;
package Foo is
...

which of course works, but is odd, and requires an equally odd
instantiation:

type My_X is ...;
type My_Y is ...;
type My_Table_Type is array(My_X, My_Y) of My_X;
My_Table: My_Table_Type := (...);
package My_Foo is new Foo(My_X, My_Y, My_Table_Type, My_Table);
...

This works, but is ugly and stupid. Is there a smart way to rewrite it?

(I feel I am again on the verge of giving up the Ada generic programming
idiom. What is this Ada thing with anonymous array types?)

Thanks.

| | |,| | | | |RuaFrancTaborda24RcD 2815-249CharnecaCaparica 351+212976751
| |M|A|R|I|O| |                                              mob 219354005
| |A|M|A|D|O| |DepartmentoInformaticFCT/UNL 2825-114Caparica 351+212958536
| |A|L|V|E|S| |                                              fax 212948541
| | | | | | | |               maa@di.fct.unl.pt              FCT 212948300




 Sent via Deja.com http://www.deja.com/
 Before you buy.




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

* Re: Generic package array parameter
  1999-11-12  0:00 ` Generic package array parameter Mario Amado Alves
@ 1999-11-12  0:00   ` Matthew Heaney
  1999-11-13  0:00     ` Robert A Duff
  1999-11-12  0:00   ` Tucker Taft
  1 sibling, 1 reply; 9+ messages in thread
From: Matthew Heaney @ 1999-11-12  0:00 UTC (permalink / raw)


In article 
<Pine.LNX.4.10.9911121752180.11396-100000@lexis.di.fct.unl.pt> , Mario
Amado Alves <maa@di.fct.unl.pt>  wrote:

> generic
>   type X is (<>);
>   type Y is (<>);
>   type Table_Type is array(X, Y) of X;
>   Table: Table_Type;
> package Foo is
> ...
>
> which of course works, but is odd, and requires an equally odd
> instantiation:
>
> type My_X is ...;
> type My_Y is ...;
> type My_Table_Type is array(My_X, My_Y) of My_X;
> My_Table: My_Table_Type := (...);
> package My_Foo is new Foo(My_X, My_Y, My_Table_Type, My_Table);
> ...


There is nothing odd about this instantiation.  The only thing odd here
is that you would find it odd!

Your generic formal region has 3 formal types and 1 formal object, and
you supply 3 actual types and 1 actual object.  What else did you expect
you'd have to do?

If you call a subprogram that has 4 formal parameters, then you expect
to call it with 4 actual parameters.  What else is new?


> This works, but is ugly and stupid.

I'm sorry to hear that.


> Is there a smart way to rewrite it?

Do you need to import the type and the object as generic formals?

generic
  type XT is (<>);
  type YT is (<>);
  type ZT is private;
package GP is

  type Array_Type is array (XT, YT) of ZT;

  Table : Array_Type;
...
end GP;


Do you need to import index types?  What's wrong with Positive?

generic
  type ZT is private;
  Max_X : in Positive;
  Max_Y : in Positive;
package GP is

  type Array_Type is array (Positive range <>, Positive range <>) of ZT;

  Table : Array_Type (1 .. Max_X, 1 .. Max_Y);
...
end GP;

If named access types offend you, then just declare your table with an
anonymous type:

generic
  ...
package GP is

  Table : array (1 .. Max_X, 1 .. Max_Y) of ZT;

end GP;


> (I feel I am again on the verge of giving up the Ada generic programming
> idiom. What is this Ada thing with anonymous array types?)

Don't criticize what you don't understand.

(Anonymous array types aren't allowed because, what would "=" mean for
the type?  What would ":=" mean for the type?

  function (L, R : ???) return Boolean;

What's the type of the formal parameters of function "="?

  procedure ":=" (L : in out ???; R : in ???);

What are the types on the LHS and on the RHS?

Operations are always associated with a type.  The type needs a name in
order to associate an operation with the type.  But if the array is
anonymous, then you don't have a name, so you don't have the operation
either...)


--
Science is, foremost, a method of interrogating reality: proposing
hypotheses that seem true and then testing them -- trying, almost
perversely, to negate them, elevating only the handful that survive to
the status of a theory. Creationism is a doctrine, whose adherents are
interested only in seeking out data that support it.

George Johnson, NY Times, 15 Aug 1999




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

* Re: Generic package array parameter
  1999-11-12  0:00 ` Generic package array parameter Mario Amado Alves
  1999-11-12  0:00   ` Matthew Heaney
@ 1999-11-12  0:00   ` Tucker Taft
  1 sibling, 0 replies; 9+ messages in thread
From: Tucker Taft @ 1999-11-12  0:00 UTC (permalink / raw)


Mario Amado Alves wrote:
> 
> I am trying to rewrite
> 
> generic
>   type X is (<>);
>   type Y is (<>);
>   Table: array(X, Y) of X;
> package Foo is
> ...
> 
> in order to circuvent the 'anonymous array definition not allowed here'
> constraint. I tried
> 
> generic
>   type X is (<>);
>   type Y is (<>);
>   Table: Table_Type;
> package Foo is
>   type Table_Type is array(X, Y) of X;
> ...
> 
> and of course got '"Table_Type" is undefined'. Then I tried
> 
> generic
>   type X is (<>);
>   type Y is (<>);
>   type Table_Type is array(X, Y) of X;
>   Table: Table_Type;
> package Foo is
> ...
> 
> which of course works, but is odd, and requires an equally odd
> instantiation:
> 
> type My_X is ...;
> type My_Y is ...;
> type My_Table_Type is array(My_X, My_Y) of My_X;
> My_Table: My_Table_Type := (...);
> package My_Foo is new Foo(My_X, My_Y, My_Table_Type, My_Table);
> ...
> 
> This works, but is ugly and stupid. Is there a smart way to rewrite it?

Probably the simplest solution is to use a nested generic:

    generic
        type X is (<>);
        type Y is (<>);
    package Foo is
        type Table_Type is array(X, Y) of X;
        generic
            Table : Table_Type;
        package Inner is ...

  With this, your instantiation becomes:
    type My_X is ...
    type My_Y is ...
    package My_Foo is new Foo(My_X, My_Y);
    My_Table : My_Foo.Table;
    package My_Inner_Foo is new Foo.Inner(My_Table);

Using a nested generic is not the most obvious solution, but
they do provide a lot of power.  Note that there are other
similar (Ada95-only) solutions that are a bit more extensible, including
using a generic child package rather than a nested package,
or using a second generic that takes an instance of the
first generic as the actual for a formal package parameter.

> (I feel I am again on the verge of giving up the Ada generic programming
> idiom. What is this Ada thing with anonymous array types?)

Anonymous types are generally frowned upon because they
smack of "structural" type equality rather than "named" type
equivalence.  Named type equivalence usually provides stronger type
checking, and hence typically more compile-time detection of errors,
than structural type equivalence.  It is admittedly more
work sometimes when writing code, but Ada is definitely prejudiced
in favor of the reader over the writer.

But in any case, don't give up on Ada generics.  They provide a lot
of capability, especially when you start nesting generics and/or instances
within one another.

> Thanks.
> 
> | | |,| | | | |RuaFrancTaborda24RcD 2815-249CharnecaCaparica 351+212976751
> | |M|A|R|I|O| |                                              mob 219354005
> | |A|M|A|D|O| |DepartmentoInformaticFCT/UNL 2825-114Caparica 351+212958536
> | |A|L|V|E|S| |                                              fax 212948541
> | | | | | | | |               maa@di.fct.unl.pt              FCT 212948300

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




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

* Re: Generic package array parameter
  1999-11-12  0:00   ` Matthew Heaney
@ 1999-11-13  0:00     ` Robert A Duff
  1999-11-23  0:00       ` Mario Amado Alves
  0 siblings, 1 reply; 9+ messages in thread
From: Robert A Duff @ 1999-11-13  0:00 UTC (permalink / raw)


"Matthew Heaney" <matthew_heaney@acm.org> writes:

> Don't criticize what you don't understand.
> 
> (Anonymous array types aren't allowed because, what would "=" mean for
> the type?  What would ":=" mean for the type?
> 
>   function (L, R : ???) return Boolean;
> 
> What's the type of the formal parameters of function "="?

Well, for regular run-of-the-mill anonymous array types,
the answer is that ??? is the anonymous array type.
Eg:

    X: array(Integer range 1..10) of Character := "abcdefghij";
    ...
    if X = "Hello, world" then ...

But I think Tucker's idea (never use anonymous array types)
is better, at least as a rule of thumb.

- Bob




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

* Re: Generic package array parameter
  1999-11-13  0:00     ` Robert A Duff
@ 1999-11-23  0:00       ` Mario Amado Alves
  1999-11-23  0:00         ` Matthew Heaney
  0 siblings, 1 reply; 9+ messages in thread
From: Mario Amado Alves @ 1999-11-23  0:00 UTC (permalink / raw)
  To: comp.lang.ada@list.deja.com

Looking back, I was really looking for a way to make an instatiation with
an array (of type named or not) *know* about its types (of the indexes
and/or of the cells) in a compact way, e.g. (pseudocode):

generic
  Table: array(<>, <>) of <>;
package Foo
  type Index1 is Table'Index'Type(1);
  type Index2 is Table'Index'Type(2);
  type Cell_Type is Table(Index1'First, Index2'First)'Type;
  function Example(I: Index1; J: Index2) return Cell_Type;
end;

But now I've agreed to trade compactness for safety and eficiency; the
thing has now compiled and it's working. Duff, thanks a lot. (Heaney,
perhaps sometime I take the trouble to comment back and show the world I am
not that stupid.;-)

| | |,| | | | |RuaFrancTaborda24RcD 2815-249CharnecaCaparica 351+212976751
| |M|A|R|I|O| |                                              mob 219354005
| |A|M|A|D|O| |DepartmentoInformaticFCT/UNL 2825-114Caparica 351+212958536
| |A|L|V|E|S| |                                              fax 212948541
| | | | | | | |               maa@di.fct.unl.pt              FCT 212948300




 Sent via Deja.com http://www.deja.com/
 Before you buy.




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

* Re: Generic package array parameter
  1999-11-23  0:00       ` Mario Amado Alves
@ 1999-11-23  0:00         ` Matthew Heaney
  0 siblings, 0 replies; 9+ messages in thread
From: Matthew Heaney @ 1999-11-23  0:00 UTC (permalink / raw)


In article <Pine.LNX.4.10.9911231052200.6738-100000@lexis.di.fct.unl.pt> 
, Mario Amado Alves <maa@di.fct.unl.pt>  wrote:

> (Heaney, perhaps sometime I take the trouble to comment back and show the
> world I am not that stupid.;-)

Many things may at first seem "stupid and ugly," but on closer
inspection it turns out that there is usually a good reason for things
being that way.

I myself made a mistake very similar to yours (although it was many
years ago ;^), like this:

  type RT (D : Positive) is
    record
      Items : array (1 .. D) of Item_Type;
    end record;

This of course is not legal Ada, and my initial reaction was probably
very similar to yours wrt the syntax of generic formal array objects.

In the end, the only way to learn a language is by programming in that
language.

--
Science is, foremost, a method of interrogating reality: proposing
hypotheses that seem true and then testing them -- trying, almost
perversely, to negate them, elevating only the handful that survive to
the status of a theory. Creationism is a doctrine, whose adherents are
interested only in seeking out data that support it.

George Johnson, NY Times, 15 Aug 1999




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

end of thread, other threads:[~1999-11-23  0:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-04  0:00 HELP - MAC compilation of an Ada program William A Whitaker
1999-11-05  0:00 ` Robert Dewar
1999-11-05  0:00 ` James E. Hopper
1999-11-12  0:00 ` Generic package array parameter Mario Amado Alves
1999-11-12  0:00   ` Matthew Heaney
1999-11-13  0:00     ` Robert A Duff
1999-11-23  0:00       ` Mario Amado Alves
1999-11-23  0:00         ` Matthew Heaney
1999-11-12  0:00   ` Tucker Taft

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