* private "subtype"s
@ 2000-10-09 0:00 Georg Bauhaus
2000-10-09 0:00 ` Ted Dennison
0 siblings, 1 reply; 3+ messages in thread
From: Georg Bauhaus @ 2000-10-09 0:00 UTC (permalink / raw)
A similar question has been partially answerd a while
ago by M. Heaney, in the sense that something
like the following code is not possible. But why?
package Whoops is -- illegal!
subtype Constr is private;
-- [[Constr]] is constrained, but the constraints need
-- not be known outside
private
subtype Constr is Natural range 0..99;
end Whoops;
Georg Bauhaus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: private "subtype"s
2000-10-09 0:00 private "subtype"s Georg Bauhaus
@ 2000-10-09 0:00 ` Ted Dennison
2000-10-10 0:00 ` Georg Bauhaus
0 siblings, 1 reply; 3+ messages in thread
From: Ted Dennison @ 2000-10-09 0:00 UTC (permalink / raw)
In article <8rsubg$ka7$1@news-hrz.uni-duisburg.de>,
sb463ba@l1-hrz.uni-duisburg.de (Georg Bauhaus) wrote:
> package Whoops is -- illegal!
>
> subtype Constr is private;
> -- [[Constr]] is constrained, but the constraints need
> -- not be known outside
>
> private
> subtype Constr is Natural range 0..99;
> end Whoops;
That makes a little bit of sense. After all, if the client doesn't know
that Constr is a subtype of Natural, then what should the compiler do if
the client tries to assign a Constr to an Integer? The most probable
answer is "report an error". But if that's the case, Constr is really no
better to the client than a derived type. If fact, its worse. So why not
just use a derived type and be done with it?
--
T.E.D.
http://www.telepath.com/~dennison/Ted/TED.html
Day 1 of Free Europe
Sent via Deja.com http://www.deja.com/
Before you buy.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: private "subtype"s
2000-10-09 0:00 ` Ted Dennison
@ 2000-10-10 0:00 ` Georg Bauhaus
0 siblings, 0 replies; 3+ messages in thread
From: Georg Bauhaus @ 2000-10-10 0:00 UTC (permalink / raw)
Ted Dennison:
: That makes a little bit of sense.
At least :-) I started thinking it doesn't
and only made things awkwardly complex. So
would I be better off using some tagged records
for the following example?
package Society is
type Person is
(Dumb, Boring, Average, Skilled, Smart, Clever, Genius, Freaky);
-- (rather incomplete)
end Society;
generic
How_Many: Positive;
-- counting the crowd
package Society.Club is
-- sub-
type Correct_People is private;
-- a selection of more distinguished persons
type Participants is
array(1..How_Many) of Correct_People;
procedure Party(P: Participants);
procedure Celebrate(P: Participants) renames Party;
-- stay PC
private
-- sub-
type Correct_People is new Person
range Smart..Genius;
end Society.Club;
generic
How_Many: Positive;
-- counting the crowd
package Society.Joe_Bloggs is
-- sub-
type Cheap_Flat_People is private;
-- a selection of persons
type Participants is
array(1..How_Many) of Cheap_Flat_People;
procedure Party(P: Participants);
procedure Get_Drunk(P: Participants) renames Party;
-- well, maybe
private
-- sub-
type Cheap_Flat_People is new Person
range Dumb..Average;
-- if you can believe this
end Society.Joe_Bloggs;
The admittedly vague idea in the code
is to have someone like Groucho Marx enter the
Club and not having to be converted to another
type of person...
But with "-- sub-"types below it looks like
requiring constraints to trigger similar things
like types can do. Yes, so there...
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2000-10-10 0:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-09 0:00 private "subtype"s Georg Bauhaus
2000-10-09 0:00 ` Ted Dennison
2000-10-10 0:00 ` Georg Bauhaus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox