* Alright, now for an Ada '95 question.
@ 1996-08-15 0:00 Tom Di Sessa
1996-08-15 0:00 ` Mike Bishop
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Tom Di Sessa @ 1996-08-15 0:00 UTC (permalink / raw)
First of all, I want to thank the people who responded to my first(and
rather unpolite) post. Thank you.
In Java, I am able to do this comparison:
(target is of Class(Type) Component, and Class Button is is derived from
Component)
if (target instanceof Button) {...}
Now, is there a way to do this comparison in Ada '95, if target was of
type Component'Class and Button was a derived type from Component?
-tom :)
--
+------------------------------------------------------------------+
| Thomas G. Di Sessa || |
| WPL Laboratories, Inc. || Email: tdisessa@wpllabs.com |
| Whitehall Offices, Suite 6 || Voice: 610.658.2362 ext. 227 |
| 410 Lancaster Avenue || Fax: 610.658.2361 |
| Haverford, PA 19041 || |
+------------------------------------------------------------------+
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Alright, now for an Ada '95 question.
1996-08-15 0:00 Alright, now for an Ada '95 question Tom Di Sessa
1996-08-15 0:00 ` Mike Bishop
@ 1996-08-15 0:00 ` William W Pritchett
1996-08-16 0:00 ` Jon S Anthony
1996-08-16 0:00 ` Tucker Taft
3 siblings, 0 replies; 7+ messages in thread
From: William W Pritchett @ 1996-08-15 0:00 UTC (permalink / raw)
Try something like the following code
if target in Button'class then
...
But if you're doing Event handling in AppletMagic there is an easier way
to check for a particular widget
if The_Event.Target = Object_Ptr(My_Widget) then
...
where My_Widget is a Button_Ptr, MenuItem_Ptr, etc and The_Event is of type
Event.Event_Ptr
Hope this helps,
Bill Pritchett
DCS Corporation
Tom Di Sessa (tdisessa@wpllabs.com) wrote:
: First of all, I want to thank the people who responded to my first(and
: rather unpolite) post. Thank you.
: In Java, I am able to do this comparison:
: (target is of Class(Type) Component, and Class Button is is derived from
: Component)
: if (target instanceof Button) {...}
: Now, is there a way to do this comparison in Ada '95, if target was of
: type Component'Class and Button was a derived type from Component?
: -tom :)
: --
: +------------------------------------------------------------------+
: | Thomas G. Di Sessa || |
: | WPL Laboratories, Inc. || Email: tdisessa@wpllabs.com |
: | Whitehall Offices, Suite 6 || Voice: 610.658.2362 ext. 227 |
: | 410 Lancaster Avenue || Fax: 610.658.2361 |
: | Haverford, PA 19041 || |
: +------------------------------------------------------------------+
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Alright, now for an Ada '95 question.
1996-08-15 0:00 Alright, now for an Ada '95 question Tom Di Sessa
@ 1996-08-15 0:00 ` Mike Bishop
1996-08-16 0:00 ` Mark A Biggar
1996-08-16 0:00 ` Jon S Anthony
1996-08-15 0:00 ` William W Pritchett
` (2 subsequent siblings)
3 siblings, 2 replies; 7+ messages in thread
From: Mike Bishop @ 1996-08-15 0:00 UTC (permalink / raw)
Tom Di Sessa wrote:
>
> First of all, I want to thank the people who responded to my first(and
> rather unpolite) post. Thank you.
>
> In Java, I am able to do this comparison:
> (target is of Class(Type) Component, and Class Button is is derived from
> Component)
>
> if (target instanceof Button) {...}
>
> Now, is there a way to do this comparison in Ada '95, if target was of
> type Component'Class and Button was a derived type from Component?
The following comparisons can be done in Ada 95:
if target in Button then ...
if target in Component'class then ...
I don't know of a way to compare the types Button and Component in order
to determine if Button is derived from Component. That doesn't mean that
there is no way to do it, only that I don't know how to do it.
--
Mike Bishop
mbishop@ghgcorp.com
http://www.ghgcorp.com/mbishop/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Alright, now for an Ada '95 question.
1996-08-15 0:00 Alright, now for an Ada '95 question Tom Di Sessa
1996-08-15 0:00 ` Mike Bishop
1996-08-15 0:00 ` William W Pritchett
@ 1996-08-16 0:00 ` Jon S Anthony
1996-08-16 0:00 ` Tucker Taft
3 siblings, 0 replies; 7+ messages in thread
From: Jon S Anthony @ 1996-08-16 0:00 UTC (permalink / raw)
In article <32134421.31CF@wpllabs.com> Tom Di Sessa <tdisessa@wpllabs.com> writes:
> In Java, I am able to do this comparison:
> (target is of Class(Type) Component, and Class Button is is derived from
> Component)
>
> if (target instanceof Button) {...}
>
> Now, is there a way to do this comparison in Ada '95, if target was of
> type Component'Class and Button was a derived type from Component?
if Target in Button then...end if;
if you wanted to know if Target is "classified" as a button (a direct
instance of _some_ type derived directly or indirectly from Button
or Button itself) you write
if Target in Button'Class then ... end if;
/Jon
--
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178
617.484.3383
jsa@organon.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Alright, now for an Ada '95 question.
1996-08-15 0:00 ` Mike Bishop
@ 1996-08-16 0:00 ` Mark A Biggar
1996-08-16 0:00 ` Jon S Anthony
1 sibling, 0 replies; 7+ messages in thread
From: Mark A Biggar @ 1996-08-16 0:00 UTC (permalink / raw)
In article <3213D46A.2404@ghgcorp.com> Mike Bishop <mbishop@ghgcorp.com> writes:
>Tom Di Sessa wrote:
>> First of all, I want to thank the people who responded to my first(and
>> rather unpolite) post. Thank you.
>> In Java, I am able to do this comparison:
>> (target is of Class(Type) Component, and Class Button is is derived from
>> Component)
>> if (target instanceof Button) {...}
>> Now, is there a way to do this comparison in Ada '95, if target was of
>> type Component'Class and Button was a derived type from Component?
>The following comparisons can be done in Ada 95:
>if target in Button then ...
>if target in Component'class then ...
>I don't know of a way to compare the types Button and Component in order
>to determine if Button is derived from Component. That doesn't mean that
>there is no way to do it, only that I don't know how to do it.
The only way I can think of is to create a dummy object and use that:
declare
target: Button;
begin
if target in Component'Class then
-- Button is derived from or subtype of Component
end if;
end;
--
Mark Biggar
mab@wdl.lmco.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Alright, now for an Ada '95 question.
1996-08-15 0:00 Alright, now for an Ada '95 question Tom Di Sessa
` (2 preceding siblings ...)
1996-08-16 0:00 ` Jon S Anthony
@ 1996-08-16 0:00 ` Tucker Taft
3 siblings, 0 replies; 7+ messages in thread
From: Tucker Taft @ 1996-08-16 0:00 UTC (permalink / raw)
Tom Di Sessa (tdisessa@wpllabs.com) wrote:
: First of all, I want to thank the people who responded to my first(and
: rather unpolite) post. Thank you.
: In Java, I am able to do this comparison:
: (target is of Class(Type) Component, and Class Button is is derived from
: Component)
: if (target instanceof Button) {...}
: Now, is there a way to do this comparison in Ada '95, if target was of
: type Component'Class and Button was a derived type from Component?
if target in Button'Class then
...
end if;
The above checks whether the tag of Target identifies the type
Button or anything derived from it.
If we want to know whether the tag identifies Button itself, then:
if target in Button then
...
end if;
will perform that test.
: -tom :)
-Tuck ;-) ;-)
: | Thomas G. Di Sessa || |
: | WPL Laboratories, Inc. || Email: tdisessa@wpllabs.com |
: | Whitehall Offices, Suite 6 || Voice: 610.658.2362 ext. 227 |
: | 410 Lancaster Avenue || Fax: 610.658.2361 |
: | Haverford, PA 19041 || |
-Tucker Taft stt@inmet.com http://www.inmet.com/~stt/
Intermetrics, Inc. Cambridge, MA USA
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Alright, now for an Ada '95 question.
1996-08-15 0:00 ` Mike Bishop
1996-08-16 0:00 ` Mark A Biggar
@ 1996-08-16 0:00 ` Jon S Anthony
1 sibling, 0 replies; 7+ messages in thread
From: Jon S Anthony @ 1996-08-16 0:00 UTC (permalink / raw)
In article <3213D46A.2404@ghgcorp.com> Mike Bishop <mbishop@ghgcorp.com> writes:
> I don't know of a way to compare the types Button and Component in
> order to determine if Button is derived from Component. That doesn't
> mean that there is no way to do it, only that I don't know how to do
> it.
I don't think you can do this directly as 4.4(8) rules out first named
subtype names as being names used in memebership tests and I don't see
any such tests specific to types.
The obvious hack would be:
declare
x : Button;
begin
if Button'Class(x) in Component'Class then ... end if;
end;
/Jon
--
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178
617.484.3383
jsa@organon.com
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~1996-08-16 0:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-15 0:00 Alright, now for an Ada '95 question Tom Di Sessa
1996-08-15 0:00 ` Mike Bishop
1996-08-16 0:00 ` Mark A Biggar
1996-08-16 0:00 ` Jon S Anthony
1996-08-15 0:00 ` William W Pritchett
1996-08-16 0:00 ` Jon S Anthony
1996-08-16 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