From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Full view of a private partial view cannot be a subtype
Date: Wed, 6 Dec 2017 18:52:13 -0600
Date: 2017-12-06T18:52:13-06:00 [thread overview]
Message-ID: <p0a3bs$ksq$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: f73127a6-2334-430b-80a0-0ac9b9519e89@googlegroups.com
>"Shark8" <onewingedshark@gmail.com> wrote in message
>news:f73127a6-2334-430b-80a0-0ac9b9519e89@googlegroups.com...
>On Tuesday, December 5, 2017 at 1:59:05 PM UTC-7, Randy Brukardt wrote:
>> "Shark8" wrote in message
>> news:43498b2a-773c-454a-b0e7-ade5d6594bd4googlegroups.com...
>> ...
>> >Besides UIs, the one problem that springs immediately to mind is the
>> >internals of a
>> >compiler's IR/parse-tree.
>>
>> I can speak to this (at least somewhat), and I think the full OOP version
>> would be a nightmare.
>
>For [only] the Parse-tree/IR?
>I honestly don't see why it wouldn't work as a hierarchy, and in fact think
>it would naturally go that way, especially in an Ada program where you
>have trees all over the place: the library-hierarchy, nesting of various
>Ada-elements (package, subprogram, task), etc.
Of course there is a hierarchy, but that is the least interesting feature of
"full OOP" as I understand it. (Especially as a variant record is also a
representation of a hierarchy.) A "full OOP" version has to use dispatching
operations for essentially all operations on the parse-tree. But there are a
*lot* of those operations.
Just consider tree walks. Janus/Ada has five primary expression tree walks
(remember, Janus/Ada doesn't use trees for anything bigger than an
expression), and a number of secondary ones. These don't all walk the tree
in the same way, given the different purposes. So one ends up with a whole
bunch of primitive routines that walk the tree for different purposes and in
slightly different ways.
When you create a new kind of node (which should be fairly frequent for an
agile programmers), you have to write bodies for all of these routines. A
lot of the code of each routine is similar, but sharing that code is hard,
given that it is interspresed with the other stuff that the tree walk is
doing. For me (in the Claw Builder), it felt like implementing a lot of
boilerplate.
Then you have similar things for code generation, serialization (to read
trees in and out), and so on.
This sort of thing makes agile programming rather difficult (and I thought
that big-bang programming was mostly dead), as one can't even compile (much
less test) the new node until all of those routines exist somehow. That took
a very long time investment for the Claw Builder, and I suspect a real
compiler would be even worse.
Worse, if you find you need a new kind of tree walk part way through
development, you have to add a new kind of dispatching routine to the root
of the tree, and then add implementations to every node type. That takes
forever, and is absolutely not agile programming.
Certainly, there are some tools that could help some, but my experience
suggests that
>Here's an interesting tutorial on Pratt Parsing that illustrates the
>technique (albeit in
>Java), but while it's on parsing in-general it shows how the elements
>constructed
>can be "smart" enough to construct themselves*
This is no problem to do (as noted above), the problem is that the result is
very hard to modify. And if you are building something large and long-lived
like an Ada compiler, you WILL have to modify it a lot. Maybe Ada 2020 comes
out, maybe you need to implement a new code generation technique (to improve
performance or fix a problem with the existing one).
Modifications of OOP designs are inside-out: what usually would be a local
changes (say a special tree walk to be used in a generic instantiation case)
tend to have to be done globally (a new dispatching routine has to be added
to every node), and global changes (like adding a new node) tend to be more
local. The problem with that is that adding a new node is rather rare (the
Ada 2012 changes are the first new expression nodes in Janus/Ada since about
1990), while local fixes to fix bugs are rather common.
You might be able to avoid this problem by abandoning OOP for significant
parts of the code, but the OOP structure is not then gaining anything about
extra work to write every dispatching routine.
Someone who has never used variant records in Ada might not realize how
strong a solution that they actually are to these sorts of problems, and
thus might think that an OOP solution is the only way to go. But that's not
really true.
Randy.
next prev parent reply other threads:[~2017-12-07 0:52 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-03 2:14 Full view of a private partial view cannot be a subtype Jere
2017-12-03 12:01 ` Jeffrey R. Carter
2017-12-03 13:33 ` Jere
2017-12-03 14:34 ` Jeffrey R. Carter
2017-12-03 17:44 ` Robert Eachus
2017-12-03 18:50 ` Simon Wright
2017-12-03 22:10 ` Robert Eachus
2017-12-03 19:03 ` Jeffrey R. Carter
2017-12-03 22:23 ` Jere
2017-12-04 8:25 ` Dmitry A. Kazakov
2017-12-04 18:04 ` Jeffrey R. Carter
2017-12-04 20:41 ` Jere
2017-12-04 21:48 ` Jeffrey R. Carter
2017-12-05 8:20 ` Dmitry A. Kazakov
2017-12-05 18:16 ` Jeffrey R. Carter
2017-12-05 20:39 ` Dmitry A. Kazakov
2017-12-05 21:38 ` Jeffrey R. Carter
2017-12-05 12:35 ` Jere
2017-12-05 18:40 ` Jeffrey R. Carter
2017-12-06 12:54 ` Jere
2017-12-06 18:03 ` Jeffrey R. Carter
2017-12-05 20:22 ` Randy Brukardt
2017-12-05 15:27 ` Shark8
2017-12-05 18:50 ` Jeffrey R. Carter
2017-12-05 20:59 ` Randy Brukardt
2017-12-05 22:43 ` Shark8
2017-12-07 0:52 ` Randy Brukardt [this message]
2017-12-05 20:16 ` Randy Brukardt
2017-12-05 21:29 ` Jeffrey R. Carter
2017-12-07 0:04 ` Randy Brukardt
2017-12-04 20:49 ` Randy Brukardt
2017-12-05 12:56 ` Jere
2017-12-05 20:12 ` Randy Brukardt
2017-12-17 15:26 ` Jere
2017-12-17 15:39 ` Dmitry A. Kazakov
2017-12-18 22:47 ` Randy Brukardt
2017-12-19 1:22 ` Jere
2017-12-19 23:16 ` Randy Brukardt
2017-12-19 1:01 ` Jere
2017-12-19 9:08 ` Dmitry A. Kazakov
2017-12-19 13:08 ` Jere
2017-12-19 13:27 ` Dmitry A. Kazakov
2017-12-19 19:10 ` Stephen Leake
2017-12-18 20:45 ` Stephen Leake
2017-12-18 22:54 ` Randy Brukardt
2017-12-19 1:08 ` Jere
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox