Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #6737
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Eric Sosman <esosman@ieee-dot-org.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: looping through a list, starting at 1 |
| Date | Tue, 02 Aug 2011 07:31:17 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 50 |
| Message-ID | <j18n7b$iia$1@dont-email.me> (permalink) |
| References | <list-20110802003845@ram.dialup.fu-berlin.de> <j17l8r$1p2$1@dont-email.me> <loop-20110802043110@ram.dialup.fu-berlin.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Tue, 2 Aug 2011 11:31:55 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="f8igmItKsWs6nM5YanFxAA"; logging-data="19018"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XkDyTVkAY8WSy70dJ7vQh" |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0 |
| In-Reply-To | <loop-20110802043110@ram.dialup.fu-berlin.de> |
| Cancel-Lock | sha1:CAWbbWr3IvWkMxN6W2UMwgADfS0= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6737 |
Show key headers only | View raw
On 8/1/2011 10:43 PM, Stefan Ram wrote:
> Eric Sosman<esosman@ieee-dot-org.invalid> writes:
>> ... and "natural" is a little unnatural, it seems to me. If
>> the various E are truly independent -- if l is merely a Collection
>> for the purposes of the loop -- one wonders where the interloper at
>> position 0 came from.
>
> This is code for my new mark-up language. A section might
> look like:
>
> < [This is an example heading]
>
> [This is the first paragraph of the body.]
>
> [This is the last paragraph of the body.]>
>
> . The first entry of a section always is interpreted as its
> heading, so a heading does not require additional mark-up.
>
> The code to convert this section to HTML converts the first
> entry »[This is an example heading]« into an HTML heading
> element. Then it loops through the rest of the entries to
> convert them to HTML paragraph elements.
It seems to me that the heading doesn't belong in the same
List as the remaining entries: It has special significance and
gets special handling. "I'm at position zero, so..." doesn't
stand out as a robust signifier of the heading's specialness,
and you might want to consider whether to manifest it in other
ways. For example, suppose you decide to introduce the notion
of sub-headings: You'll now need three treatments, but "I'm at
zero" can only divide one of them from the other two. Or maybe
you'd like to generate an index of all the section headings: In
a List of nothing but headings, "I'm at zero" is not special.
One possibility would be to keep the List, but to delegate
the formatting style to the entry itself. Make E abstract with
an abstract toHTML() method, and let headings and body entries
subclass it to provide their own implementations. Implementing
sub-headings then just amounts to writing a new E subclass. For
flexibility's sake, maybe E shouldn't just be "entry" but "entry
with formatter" so you can easily inject other formatters for
generating indexes, tables of contents, "site maps," and so on.
But there ought to be something more significant than "I'm
at position zero" to trigger the special handling. Just sayin'.
--
Eric Sosman
esosman@ieee-dot-org.invalid
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Re: looping through a list, starting at 1 Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-08-01 21:50 -0400
Re: looping through a list, starting at 1 Patricia Shanahan <pats@acm.org> - 2011-08-01 20:34 -0700
Re: looping through a list, starting at 1 Patricia Shanahan <pats@acm.org> - 2011-08-01 20:35 -0700
Re: looping through a list, starting at 1 Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-08-02 07:31 -0400
Re: looping through a list, starting at 1 Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2011-08-02 14:38 -0500
Re: looping through a list, starting at 1 markspace <-@.> - 2011-08-02 12:50 -0700
Re: looping through a list, starting at 1 Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2011-08-03 13:34 -0500
csiph-web