comp.lang.ada
 help / color / mirror / Atom feed
* ForTran-Ada + flamette + question
@ 1986-05-21  6:06 larry
  1986-05-21 15:41 ` Mark Biggar
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: larry @ 1986-05-21  6:06 UTC (permalink / raw)


>  I for one am getting a little tired of short, nasty, replies from 
>  "real-annoyed-sender"s who pull the reply trigger before they stop....

Me too.

The biggest difference is that you can use subprogram names as parameters 
to subprograms in ForTran and you can't in Ada.  This is causing me major
problems in porting EMACS (written in C) to Ada.  An important feature of 
EMACS is the ability to do run-time rebinding of functions to key-strokes
and I haven't figured out how to do this in Ada.

In C one can build an array of records, each record containing a pointer 
to a function and the string of characters used to invoke the function.  
When that string is intercepted from the keyboard, the matching function
is invoked.

With this to build on it's fairly easy to create a macro facility, and even 
a subset programming language so that users can extend the editor command 
set.

Anyone have an idea how to do run-time binding of keys to commands in Ada?

                                                    Larry @ jpl-vlsi.arpa

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

* Re: ForTran-Ada + flamette + question
  1986-05-21  6:06 ForTran-Ada + flamette + question larry
@ 1986-05-21 15:41 ` Mark Biggar
  1986-05-21 16:40 ` broman
  1986-05-28 19:30 ` ForTran-Ada + flamette + question David Lamb
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Biggar @ 1986-05-21 15:41 UTC (permalink / raw)


In article <8605210805.AA20308@ucbvax.Berkeley.EDU> larry@JPL-VLSI.ARPA writes:
>Anyone have an idea how to do run-time binding of keys to commands in Ada?

This problem has a simple solution.

There are two types of function in something like EMACS that you want to
be able to bind to a key (or key sequence):  built-in functions and
user-defined functions (usually written in a lisp like language).

Now if you assign to each function an id code (e.g. negative numbers for
built-in functions and positive numbers for user-defined) then bind the
key sequence to the id code.

To interpret the key sequence just look at the id code, if it denotes a
built-in you select the code for the built-in using a humongous case
statement; otherwise pass the id code for the user-defined function
off to the interpreter.  Note that the same id codes for the built-in
functions can be used in the data structures that are used to build
the user-defined functions (you have the same problem with binding built-in
functions into the user-defined functions as you do with binding them to
key sequences).

Mark Biggar
{allegra,burdvax,cbosgd,hplabs,ihnp4,akgua,sdcsvax}!sdcrdcf!markb

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

* Re: ForTran-Ada + flamette + question
  1986-05-21  6:06 ForTran-Ada + flamette + question larry
  1986-05-21 15:41 ` Mark Biggar
@ 1986-05-21 16:40 ` broman
  1986-05-27 13:07   ` ForTran-Ada ... (really procedure variables) Vic Churchill
  1986-05-28 19:30 ` ForTran-Ada + flamette + question David Lamb
  2 siblings, 1 reply; 5+ messages in thread
From: broman @ 1986-05-21 16:40 UTC (permalink / raw)


In article <8605210805.AA20308@ucbvax.Berkeley.EDU>, larry@JPL-VLSI.ARPA writes:
> The biggest difference is that you can use subprogram names as parameters 
> to subprograms in ForTran and you can't in Ada.  This is causing me major
> problems in porting EMACS (written in C) to Ada.
> Anyone have an idea how to do run-time binding of keys to commands in Ada?

Unfortunately, Ada seems to be designed to make that as hard as possible.
The Steelman requirement 5D says: "Procedures, functions, types, labels,
exception situations, and statements shall not be assignable to variables,
be computable as values of expressions, or be usable as nongeneric parameters
to procedures or functions."  This is a major lossage, in my view, compared
to the reasonable design in (e.g.) Modula-2 for defining procedure pointers.

The only way I can see to simulate procedure pointers is to define an
enumeration type with elements corresponding to the procedures that may be
pointed to (as well as NULL) and write a procedure with a big CASE
statement which dispatches to the procedure corresponding to the
enumeration-value you supply as a parameter (or complains about calling NULL).

Yeah, I know, yuk.


Vincent Broman, code 632,  Naval Ocean Systems Center, San Diego, CA 92152, USA
Phone: +1 619 225 2365        {seismo,caip,ihnp4,ucbvax}!\\\\\\\
Arpa: broman@bugs.nosc.mil Uucp: {floyd,moss,bang,hp-sdd,sdcsvax}!noscvax!broman

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

* Re: ForTran-Ada ... (really procedure variables)
  1986-05-21 16:40 ` broman
@ 1986-05-27 13:07   ` Vic Churchill
  0 siblings, 0 replies; 5+ messages in thread
From: Vic Churchill @ 1986-05-27 13:07 UTC (permalink / raw)


The question seems to be how to persuade Ada to run a
function when you ask for it ... try looking at

1. Ada Letters III-4 (Jan/Feb 84), pp. 51-61 "A command interpreter for
Ada": TJ Wheeler
2. IEEE Trans S/W Eng SE-9,1 (Jan 83) pp. 13-15 "Simulation
of Procedure Variables using Ada tasks": D Lamb & P Hilfinger.

Best Regards,
  Vic Churchill (jvc@stl  ...!mcvax!ukc!stl!jvc  +44-279-29531 x 2546)

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

* Re: ForTran-Ada + flamette + question
  1986-05-21  6:06 ForTran-Ada + flamette + question larry
  1986-05-21 15:41 ` Mark Biggar
  1986-05-21 16:40 ` broman
@ 1986-05-28 19:30 ` David Lamb
  2 siblings, 0 replies; 5+ messages in thread
From: David Lamb @ 1986-05-28 19:30 UTC (permalink / raw)


Someone recently asked if there was any way to pass procedures as
parameters in Ada, or place them in records;  I think the problem in
question was doing key-to-procedure bindings in an editor.  Ada has
neither of these directly;  you can sometimes simulate them in ugly
ways.  You can simulate procedure parameters via generics: pass the
procedures or functions as generic parameters, and hope your compiler
is smart enough to pass them as procedures at runtime.  You can get
procedure variables (or record fields) with the tasking mechanism
(yech!) as shown in "Simulating Procedure Variables with Ada Tasks",
D.A. Lamb and P. Hilfinger, IEEE Trans. Soft. Eng.  v9#1 (Jan 83).

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

end of thread, other threads:[~1986-05-28 19:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1986-05-21  6:06 ForTran-Ada + flamette + question larry
1986-05-21 15:41 ` Mark Biggar
1986-05-21 16:40 ` broman
1986-05-27 13:07   ` ForTran-Ada ... (really procedure variables) Vic Churchill
1986-05-28 19:30 ` ForTran-Ada + flamette + question David Lamb

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