From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: S-expression I/O in Ada
Date: Tue, 24 Aug 2010 18:56:32 -0700
Date: 2010-08-24T18:56:32-07:00 [thread overview]
Message-ID: <i51t8h$3mf$1@adenine.netfront.net> (raw)
In-Reply-To: <slrni77bvq.dki.lithiumcat@sigil.instinctive.eu>
On 08/24/2010 04:41 AM, Natasha Kerensikova wrote:
>
> Does anybody have an idea about how to solve this issue?
What issue? You haven't demonstrated that a deep copy is a problem anywhere
outside your mind. If you implement this and find that actual use exhausts
memory or takes longer than the user is willing to wait (~2 sec) then you have
something to worry about.
> Another point I discovered while writing this implementation, is that I
> end up writing a lot of wrappers over the container's functions. Would
> it be possible to somehow define List and Cursors directly as instances
> of the container respective types, and to expose directly container's
> functions? All this while maintaining the type hiding, I don't want to
> expose the container, and just want to specify "I expose this and that
> functions" and tell in the body "oh by the way, this and that functions
> are just public names of this and that container functions". This way
> the code would be lighter but still as flexible (whenever I'm not
> satisfied with container functions, or whenever I want to change the
> container, I just have to (re)write the publicly exposed functions
> without changing the specification).
This is called "renaming as body": you implement the declaration with a renames
of another subprogram:
function F (I : Integer) return Integer;
and later
package P is new Something (...);
function F renames P.F;
This requires that both subprograms have the same parameter and result type profile.
> I still can't estimate how bad or inelegant
> or ugly are explicit access. I guess even in Ada they have some niche
> use, and avoiding expensive copy can be one them, right?
They are needed to implement things like Ada.Containers.Doubly_Linked_Lists.
> Last point, I had trouble finding names. I read the Ada 95 Quality and
> Style Guide, and I find it difficult to follow. For example, I was
> tempted to call "Atom" the public array representation, the internal
> node type, and the function taking a Cursor and returning the public
> array representation. I was tempted to call "Node_Type" the public
> enumeration type, the function taking a Cursor and returning the type of
> the pointed node, and (not in this implementation but in some other
> attempts) the internal object discriminant name.
One thing about choosing names: the fewer names you have to choose, the less of
an issue it is. If you use a Boolean for the discriminant, for example, then you
don't need to choose names for the type of the discriminant or its values.
Overloading can also help reduce the number of unique names. Your procedures
String_To_Atom and Atom_To_String could be named To_Atom and To_String, same as
your functions, just as you did later with procedures and functions named Next
and Previous for Cursor.
A and S are terrible parameter names for these procedures. I would probably use
Value and Image, respectively.
> package S_Expressions is
>
> -----------
> -- Types --
> -----------
This is a worthless comment; we can tell that these are type declarations.
It's also not a good way to structure your code. Logically related things should
be grouped together, not grouped by an incidental relationship such as "these
are all types". You might want to group all declarations relating to Atoms, for
example, then all relating to Lists, and so on.
> type Node_Kind is (Node_Atom, Node_List);
These seem backward from an English usage point of view. Both are nodes, so the
rest is a modifier that indicates the kind of node. In English, modifiers
usually come before the thing they modify, so Atom_Node and List_Node would be
more natural. It also puts the important difference between the 2 first, where
it is immediately apparent.
> procedure String_To_Atom(S : in String; A : out Atom_Data);
> procedure Atom_To_String(A : in Atom_Data; S : out String);
These are only partly specified. What happens if S'Length /= A'Length?
> procedure Counts(sexp : in List; Atom_Count, List_Count : out Count_Type);
> function Atom_Count(sexp : in List) return Count_Type;
> function List_Count(sexp : in List) return Count_Type;
> function Node_Count(sexp : in List) return Count_Type;
These are problematical. I'd use Length rather than Node_Count, but I'm not sure
what I'd name the others.
>
> function Is_Atom(Element : in Cursor) return Boolean;
> function Is_List(Element : in Cursor) return Boolean;
> function Kind_Of(Element : in Cursor) return Node_Kind;
Is_* is good, but I'd just use Kind for the 3rd.
> function Atom_Size(Element : in Cursor) return Natural;
> function Atom_Contents(Element : in Cursor) return Atom_Data;
> function Atom_To_String(Element : in Cursor) return String;
Again, Length, Contents, and To_String (or Image). What happens if Element isn't
an Atom?
> procedure Query_List(Element : in Cursor;
> Process : not null access procedure
> (Sub_Sexp : in List));
> function Sublist_First(Element : in Cursor) return Cursor;
> function Sublist_Last(Element : in Cursor) return Cursor;
What happens when Element isn't a List?
--
Jeff Carter
"Help! Help! I'm being repressed!"
Monty Python & the Holy Grail
67
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
next prev parent reply other threads:[~2010-08-25 1:56 UTC|newest]
Thread overview: 252+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-01 12:17 S-expression I/O in Ada Natacha Kerensikova
2010-08-01 12:53 ` Dmitry A. Kazakov
2010-08-01 17:35 ` Natacha Kerensikova
2010-08-01 18:49 ` Dmitry A. Kazakov
2010-08-01 20:06 ` Natacha Kerensikova
2010-08-01 21:13 ` Dmitry A. Kazakov
2010-08-02 7:17 ` Georg Bauhaus
2010-08-02 7:58 ` Dmitry A. Kazakov
2010-08-07 7:23 ` Natacha Kerensikova
2010-08-07 8:39 ` Dmitry A. Kazakov
2010-08-07 12:56 ` Natacha Kerensikova
2010-08-07 14:23 ` Dmitry A. Kazakov
2010-08-08 12:23 ` Natacha Kerensikova
2010-08-08 13:01 ` Dmitry A. Kazakov
2010-08-08 13:49 ` Natacha Kerensikova
2010-08-08 15:15 ` Dmitry A. Kazakov
2010-08-09 9:55 ` Natacha Kerensikova
2010-08-09 10:56 ` Dmitry A. Kazakov
2010-08-10 8:56 ` Natacha Kerensikova
2010-08-10 10:17 ` Georg Bauhaus
2010-08-10 10:36 ` Dmitry A. Kazakov
2010-08-10 12:06 ` Natacha Kerensikova
2010-08-10 15:46 ` Dmitry A. Kazakov
2010-08-10 21:22 ` Simon Wright
2010-08-11 7:37 ` Dmitry A. Kazakov
2010-08-11 17:32 ` Simon Wright
2010-08-11 17:53 ` Dmitry A. Kazakov
2010-08-11 9:43 ` Natacha Kerensikova
2010-08-11 10:37 ` Dmitry A. Kazakov
2010-08-11 11:38 ` Natacha Kerensikova
2010-08-11 12:58 ` Robert A Duff
2010-08-11 15:30 ` Natacha Kerensikova
2010-08-11 23:39 ` Randy Brukardt
2010-08-12 1:31 ` Robert A Duff
2010-08-12 8:53 ` Natacha Porté
2010-08-12 9:22 ` Georg Bauhaus
2010-08-13 9:43 ` Natacha Kerensikova
2010-08-10 21:56 ` Randy Brukardt
2010-08-09 15:40 ` Simon Wright
2010-08-09 16:35 ` Robert A Duff
2010-08-10 0:51 ` Randy Brukardt
2010-08-10 1:00 ` Jeffrey Carter
2010-08-10 21:36 ` Randy Brukardt
2010-08-10 22:24 ` Jeffrey Carter
2010-08-10 12:50 ` Robert A Duff
2010-08-10 22:06 ` Randy Brukardt
2010-08-09 18:37 ` Natacha Kerensikova
2010-08-09 19:10 ` Robert A Duff
2010-08-08 14:08 ` Duke Normandin
2010-08-08 15:34 ` Robert A Duff
2010-08-08 18:24 ` Dmitry A. Kazakov
2010-08-08 20:03 ` Robert A Duff
2010-08-08 20:39 ` Dmitry A. Kazakov
2010-08-08 21:08 ` Robert A Duff
2010-08-09 6:50 ` Dmitry A. Kazakov
2010-08-09 13:48 ` Robert A Duff
2010-08-09 14:38 ` Dmitry A. Kazakov
2010-08-09 15:14 ` Georg Bauhaus
2010-08-09 16:11 ` Dmitry A. Kazakov
2010-08-09 16:46 ` Georg Bauhaus
2010-08-09 17:05 ` Robert A Duff
2010-08-09 18:29 ` Georg Bauhaus
2010-08-09 19:18 ` Robert A Duff
2010-08-10 8:21 ` Georg Bauhaus
2010-08-09 20:40 ` Dmitry A. Kazakov
2010-08-09 22:21 ` Georg Bauhaus
2010-08-10 7:07 ` Dmitry A. Kazakov
2010-08-09 16:47 ` Robert A Duff
2010-08-09 19:59 ` Dmitry A. Kazakov
2010-08-09 21:34 ` Robert A Duff
2010-08-09 22:29 ` Jeffrey Carter
2010-08-10 7:48 ` Dmitry A. Kazakov
2010-08-09 21:54 ` _FrnchFrgg_
2010-08-09 22:32 ` Georg Bauhaus
2010-08-10 7:16 ` Dmitry A. Kazakov
2010-08-10 11:06 ` _FrnchFrgg_
2010-08-10 11:19 ` Dmitry A. Kazakov
2010-08-10 23:04 ` _FrnchFrgg_
2010-08-11 14:10 ` Dmitry A. Kazakov
2010-08-11 17:51 ` Structural unification (pattern matching) in Ada [was: Re: S-expression I/O in Ada] _FrnchFrgg_
2010-08-11 18:06 ` Dmitry A. Kazakov
2010-08-11 19:43 ` Robert A Duff
2010-08-11 20:26 ` (see below)
2010-08-11 21:21 ` Structural unification (pattern matching) in Ada Simon Wright
2010-08-12 12:43 ` Structural unification (pattern matching) in Ada [was: Re: S-expression I/O in Ada] _FrnchFrgg_
2010-08-10 1:06 ` S-expression I/O in Ada Randy Brukardt
2010-08-09 16:50 ` Robert A Duff
2010-08-09 18:32 ` Natacha Kerensikova
2010-08-09 19:06 ` Jeffrey Carter
2010-08-09 19:24 ` Robert A Duff
2010-08-09 19:35 ` (see below)
2010-08-09 17:00 ` Robert A Duff
2010-08-09 20:27 ` Dmitry A. Kazakov
2010-08-09 21:30 ` Robert A Duff
2010-08-10 1:17 ` Randy Brukardt
2010-08-10 6:48 ` Dmitry A. Kazakov
2010-08-10 21:42 ` Randy Brukardt
2010-08-11 8:02 ` Dmitry A. Kazakov
2010-08-11 23:18 ` Randy Brukardt
2010-08-12 6:20 ` Dmitry A. Kazakov
2010-08-12 20:56 ` Randy Brukardt
2010-08-13 6:56 ` Dmitry A. Kazakov
2010-08-14 0:52 ` Randy Brukardt
2010-08-09 18:55 ` Jeffrey Carter
2010-08-09 18:20 ` Natacha Kerensikova
2010-08-09 19:19 ` Robert A Duff
2010-08-07 15:38 ` Jeffrey Carter
2010-08-07 17:01 ` Natacha Kerensikova
2010-08-08 6:52 ` Jeffrey Carter
2010-08-08 13:11 ` Natacha Kerensikova
2010-08-08 15:24 ` Robert A Duff
2010-08-09 18:00 ` Natacha Kerensikova
2010-08-09 18:09 ` Robert A Duff
2010-08-08 20:34 ` Jeffrey Carter
2010-08-09 18:10 ` Natacha Kerensikova
2010-08-08 10:26 ` Simon Wright
2010-08-08 11:44 ` Dmitry A. Kazakov
2010-08-08 11:48 ` Dmitry A. Kazakov
2010-08-08 14:05 ` Natacha Kerensikova
2010-08-08 20:11 ` Jeffrey Carter
2010-08-14 1:02 ` Yannick Duchêne (Hibou57)
2010-08-14 9:53 ` Georg Bauhaus
2010-08-14 11:32 ` Natacha Kerensikova
2010-08-01 22:03 ` Simon Wright
2010-08-02 17:08 ` Pascal Obry
2010-08-02 19:08 ` Simon Wright
2010-08-01 16:01 ` Ludovic Brenta
2010-08-09 18:49 ` Ludovic Brenta
2010-08-09 19:59 ` Natacha Kerensikova
2010-08-10 0:11 ` Ludovic Brenta
2010-08-10 0:57 ` Jeffrey Carter
2010-08-10 6:47 ` Natacha Kerensikova
2010-08-10 18:13 ` Jeffrey Carter
2010-08-12 9:26 ` Natacha Kerensikova
2010-08-12 10:55 ` Ludovic Brenta
2010-08-12 12:16 ` Natacha Kerensikova
2010-08-12 12:46 ` Ludovic Brenta
2010-08-12 13:23 ` Natacha Kerensikova
2010-08-12 16:19 ` Ludovic Brenta
2010-08-12 17:17 ` Natacha Kerensikova
2010-08-12 18:51 ` Jeffrey Carter
2010-08-13 9:32 ` Natacha Kerensikova
2010-08-13 15:52 ` Ludovic Brenta
2010-08-13 22:53 ` Jeffrey R. Carter
2010-08-14 11:10 ` Natacha Kerensikova
2010-08-10 15:48 ` Ludovic Brenta
2010-08-10 15:59 ` Georg Bauhaus
2010-08-12 7:53 ` Ludovic Brenta
2010-08-12 18:55 ` Jeffrey Carter
2010-08-12 19:59 ` Ludovic Brenta
2010-08-12 20:23 ` Natacha Kerensikova
2010-08-12 20:45 ` Ludovic Brenta
2010-08-13 8:24 ` Natacha Kerensikova
2010-08-13 9:08 ` Ludovic Brenta
2010-08-14 10:27 ` Natacha Kerensikova
2010-08-14 11:11 ` Ludovic Brenta
2010-08-14 12:17 ` Natasha Kerensikova
2010-08-14 13:13 ` Ludovic Brenta
2010-08-14 13:33 ` Yannick Duchêne (Hibou57)
2010-08-12 22:25 ` Jeffrey R. Carter
2010-08-13 9:10 ` Natacha Kerensikova
2010-08-13 9:51 ` Dmitry A. Kazakov
2010-08-14 10:36 ` Natacha Kerensikova
2010-08-14 10:57 ` Dmitry A. Kazakov
2010-08-13 19:23 ` Jeffrey Carter
2010-08-13 19:42 ` Dmitry A. Kazakov
2010-08-13 20:44 ` Yannick Duchêne (Hibou57)
2010-08-14 0:57 ` Randy Brukardt
2010-08-14 10:47 ` Natacha Kerensikova
2010-08-13 19:36 ` Simon Wright
2010-08-12 20:11 ` Natacha Kerensikova
2010-08-12 20:22 ` Ludovic Brenta
2010-08-01 18:25 ` Jeffrey Carter
2010-08-01 19:43 ` Natacha Kerensikova
2010-08-01 19:53 ` Ludovic Brenta
2010-08-01 20:00 ` Dmitry A. Kazakov
2010-08-01 20:03 ` Jeffrey Carter
2010-08-01 20:34 ` Georg Bauhaus
2010-08-01 20:44 ` Georg Bauhaus
2010-08-01 21:01 ` anon
2010-08-12 23:26 ` Shark8
2010-08-13 2:31 ` Shark8
2010-08-13 8:56 ` Natacha Kerensikova
2010-08-13 10:30 ` Georg Bauhaus
2010-08-13 15:58 ` Shark8
2010-08-13 21:48 ` Shark8
2010-08-14 11:02 ` Natacha Kerensikova
2010-08-17 17:01 ` Natasha Kerensikova
2010-08-17 19:00 ` Jeffrey Carter
2010-08-18 10:49 ` Natasha Kerensikova
2010-08-18 11:14 ` Ludovic Brenta
2010-08-18 11:59 ` Natasha Kerensikova
2010-08-18 12:31 ` Ludovic Brenta
2010-08-18 13:16 ` J-P. Rosen
2010-08-18 13:55 ` Natasha Kerensikova
2010-08-18 14:40 ` J-P. Rosen
2010-08-20 20:50 ` Yannick Duchêne (Hibou57)
2010-08-18 15:07 ` Ludovic Brenta
2010-08-19 7:42 ` Natasha Kerensikova
2010-08-18 12:51 ` Georg Bauhaus
2010-08-18 13:24 ` Natasha Kerensikova
2010-08-18 14:40 ` Georg Bauhaus
2010-08-18 23:50 ` Randy Brukardt
2010-08-18 11:22 ` Georg Bauhaus
2010-08-18 12:02 ` Natasha Kerensikova
2010-08-20 21:04 ` Yannick Duchêne (Hibou57)
2010-08-22 10:21 ` Natasha Kerensikova
2010-08-22 10:28 ` Simon Wright
2010-08-22 17:13 ` Jeffrey Carter
2010-08-22 14:06 ` Dmitry A. Kazakov
2010-08-21 19:36 ` Yannick Duchêne (Hibou57)
2010-08-18 18:08 ` Jeffrey Carter
2010-08-19 8:09 ` Natasha Kerensikova
2010-08-19 10:16 ` Natasha Kerensikova
2010-08-19 10:42 ` Dmitry A. Kazakov
2010-08-22 10:24 ` Natasha Kerensikova
2010-08-22 14:10 ` Dmitry A. Kazakov
2010-08-19 18:07 ` Jeffrey Carter
2010-08-22 10:43 ` Natasha Kerensikova
2010-08-22 17:17 ` Jeffrey Carter
2010-08-19 17:59 ` Jeffrey Carter
2010-08-22 10:45 ` Natasha Kerensikova
2010-08-22 17:20 ` Jeffrey Carter
2010-08-24 11:41 ` Natasha Kerensikova
2010-08-25 1:56 ` Jeffrey Carter [this message]
2010-08-25 12:18 ` Natasha Kerensikova
2010-08-25 14:07 ` Jeffrey Carter
2010-08-25 8:06 ` Georg Bauhaus
2010-08-25 13:27 ` Natasha Kerensikova
2010-08-25 18:55 ` Simon Wright
2010-08-25 19:19 ` Georg Bauhaus
2010-08-25 19:23 ` Georg Bauhaus
2010-08-25 22:38 ` Simon Wright
2010-08-25 23:55 ` Georg Bauhaus
2010-08-27 13:19 ` Natasha Kerensikova
2010-08-27 14:57 ` Georg Bauhaus
2010-08-29 10:45 ` Natasha Kerensikova
2010-08-29 13:10 ` Simon Wright
2010-08-29 14:21 ` Natasha Kerensikova
2010-08-29 14:30 ` Niklas Holsti
2010-08-29 13:23 ` Robert A Duff
2010-08-29 13:57 ` Jeffrey Carter
2010-08-29 14:18 ` Britt Snodgrass
2010-08-29 14:29 ` Natasha Kerensikova
2010-08-29 15:12 ` Robert A Duff
2010-09-03 21:52 ` Randy Brukardt
2010-08-29 13:56 ` Jeffrey Carter
2010-08-29 14:34 ` Natasha Kerensikova
2010-08-29 14:55 ` Dmitry A. Kazakov
2010-08-29 15:25 ` Robert A Duff
2010-08-29 18:50 ` Georg Bauhaus
2010-08-29 21:43 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox