From: Jakub Narebski <jnareb@gmail.com>
To: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 5/7] gitweb: auxiliary functions to group data
Date: Fri, 17 Sep 2010 19:17:44 +0200 [thread overview]
Message-ID: <201009171917.44979.jnareb@gmail.com> (raw)
In-Reply-To: <AANLkTikjLNva7Jgh0xYeah1maFusfOiaLwY7+eixx8so@mail.gmail.com>
On Fri, 17 Sep 2010, Giuseppe Bilotta wrote:
> On Fri, Sep 17, 2010 at 6:06 PM, Jakub Narebski <jnareb@gmail.com> wrote:
>> Giuseppe Bilotta wrote:
>>> On Fri, Sep 17, 2010 at 3:24 AM, Jakub Narebski <jnareb@gmail.com> wrote:
>>>>
>>>> ... but I think that having separate subroutines for opening and
>>>> closing tags is a bad design / bad API (except in some rare cases).
>>>> It is begging for unbalanced HTML.
>>>>
>>>> It would be better if it was a single subroutine wrapping 'div' around
>>>> contents given either as a string, or via callback (subroutine reference),
>>>> in my opinion.
>>>
>>> I'm not sure that in this case the string or callback approach would
>>> be any cleaner. I'll see if perl supports closures or something like
>>> that.
>>
>> Perl supports closures (thanks to anonymous subroutines 'sub { ... }'
>> and lexical variables 'my $var'), see perlsub and "Function Templates"
>> in perlref.
>>
>> I also recommend free ebook "Higher-Order Perl" http://hop.perl.plover.com/
>
> Thanks for the suggestion. I'm still not convinced that such an
> implementation would be better though. Aside from the general
> aesthetical suckiness of passing closures around (and the experience
> is not any more pleasurable in Perl), there's also the matter of the
> calling convention to use. I can think of two options:
>
> (1) we make the function callable as git_do_group($class, $id, sub {
> <closure that prints the content> }, <paramters that go to
> git_print_header_div>), which is somewhat illogical since we're
> specifying the content before the header,
Why not
git_do_group($class, $id, <print_header_div parameters>, sub { ... })
or even use subroutine prototypes? We can use 'pop @_' to get last
argument of a subroutine.
[...]
> Overall, I still get the impression that the current API is
> considerably cleaner, even with the small counterweight of the risk of
> leaving groups open (which is not something so dramatic anyway, IMO).
Might be.
But as currently git_*group() is used in only one place, isn't it
premature generalization ;-) ?
--
Jakub Narebski
Poland
next prev parent reply other threads:[~2010-09-17 17:17 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-16 9:30 [PATCH 0/7] gitweb: allheads feature Giuseppe Bilotta
2010-09-16 9:30 ` [PATCH 1/7] gitweb: introduce remote_heads feature Giuseppe Bilotta
2010-09-16 21:41 ` Jakub Narebski
2010-09-17 15:39 ` Giuseppe Bilotta
2010-09-16 9:31 ` [PATCH 2/7] gitweb: git_get_heads_list accepts an optional list of refs Giuseppe Bilotta
2010-09-16 22:14 ` Jakub Narebski
2010-09-17 15:52 ` Giuseppe Bilotta
2010-09-16 9:31 ` [PATCH 3/7] gitweb: separate heads and remotes lists Giuseppe Bilotta
2010-09-16 10:19 ` Ævar Arnfjörð Bjarmason
2010-09-16 11:35 ` Giuseppe Bilotta
2010-09-16 22:30 ` Jakub Narebski
2010-09-16 22:54 ` Ævar Arnfjörð Bjarmason
2010-09-16 22:46 ` Jakub Narebski
2010-09-16 9:31 ` [PATCH 4/7] gitweb: link heads and remotes view Giuseppe Bilotta
2010-09-16 23:02 ` Jakub Narebski
2010-09-17 16:01 ` Giuseppe Bilotta
2010-09-16 9:31 ` [PATCH 5/7] gitweb: auxiliary functions to group data Giuseppe Bilotta
2010-09-16 10:26 ` Ævar Arnfjörð Bjarmason
2010-09-17 1:24 ` Jakub Narebski
2010-09-17 6:54 ` Giuseppe Bilotta
2010-09-17 16:06 ` Jakub Narebski
2010-09-17 16:41 ` Giuseppe Bilotta
2010-09-17 17:17 ` Jakub Narebski [this message]
2010-09-18 7:51 ` Giuseppe Bilotta
2010-09-16 9:31 ` [PATCH 6/7] gitweb: group styling Giuseppe Bilotta
2010-09-17 16:26 ` Jakub Narebski
2010-09-17 16:49 ` Giuseppe Bilotta
2010-09-17 17:22 ` Jakub Narebski
2010-09-16 9:31 ` [PATCH 7/7] gitweb: group remote heads Giuseppe Bilotta
2010-09-16 10:29 ` Ævar Arnfjörð Bjarmason
2010-09-16 11:36 ` Giuseppe Bilotta
2010-09-17 16:54 ` Jakub Narebski
2010-09-17 17:25 ` Jakub Narebski
2010-09-19 5:39 ` Giuseppe Bilotta
2010-09-19 23:02 ` Jakub Narebski
2010-09-20 8:15 ` Giuseppe Bilotta
2010-09-20 8:59 ` Jakub Narebski
2010-09-20 9:38 ` Giuseppe Bilotta
2010-09-22 8:34 ` Jakub Narebski
2010-09-22 9:34 ` Giuseppe Bilotta
2010-09-16 21:26 ` [PATCH 0/7] gitweb: allheads feature Jakub Narebski
2010-09-17 7:24 ` Giuseppe Bilotta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201009171917.44979.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=giuseppe.bilotta@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.