* Tagged type abuse
@ 2014-12-18 11:26 Natasha Kerensikova
2014-12-18 13:01 ` Dmitry A. Kazakov
2014-12-18 16:59 ` Jeffrey Carter
0 siblings, 2 replies; 7+ messages in thread
From: Natasha Kerensikova @ 2014-12-18 11:26 UTC (permalink / raw)
Hello,
I find myself using more and more tagged types for reasons that have
nothing to do with tagging, mostly the prefix notations (when it helps
readability and when a function call is conceptually accessing a record
element but with a hidden concrete implementation) and the passing by
reference.
However, I still feel guilty about it, like I'm abusing a feature
unrelated to what I wish to accomplish.
What would you recommend to appease such feelings?
Sacrificing prefix notation readability on types that have no business
being tagged?
Trying to be more pragmatic and use tools (and language features) for any
purpose at which they end up being useful, even unintended?
Natasha
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tagged type abuse
2014-12-18 11:26 Tagged type abuse Natasha Kerensikova
@ 2014-12-18 13:01 ` Dmitry A. Kazakov
2014-12-18 16:59 ` Jeffrey Carter
1 sibling, 0 replies; 7+ messages in thread
From: Dmitry A. Kazakov @ 2014-12-18 13:01 UTC (permalink / raw)
On Thu, 18 Dec 2014 11:26:58 +0000 (UTC), Natasha Kerensikova wrote:
> What would you recommend to appease such feelings?
That all types should have been tagged anyway (meaning: has T'Class with a
type tag stored in it).
> Sacrificing prefix notation readability on types that have no business
> being tagged?
I think that prefix notation was a language design bug. As such it has
nothing to do with the type being tagged or having a class.
Prefix notation should have been an implementation of an abstract record
member of some subprogram type.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tagged type abuse
2014-12-18 11:26 Tagged type abuse Natasha Kerensikova
2014-12-18 13:01 ` Dmitry A. Kazakov
@ 2014-12-18 16:59 ` Jeffrey Carter
2014-12-18 23:10 ` Randy Brukardt
1 sibling, 1 reply; 7+ messages in thread
From: Jeffrey Carter @ 2014-12-18 16:59 UTC (permalink / raw)
On 12/18/2014 04:26 AM, Natasha Kerensikova wrote:
>
> I find myself using more and more tagged types for reasons that have
> nothing to do with tagging, mostly the prefix notations (when it helps
> readability and when a function call is conceptually accessing a record
> element but with a hidden concrete implementation) and the passing by
> reference.
>
> However, I still feel guilty about it, like I'm abusing a feature
> unrelated to what I wish to accomplish.
>
> What would you recommend to appease such feelings?
There are three reasons I use tagged types:
1. To obtain finalization
2. To avoid explicit pointers in self-referential types
3. To obtain Object.Operation notation
--
Jeff Carter
"If you think you got a nasty taunting this time,
you ain't heard nothing yet!"
Monty Python and the Holy Grail
23
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tagged type abuse
2014-12-18 16:59 ` Jeffrey Carter
@ 2014-12-18 23:10 ` Randy Brukardt
2014-12-19 12:42 ` Michael B.
0 siblings, 1 reply; 7+ messages in thread
From: Randy Brukardt @ 2014-12-18 23:10 UTC (permalink / raw)
"Jeffrey Carter" <spam.jrcarter.not@spam.not.acm.org> wrote in message
news:m6v154$r9t$1@dont-email.me...
> On 12/18/2014 04:26 AM, Natasha Kerensikova wrote:
>>
>> I find myself using more and more tagged types for reasons that have
>> nothing to do with tagging, mostly the prefix notations (when it helps
>> readability and when a function call is conceptually accessing a record
>> element but with a hidden concrete implementation) and the passing by
>> reference.
>>
>> However, I still feel guilty about it, like I'm abusing a feature
>> unrelated to what I wish to accomplish.
>>
>> What would you recommend to appease such feelings?
>
> There are three reasons I use tagged types:
>
> 1. To obtain finalization
>
> 2. To avoid explicit pointers in self-referential types
>
> 3. To obtain Object.Operation notation
I think that Jeff is saying that not everyone thinks dynamic dispatching is
relevant. But tagged types still can be useful.
Note that in pre-2012 Ada, you needed to use tagged types get "=" to work
right vis-a-vis composition. (Ada 2012 extended that to all record types,
which of course means that some programs that expect the wrong answer will
break. But in most cases, the change will fix bugs rather than create them.)
I don't use dynamic dispatching much (outside of Claw anyway), but I
sometimes use inheritance to inherit implementations (rather than having to
duplicate them all over, with the corresponding maintenance headache).
I'd probably use tagged types to get prefix notation, but I'd have to
implement it in Janus/Ada first. :-)
Anyway, I wouldn't worry about it. Tagged types cost about the same as
regular record types (the only difference is the waste of space for the tag,
which only matters for tiny records) unless you use T'Class. So do what
makes you program work better.
(We couldn't make cursors in the containers be tagged, thus you can't use
prefixed notation to do various reading operations on the containers. One
more reason out of many that I think every container operation should have
had a container parameter. [Another reason is that preconditions make much
more sense if the container passed to an operation has a name.] But of
course there is as many container designs as there are programmers --
perhaps more -- and the big value was picking one. There is no way it could
have been perfect for every use anyway.)
Randy.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tagged type abuse
2014-12-18 23:10 ` Randy Brukardt
@ 2014-12-19 12:42 ` Michael B.
2014-12-20 0:07 ` Randy Brukardt
0 siblings, 1 reply; 7+ messages in thread
From: Michael B. @ 2014-12-19 12:42 UTC (permalink / raw)
Am 19.12.2014 um 00:10 schrieb Randy Brukardt:
> Note that in pre-2012 Ada, you needed to use tagged types get "=" to work
> right vis-a-vis composition. (Ada 2012 extended that to all record types,
> which of course means that some programs that expect the wrong answer will
> break. But in most cases, the change will fix bugs rather than create them.)
Could you be more specific on that?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tagged type abuse
2014-12-19 12:42 ` Michael B.
@ 2014-12-20 0:07 ` Randy Brukardt
2014-12-20 12:39 ` Michael B.
0 siblings, 1 reply; 7+ messages in thread
From: Randy Brukardt @ 2014-12-20 0:07 UTC (permalink / raw)
"Michael B." <michaelb@example.com> wrote in message
news:m716fq$91n$1@speranza.aioe.org...
> Am 19.12.2014 um 00:10 schrieb Randy Brukardt:
>> Note that in pre-2012 Ada, you needed to use tagged types get "=" to work
>> right vis-a-vis composition. (Ada 2012 extended that to all record types,
>> which of course means that some programs that expect the wrong answer
>> will
>> break. But in most cases, the change will fix bugs rather than create
>> them.)
>
> Could you be more specific on that?
The case in question is the operator used in a composed "=". That is, what
operator is used to compare components of a type in some non-limited
composite type.
In Ada 83-2005, untagged record types compose using a reimergence of
predefined "=" (the user-defined "=" is ignored in that case). That was not
changed in Ada 95 because of compatibility concerns. But the problem wasn't
going away, and having an aspect to do the right thing made no sense and
having an aspect to do the wrong thing helps no-one (the code would have to
be modified, but if you can do that, you might as well fix it). So we just
changed it. We think that 99% of the time, people would rather have the
user-defined "=" used (why else would you have defined it?)
Randy.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tagged type abuse
2014-12-20 0:07 ` Randy Brukardt
@ 2014-12-20 12:39 ` Michael B.
0 siblings, 0 replies; 7+ messages in thread
From: Michael B. @ 2014-12-20 12:39 UTC (permalink / raw)
Sounds like a reasonable change. Thanks for clarifying.
Regards,
Michael
On 12/20/14 01:07, Randy Brukardt wrote:
> In Ada 83-2005, untagged record types compose using a reimergence of
> predefined "=" (the user-defined "=" is ignored in that case). That was not
> changed in Ada 95 because of compatibility concerns. But the problem wasn't
> going away, and having an aspect to do the right thing made no sense and
> having an aspect to do the wrong thing helps no-one (the code would have to
> be modified, but if you can do that, you might as well fix it). So we just
> changed it. We think that 99% of the time, people would rather have the
> user-defined "=" used (why else would you have defined it?)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-12-20 12:39 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-18 11:26 Tagged type abuse Natasha Kerensikova
2014-12-18 13:01 ` Dmitry A. Kazakov
2014-12-18 16:59 ` Jeffrey Carter
2014-12-18 23:10 ` Randy Brukardt
2014-12-19 12:42 ` Michael B.
2014-12-20 0:07 ` Randy Brukardt
2014-12-20 12:39 ` Michael B.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox